From: Chris Down <chris@chrisdown.name>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Tejun Heo <tj@kernel.org>
Cc: "Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Serge Hallyn" <serge.hallyn@ubuntu.com>,
"Ingo Molnar" <mingo@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"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>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
driver-core@lists.linux.dev, cgroups@vger.kernel.org,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com, sashiko-bot@kernel.org
Subject: [PATCH v3 0/3] kernfs: Build paths in linear time with respect to depth
Date: Sun, 29 Nov 2026 19:48:15 -0800 [thread overview]
Message-ID: <cover.1796009856.git.chris@chrisdown.name> (raw)
kernfs_path_from_node() walks back up from the leaf for each name in the
path, so the work grows with the square of the depth, and reading
/proc/<pid>/cgroup does that with IRQs off and css_set_lock held.
Patch 1 builds the path in a single walk instead. As Tejun suggested on
v1, a path which doesn't fit now returns -E2BIG and keeps its end rather
than its start, with "..." in front of it. Reads of /proc/<pid>/cgroup,
and of /proc/<pid>/mountinfo with a cgroup mount rooted at such a path,
fail again as they did before v6.8, when the name loop stopped reporting
truncation. Patches 2 and 3 update sched/debug, which added its own
"..." at the end, and cgroup_iter, which assumed that nothing would be
left in the buffer.
Patches 2 and 3 depend on patch 1. Patch 2 will conflict with tip's
sched/core, where acf8d1424c1a ("sched/fair: Use
list_for_each_entry_rcu() in print_cfs_stats()") moves
SEQ_printf_task_group_path() to kernel/sched/sched.h. The resolution is
to make the same change to the macro there, since otherwise the path
gets "..." at both ends.
v3:
- Put "..." at the start of a path which doesn't fit in
kernfs_path_from_node() itself, so sched/debug only drops its suffix
(Tejun)
- Have pr_cont_kernfs_path() print what's in the buffer when the path
doesn't fit, instead of "(name too long)" (Tejun)
- Put the opening /* of the comment in cgroup_iter on a line of its own
(Sashiko)
v2:
- Keep the end of the path and return -E2BIG when it doesn't fit,
instead of wrapping around the buffer to keep the start (Tejun)
- Say which reads now fail when the path doesn't fit
- Stop walking as soon as the buffer is full
- Update the kernel-doc for the kernfs_path*() functions to match
- Add patches to move sched/debug's "..." to the start of a truncated
path, and to update the comment in cgroup_iter's fdinfo
- Add numbers for more realistic depths, and for the effect on fork and
exit on other CPUs (Tejun)
- Say that it's up to the parent to set cgroup.max.depth when delegating
a subtree (Tejun)
- Drop Fixes: and Cc: stable, since this now changes behaviour as well as
speed
- Rebase onto driver-core-next
v2: https://lore.kernel.org/r/cover.1795930577.git.chris@chrisdown.name
v1: https://lore.kernel.org/r/au_pnu4s141ylqHD@chrisdown.name
Chris Down (3):
kernfs: Build paths in linear time with respect to depth
sched/debug: Drop the "..." suffix from truncated group paths
bpf: Describe cgroup_iter's fdinfo path for paths which don't fit
fs/kernfs/dir.c | 83 +++++++++++++++++++++++++---------------
include/linux/kernfs.h | 7 ++--
kernel/bpf/cgroup_iter.c | 6 ++-
kernel/sched/debug.c | 8 +---
4 files changed, 63 insertions(+), 41 deletions(-)
base-commit: f62fba71a846ebe59423bfd057af023b418935a0
--
2.56.1
next reply other threads:[~2026-11-30 3:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 3:48 Chris Down [this message]
2026-11-30 3:48 ` [PATCH v3 1/3] kernfs: Build paths in linear time with respect to depth Chris Down
2026-11-30 3:48 ` [PATCH v3 2/3] sched/debug: Drop the "..." suffix from truncated group paths Chris Down
2026-11-30 7:58 ` Peter Zijlstra
2026-11-30 15:40 ` Chris Down
2026-11-30 3:48 ` [PATCH v3 3/3] bpf: Describe cgroup_iter's fdinfo path for paths which don't fit Chris Down
2026-11-30 4:45 ` [PATCH v3 0/3] kernfs: Build paths in linear time with respect to depth Tejun Heo
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=cover.1796009856.git.chris@chrisdown.name \
--to=chris@chrisdown.name \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dietmar.eggemann@arm.com \
--cc=driver-core@lists.linux.dev \
--cc=eddyz87@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=kernel-team@meta.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=memxor@gmail.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sashiko-bot@kernel.org \
--cc=serge.hallyn@ubuntu.com \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yonghong.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.