[PATCH 10/11] sched/numa: bound cpuset trace masks by nr_node_ids
From: Yury Norov
Date: Fri Nov 27 2026 - 18:02:23 EST
With switching nodemask API to runtime nr_node_ids, bits beyond this
boundary till MAX_NUMNODES may be in undefined state. Those bits may
show up in the raw trace record.
Keep the fixed-size trace record and use nodes_copy_and_extend() to copy
the runtime range and clear every remaining bit, including padding in
the last copied word.
Print only the runtime range.
Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
---
include/trace/events/sched.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
index 535860581f15..38a2a10cba42 100644
--- a/include/trace/events/sched.h
+++ b/include/trace/events/sched.h
@@ -793,8 +793,9 @@ TRACE_EVENT(sched_skip_cpuset_numa,
__entry->ngid = task_numa_group_id(tsk);
BUILD_BUG_ON(sizeof(nodemask_t) != \
BITS_TO_LONGS(MAX_NUMNODES) * sizeof(long));
- memcpy(__entry->mem_allowed, mem_allowed_ptr->bits,
- sizeof(__entry->mem_allowed));
+ /* Clear unused bits in the fixed-size trace field. */
+ nodes_copy_and_extend(*(nodemask_t *)__entry->mem_allowed,
+ *mem_allowed_ptr);
),
TP_printk("comm=%s pid=%d tgid=%d ngid=%d mem_nodes_allowed=%*pbl",
@@ -802,7 +803,7 @@ TRACE_EVENT(sched_skip_cpuset_numa,
__entry->pid,
__entry->tgid,
__entry->ngid,
- MAX_NUMNODES, __entry->mem_allowed)
+ nr_node_ids, __entry->mem_allowed)
);
#endif /* CONFIG_NUMA_BALANCING */
--
2.53.0