On Mon, Jul 20, 2026 at 8:52 PM Huang Shijie <huangsj(a)hygon.cn> wrote:
This makes the "ps -g xxx" give us more information.
It is very useful when the "xxx" has many threads,
and the threads are in different NUMA nodes.
Signed-off-by: Huang Shijie <huangsj(a)hygon.cn>
---
task.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/task.c b/task.c
index d7f3c12..8d95bf4 100644
--- a/task.c
+++ b/task.c
@@ -6102,8 +6102,9 @@ task_mm(ulong task, int fill)
char *
task_cpu(int processor, char *buf, int verbose)
{
+ int nid = cpu_to_nid(processor);
if (processor < NR_CPUS)
- sprintf(buf, "%d", processor);
+ sprintf(buf, "%4d/%d", processor, nid);
Please adjust the ps output formatting:
PID PPID CPU TASK ST %MEM VSZ RSS COMM
0 0 0/0 ffffffff99411100 RU 0.0 0 0
[swapper/0]
0 0 1/0 ffff96b7c0c88000 RU 0.0 0 0
[swapper/1]
0 0 2/0 ffff96b7c0c8af40 RU 0.0 0 0
[swapper/2]
There is column alignment issue after extra data outputted as "0/0"
than "0", also header "CPU" should be extended to
"CPU/NUMA", anyway,
please make sure the output alignment be adjusted as well, and also
need to update "help ps" of related items.
Thanks,
Tao Liu
else
sprintf(buf, verbose ? "(unknown)" : "?");
--
2.53.0