Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: rename cpu_bitmap field to flexible_array

The cpu_bitmap flexible array now contains more than just the cpu_bitmap.
In preparation for changing the static mm_struct definitions to cover for
the additional space required, change the cpu_bitmap type from "unsigned
long" to "char", require an unsigned long alignment of the flexible array,
and rename the field from "cpu_bitmap" to "flexible_array".

Introduce the MM_STRUCT_FLEXIBLE_ARRAY_INIT macro to statically initialize
the flexible array. This covers the init_mm and efi_mm static
definitions.

This is a preparation step for fixing the missing mm_cid size for static
mm_struct definitions.

Link: https://lkml.kernel.org/r/20251224173358.647691-3-mathieu.desnoyers@efficios.com
Fixes: af7f588d8f73 ("sched: Introduce per-memory-map concurrency ID")
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Reviewed-by: Thomas Gleixner <tglx@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Aboorva Devarajan <aboorvad@linux.ibm.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Christan König <christian.koenig@amd.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Dennis Zhou <dennis@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: "Liam R . Howlett" <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Martin Liu <liumartin@google.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: SeongJae Park <sj@kernel.org>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Mathieu Desnoyers and committed by
Andrew Morton
6ac433f8 12a6ddfc

+11 -6
+1 -1
drivers/firmware/efi/efi.c
··· 74 74 .page_table_lock = __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock), 75 75 .mmlist = LIST_HEAD_INIT(efi_mm.mmlist), 76 76 .user_ns = &init_user_ns, 77 - .cpu_bitmap = { [BITS_TO_LONGS(NR_CPUS)] = 0}, 78 77 #ifdef CONFIG_SCHED_MM_CID 79 78 .mm_cid.lock = __RAW_SPIN_LOCK_UNLOCKED(efi_mm.mm_cid.lock), 80 79 #endif 80 + .flexible_array = MM_STRUCT_FLEXIBLE_ARRAY_INIT, 81 81 }; 82 82 83 83 struct workqueue_struct *efi_rts_wq;
+9 -4
include/linux/mm_types.h
··· 1329 1329 * The mm_cpumask needs to be at the end of mm_struct, because it 1330 1330 * is dynamically sized based on nr_cpu_ids. 1331 1331 */ 1332 - unsigned long cpu_bitmap[]; 1332 + char flexible_array[] __aligned(__alignof__(unsigned long)); 1333 1333 }; 1334 1334 1335 1335 /* Copy value to the first system word of mm flags, non-atomically. */ ··· 1366 1366 MT_FLAGS_USE_RCU) 1367 1367 extern struct mm_struct init_mm; 1368 1368 1369 + #define MM_STRUCT_FLEXIBLE_ARRAY_INIT \ 1370 + { \ 1371 + [0 ... sizeof(cpumask_t)-1] = 0 \ 1372 + } 1373 + 1369 1374 /* Pointer magic because the dynamic array size confuses some compilers. */ 1370 1375 static inline void mm_init_cpumask(struct mm_struct *mm) 1371 1376 { 1372 1377 unsigned long cpu_bitmap = (unsigned long)mm; 1373 1378 1374 - cpu_bitmap += offsetof(struct mm_struct, cpu_bitmap); 1379 + cpu_bitmap += offsetof(struct mm_struct, flexible_array); 1375 1380 cpumask_clear((struct cpumask *)cpu_bitmap); 1376 1381 } 1377 1382 1378 1383 /* Future-safe accessor for struct mm_struct's cpu_vm_mask. */ 1379 1384 static inline cpumask_t *mm_cpumask(struct mm_struct *mm) 1380 1385 { 1381 - return (struct cpumask *)&mm->cpu_bitmap; 1386 + return (struct cpumask *)&mm->flexible_array; 1382 1387 } 1383 1388 1384 1389 #ifdef CONFIG_LRU_GEN ··· 1474 1469 { 1475 1470 unsigned long bitmap = (unsigned long)mm; 1476 1471 1477 - bitmap += offsetof(struct mm_struct, cpu_bitmap); 1472 + bitmap += offsetof(struct mm_struct, flexible_array); 1478 1473 /* Skip cpu_bitmap */ 1479 1474 bitmap += cpumask_size(); 1480 1475 return (struct cpumask *)bitmap;
+1 -1
mm/init-mm.c
··· 47 47 #ifdef CONFIG_SCHED_MM_CID 48 48 .mm_cid.lock = __RAW_SPIN_LOCK_UNLOCKED(init_mm.mm_cid.lock), 49 49 #endif 50 - .cpu_bitmap = CPU_BITS_NONE, 50 + .flexible_array = MM_STRUCT_FLEXIBLE_ARRAY_INIT, 51 51 INIT_MM_CONTEXT(init_mm) 52 52 }; 53 53