From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795930704; b=rHxe9VMkA/3SYm13lunAo7sH2I8Sfw/I8szCRP1Tf49dgt1M1O6x9vSrhGZBAEuM3sVC DsaXHRmVDIPP00V4A+xnPHC9XXWdtFFZoYOYKyr3nl5WaVZ/7jHfvX7RMKHv6asTBhekU NV0/XbZUnZxdziZW89FsJpCHcn92+6Ws5vnkisIIG/GJwBBgrBz31DBT745cnswBT3plj T/FfQaS4BVAdF54uqVaUq6vIeqa3zZN0SAOZRbEhmc5CT1lxwEwEOSXDtpFq5/szxLle0 0KC/YEH9OqjhgI83Kp2FWoZfhMYGI+od6E0ieCt9lAt78WJjpx+CzU95FlH1boeF6+A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795930704; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:Message-ID:From:Subject:To:Cc:MIME-Version:Content-Type: Content-Disposition:User-Agent; bh=9FttyNcYSVGzmj6T4rCZmInrhX5l+Xx6kfi60R/YjQg=; b=ql5paj1nxym6A3s8nhQVuzgZX+PNTeWpRdFZFFO2cWm18PhqI8R5OO0VUmKjhuVHiAJ7 SyroR7bwL77+0gMQPlep9SdZ+qUEdAbxZHjL8f5IOc0OYqeDJqznsm2HDffzQ5DLDZroD UP5tjRA1TAkcko0Y+0qPVT9fUWT3CkogWHbcVSmhtqrB6iQnVp7vBNzOPGlmn/gnAJJmC pDPszYL6IaKRQKVBmyQJRgz/z0ByFAw+dMP0YGCcvbQpKxJEfXXnGNVJlAIwvTmewCTMj 9EqmriF9G8d+lDj5DfU5C9BuzOsUHCAO7GltOefM4X/XwXybJU4SDEFngLObfim6QIQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chrisdown.name; spf=pass smtp.mailfrom=chrisdown.name; dkim=pass header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=BRoI8kx7; arc=none smtp.remote-ip=74.125.224.48 Received: from mail-yx1-f48.google.com (mail-yx1-f48.google.com [74.125.224.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60584606A323 for ; Sun, 29 Nov 2026 05:38:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 60584606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=BRoI8kx7 Received: by mail-yx1-f48.google.com with SMTP id 956f58d0204a3-67c24619b19so8030281d50.2 for ; Sat, 28 Nov 2026 21:38:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1795930703; x=1796535503; darn=vger.kernel.org; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:message-id:date:from:to:cc:subject:date:message-id :reply-to:content-type; bh=9FttyNcYSVGzmj6T4rCZmInrhX5l+Xx6kfi60R/YjQg=; b=BRoI8kx77Lje6oujHU8+iDtqGQcJ9jZniMvT069JYqb53LmlJtH2b/stn2+6xcRbXj jxtSqsfIeRiFFMK/Tx8gkQZqUtOld/JyXEnJQyS3c+t1egs1o/HbXsufc1UFp67WnZVS 3v9jzusJZbxuzM78E2hT9XOt4ih9BqLl31HVo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795930703; x=1796535503; h=user-agent:content-disposition:content-type:mime-version:cc:to :subject:from:message-id:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=9FttyNcYSVGzmj6T4rCZmInrhX5l+Xx6kfi60R/YjQg=; b=NjETndKITJsAoTbd8JlqhyOaFOU8WQZf5X5KcgOZUxvSAUaDwaCbg9O8xCpCHw5GyP 4g4IH2C9AsR4yGpXcju851DfMsGDLA+o6PBP7loJcEZ2ck0t7ZktaDWadpUTSR2fK7ag 8dcS1ef95BQClpfbr5Qcy4QyEoVoAE+wdDCskf6LgjuUE8FkQm64GNkPwqdlkINBUJjP XrPqhgRWK2HVnzecTGqRTmJcMhcdHYCX1TYehh+jlwNsDh1ysyB/+Xnb/PhqyUia698K u3/+MmumKo6JxE7Hu4VigOAphO7q4JzYNMq7f9LTnORTVbLA/61mwtr1qGluIzEPX1OT b2IA== X-Forwarded-Encrypted: i=1; AL+hErENJX3SdKpad5FbwSVIRLf3lpyQX4CHd8hHD6lqJDtEPNh64X19TU0eKLWDExIUg+DxqSt3GrmGAzSs5d8=@vger.kernel.org X-Gm-Message-State: APuU4Z+P9RNp49i3f+3Q+psss9b8snP+XqWYPxnyprrdZBfNN4NZ7y4/ 2Ba7XOQ0m+tAcwgQKbbEbfyAnCFkP4PoqKyI9fHxeCgZKE7cOzL7BJl8E6yYAVoHeQU= X-Gm-Gg: AZFdTZfZWMRITM01IztB+PgemnCrYqUMQ/0Z/pqQAKX69XMvSYwNeImqzjRwYP85SRa sCXutYJ0KyJCnZ/Vx1oJD5rFYjDnG1vxTpxpNcRCLAEX/IjyBnCf87yYDYGXj+XAJD1NNqy2W0s U1nvmLjhKRcyec2he3z0KaXq7exuY2dbg1DDL4zMW7qmfL7HVqzrIfJDo/pvL/fJ/V3V7IhVEXa DGxMdpgCOkEWdCMVbYfq++LV3P59JCrUgxx6KqRxU/pvDu1heAcR9tPAj1cgXby/Q/nEuGRXAgm PZFUPbcCvZfdqMMhEFPnID40lSAMCzUgBxyKBynpXQz92mdn4vQWRNfEU6G9BzgUk3KzJGxUasJ Ce2yBVcsRMd1bugm/tWpdyIT2oENIhpP0lOS/ONhd+Ld5wQsMy0amWzLqjwgdf7AekEz+Jnodkp oyz28J+pmaRaLy0QSAJB3LyOn/j+GXt3NTFJ7Uua348cRABw9o/c8ACKt8hn6FLV85N7VOnKidj deqxCfN3HdYAmZoC9ZG6eEqkKzFkzwYuh7HyobWDfDFx7SrjQ0f6+Nu2eEJ3ZDJz8Y1r0u+Pzlc Ig4uNeB8FjjmhIVAe4SbatYg/ab0h8JcIUR5LBna9Rhh+OQegzBmKjTDlRRKVuLwkgVaG9usxNS +U8LSOj4fPbnVORXxJdLIiqZeBibNd4bO2CaxmS8agEn4rClFsvZ3R4+26lmXZuKz76DC7tDm4g z8y+9fExFOV+Et9afGb9W4tcMSqAc2g+mntqSu6cXuXy3G3Ab85/NVERjdsbK4Ioikr4BfWwLiI myWeSqKzhWZOb8IBxSW0cgovLzbb/0Yt84FbkhMlXcO X-Received: by 2002:a05:690e:4505:10b0:67d:be72:879b with SMTP id 956f58d0204a3-67df44c230emr9163292d50.81.1795930703490; Sat, 28 Nov 2026 21:38:23 -0800 (PST) Received: from [172.20.0.2] (c-73-207-185-9.hsd1.ga.comcast.net. [73.207.185.9]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67df3353258sm13785173d50.9.2026.11.28.21.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2026 21:38:22 -0800 (PST) Date: Sat, 28 Nov 2026 21:38:19 -0800 Message-ID: From: Chris Down Subject: [PATCH v2 0/3] kernfs: Build paths in linear time with respect to depth To: Greg Kroah-Hartman , Tejun Heo Cc: Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , 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@lists.linux.dev, cgroups@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/2.4.3 (cc9e3943) (2026-10-09) 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//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//cgroup, and of /proc//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