Ext4: Use get_cpu()/put_cpu() in preemptible context
A message that is not in the archive (sent off-list or not yet received): E1Inx4A-0002PQ-00@kernel
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
RFC PATCH 1/1 Ext4: Use get_cpu()/put_cpu() in preemptible context
Fix the warning of:
printk: 369 messages suppressed.
BUG: using smp_processor_id() in preemptible [00000001] code: fsx-linux/31702 caller is ext4_mb_new_blocks+0x2aa/0x1319
--- fs/ext4/mballoc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/mballoc.c +2 -1
@@ -4006,7 +4006,8 @@ static void ext4_mb_group_or_file(structreturn ;BUG_ON (ac->ac_lg !=NULL ); - ac->ac_lg = &sbi->s_locality_groups[smp_processor_id ()]; + ac->ac_lg = &sbi->s_locality_groups[get_cpu ()]; +put_cpu ();/* we're going to use group allocation */ ac->ac_flags |=EXT4_MB_HINT_GROUP_ALLOC ;
Quoted 5 lines · Mingming Cao
Index:
linux-2.6.24-rc1/fs/ext4/mballoc.c
===================================================================
fs/ext4/mballoc.c static void ext4_mb_group_or_file(struct · line 4013
Quoted 9 lines
fs/ext4/mballoc.c +2
-1@@ -4006,7 +4006,8 @@ static void ext4_mb_group_or_file(structreturn ;BUG_ON (ac->ac_lg !=NULL ); - ac->ac_lg = &sbi->s_locality_groups[smp_processor_id ()]; + ac->ac_lg = &sbi->s_locality_groups[get_cpu ()]; +put_cpu ();/* we're going to use group allocation */ ac->ac_flags |=EXT4_MB_HINT_GROUP_ALLOC ;
Shouldn't the put_cpu() be after ac->ac_lg is no longer being used? I guess there would otherwise be a danger of other processes using the same s_locality_groups[] struct?
Cheers, Andreas
--
Andreas Dilger
Sr. Software Engineer, Lustre Group
Sun Microsystems of Canada, Inc.
Quoted 13 lines · Andreas Dilger
Quoted 12 lines · Mingming Cao
Index:
linux-2.6.24-rc1/fs/ext4/mballoc.c
===================================================================fs/ext4/mballoc.c +2
-1@@ -4006,7 +4006,8 @@ static void ext4_mb_group_or_file(structreturn ;BUG_ON (ac->ac_lg !=NULL ); - ac->ac_lg = &sbi->s_locality_groups[smp_processor_id ()]; + ac->ac_lg = &sbi->s_locality_groups[get_cpu ()]; +put_cpu ();
Quoted 8 lines
fs/ext4/mballoc.c static void ext4_mb_group_or_file(struct · line 4013
Quoted 2 lines
fs/ext4/mballoc.c +0
-0/* we're going to use group allocation */ ac->ac_flags |=EXT4_MB_HINT_GROUP_ALLOC ;Shouldn't the
put_cpu()be afterac->ac_lgis no longer being used? I guess there would otherwise be a danger of other processes using the same s_locality_groups[] struct?From the code, the concurrent use of the same
s_locality_groupsis being
protected by the ac_lg->lg_sem. The put_cpu() instruction is before the lock is taken.
Mingming