Skip to contentSkip to conversation

mm/init-mm.c: use CPU_BITS_NONE to initialize .cpu_bitmap

PATCH In review Rasmus Villemoes 2 participants 2 messages Aug 22, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/init-mm.c: use CPU_BITS_NONE to initialize .cpu_bitmap

init_mm is sizeof(long) larger than it needs to be. Use the CPU_BITS_NONE macro meant for this, which will initialize just the indices 0...(BITS_TO_LONGS(NR_CPUS)-1) and hence make the array size actually BITS_TO_LONGS(NR_CPUS).

---
 mm/init-mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/init-mm.c +1 -1
index a787a319211e..fb1e15028ef0 100644
@@ -35,6 +35,6 @@ struct mm_struct init_mm = {
 	.arg_lock	=  __SPIN_LOCK_UNLOCKED(init_mm.arg_lock),
 	.mmlist		= LIST_HEAD_INIT(init_mm.mmlist),
 	.user_ns	= &init_user_ns,
-	.cpu_bitmap	= { [BITS_TO_LONGS(NR_CPUS)] = 0},
+	.cpu_bitmap	= CPU_BITS_NONE,
 	INIT_MM_CONTEXT(init_mm)
 };
Signature · 1 line
2.20.1
#1 lore raw

Hi,

Quoted 4 lines · Rasmus Villemoes

init_mm is sizeof(long) larger than it needs to be. Use the CPU_BITS_NONE macro meant for this, which will initialize just the indices 0...(BITS_TO_LONGS(NR_CPUS)-1) and hence make the array size actually BITS_TO_LONGS(NR_CPUS).

I've sent a similar patch [1] a week or so ago, it's in -mm tree.

[1] https://lore.kernel.org/linux-mm/[email protected]/

Quoted 21 lines
---
 mm/init-mm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/init-mm.c +1 -1
index a787a319211e..fb1e15028ef0 100644
@@ -35,6 +35,6 @@ struct mm_struct init_mm = {
 	.arg_lock	=  __SPIN_LOCK_UNLOCKED(init_mm.arg_lock),
 	.mmlist		= LIST_HEAD_INIT(init_mm.mmlist),
 	.user_ns	= &init_user_ns,
-	.cpu_bitmap	= { [BITS_TO_LONGS(NR_CPUS)] = 0},
+	.cpu_bitmap	= CPU_BITS_NONE,
 	INIT_MM_CONTEXT(init_mm)
 };
Signature · 1 line
2.20.1
Signature · 2 lines
Sincerely yours,
Mike.