From: Maoyi Xie <maoyixie.tju@gmail.com>
To: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: sched/numa: Ngid is reported as a global pid inside a pid namespace
Date: Sat, 3 Oct 2026 03:48:33 +0800 [thread overview]
Message-ID: <20261002194833.1069966-1-maoyixie.tju@gmail.com> (raw)
Hi all,
I think Ngid in /proc/<pid>/status is not translated into the pid
namespace of the procfs instance it is read from. I would appreciate it
if you could take a look.
task_state() translates the other pids it prints (fs/proc/array.c).
ppid = task_ppid_nr_ns(p, ns);
tgid = task_tgid_nr_ns(p, ns);
ngid = task_numa_group_id(p);
task_numa_group_id() returns the gid of the task's NUMA group.
task_numa_group() sets it from p->pid when it creates the group. A task
in a group therefore shows the pid, in the initial pid namespace, of the
task that created the group.
A CodeQL check for pids printed without a namespace translation reported
sched_show_numa(), which prints the same value in /proc/<pid>/sched. I
reproduced the Ngid case on mainline 5e0f8396d480 in qemu with two NUMA
nodes and numa_balancing enabled. It needed no kernel changes. An
unprivileged workload under "unshare -Urpf --propagation private
--mount-proc" has tasks 1 to 17 in its new namespace and reads
"Ngid: 421" from /proc/self/task/<tid>/status.
I sent these three fixes for the same kind of gap this year.
keys https://git.kernel.org/linus/0d6a4268b060
io_uring https://git.kernel.org/linus/3799c2570982
netdev https://git.kernel.org/linus/1f24c0d01db2
I am not sure which fix is right. One is to keep a struct pid in the
group and print it with pid_nr_ns(). Another is to print 0 unless the
procfs instance belongs to the initial pid namespace. I tested the
second one for Ngid, but proc.rst documents 0 as no group.
Does this look worth fixing? If it does, I am happy to send a patch, or
to leave the fix to you.
Thanks,
Maoyi
reply other threads:[~2026-10-02 19:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261002194833.1069966-1-maoyixie.tju@gmail.com \
--to=maoyixie.tju@gmail.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®