All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] kernfs: Build paths in linear time with respect to depth
@ 2026-11-29  5:38 Chris Down
  2026-11-29  5:38 ` [PATCH v2 1/3] " Chris Down
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Chris Down @ 2026-11-29  5:38 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Tejun Heo
  Cc: Johannes Weiner, Michal Koutný, Serge Hallyn, Ingo Molnar,
	Peter Zijlstra, Juri Lelli, Vincent Guittot, Dietmar Eggemann,
	Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider,
	K Prateek Nayak, Yonghong Song, Alexei Starovoitov,
	Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman,
	Kumar Kartikeya Dwivedi, driver-core, cgroups, bpf, linux-kernel,
	kernel-team

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. 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 and cgroup_iter, which assumed that the start of the
path would be kept or 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.

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

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: Mark a truncated group path at the start
  bpf: Describe cgroup_iter's fdinfo path for paths which don't fit

 fs/kernfs/dir.c          | 70 ++++++++++++++++++++++++++--------------
 include/linux/kernfs.h   |  6 ++--
 kernel/bpf/cgroup_iter.c |  3 +-
 kernel/sched/debug.c     | 12 +++----
 4 files changed, 55 insertions(+), 36 deletions(-)


base-commit: f62fba71a846ebe59423bfd057af023b418935a0
-- 
2.56.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-29 16:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29  5:38 [PATCH v2 0/3] kernfs: Build paths in linear time with respect to depth Chris Down
2026-11-29  5:38 ` [PATCH v2 1/3] " Chris Down
2026-11-29  5:38 ` [PATCH v2 2/3] sched/debug: Mark a truncated group path at the start Chris Down
2026-11-29  5:38 ` [PATCH v2 3/3] bpf: Describe cgroup_iter's fdinfo path for paths which don't fit Chris Down
2026-11-29  5:43   ` sashiko-bot
2026-11-29 16:36 ` [PATCH v2 0/3] kernfs: Build paths in linear time with respect to depth Tejun Heo

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.