Add NumaB_mode to /proc//status so users can inspect the configured process automatic NUMA balancing mode without issuing a prctl() from the target process. The field reports the process mode as enabled or disabled when automatic NUMA balancing is supported, and unsupported when the kernel is built without CONFIG_NUMA_BALANCING. Effective behavior still depends on the global numa_balancing sysctl and memory policy. Signed-off-by: Li Zhe --- fs/proc/array.c | 16 ++++++++++++++++ include/linux/sched/numa_balancing.h | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/fs/proc/array.c b/fs/proc/array.c index f6f75d206762..a27a6a57e8b2 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -425,6 +425,21 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm) seq_printf(m, "THP_enabled:\t%d\n", thp_enabled); } +#ifdef CONFIG_NUMA_BALANCING +static inline void task_numa_balancing_status(struct seq_file *m, + struct task_struct *task) +{ + seq_printf(m, "NumaB_mode:\t%s\n", + task_numa_balancing_mode_name(task)); +} +#else +static inline void task_numa_balancing_status(struct seq_file *m, + struct task_struct *task) +{ + seq_puts(m, "NumaB_mode:\tunsupported\n"); +} +#endif + static inline void task_untag_mask(struct seq_file *m, struct mm_struct *mm) { seq_printf(m, "untag_mask:\t%#lx\n", mm_untag_mask(mm)); @@ -453,6 +468,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, task_untag_mask(m, mm); mmput(mm); } + task_numa_balancing_status(m, task); task_sig(m, task); task_cap(m, task); task_seccomp(m, task); diff --git a/include/linux/sched/numa_balancing.h b/include/linux/sched/numa_balancing.h index bc413aae5915..69e79359fa22 100644 --- a/include/linux/sched/numa_balancing.h +++ b/include/linux/sched/numa_balancing.h @@ -47,6 +47,11 @@ static inline int task_numa_balancing_get_current(void) { return task_numa_process_mode_enabled(current); } + +static inline const char *task_numa_balancing_mode_name(struct task_struct *p) +{ + return task_numa_process_mode_enabled(p) ? "enabled" : "disabled"; +} bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, int src_nid, int dst_cpu); #else -- 2.20.1