From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795930705; b=0N85mDen61CiPeoK3ThIn/bgagXG5vSEh4xhq1BbDbVKy/Na9NmmnvaCjfvK2unVW7f3 VfijgqG83xtSt+b2d7C6Oa4uHn6Nbm5USTwZKkVIm0IrTXtWOWEjW8eL/8Hpo/rnODQJA Ry9KPRDBrc8fSg3jivVFb6c7MfuwQsltvYZq57KWlivyTYBvaH3SMeAs4hMEv2eYnJ6k6 JGhd8Eln5jDwjTwXIoAiCS7EdkFMfjELx7wLAOUCKI973V9C7tHfBPALhPtkAVVuAZFv9 vBxpcolc5XZ4uGtUba0Ct/dS8QlNcBqZledPQsExT7+tvQ7jFFevOmvdbN8S93MI0nQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795930705; 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=iadiBopbcZcrMGNvcTE1KadHrsUVzcpYulqpZKqw3XYsbghVKfiRs6woPHo760HTs7vU 0OVnOAVtFPYpgcV04sRv7fXXbEbdwNL7mxnd/JT3r2N0wcBspYx4zB+YU4/8hFOZqY9nM IIMlLO8/BrxsnwxhwU6c1qkPa+OQF6jFwrPlBXn43efPLdUq85VQwauGisF9CVGoGAXsN fZfWnfHmKDae9/GdlDk/tyF2/EdtC2FC0841iNOKyEo41qHE5ZLv3TTxS6SRbNAuBkDWm RX7bf2ZZKm5FVrfRMxwcbvDc3JqZXIGGjZNuZZdWvnWdlr1DQ7uok1pMap55cGa7XSA== 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.51 Received: from mail-yx1-f51.google.com (mail-yx1-f51.google.com [74.125.224.51]) (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 639B5606A324 for ; Sun, 29 Nov 2026 05:38:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 639B5606A324 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) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=BRoI8kx7 Received: by mail-yx1-f51.google.com with SMTP id 956f58d0204a3-67da62357acso12177996d50.0 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=GoufcyZk9+Uo7UjCf/v/iAeEM66Q8qztOrKhw46N9U1ha/monuTD1zklmhtSxnWYrd chqx6kUQyIt4Qpy147eFwAmiaN5I14UihW8b2soIBCduzUgh7Ci+6SPs6k9NvZlSkFlG Pz/OsHLhbqYeravY/Yfx7USzUxuZaSsJ0PS4/OQ1uyYnBsVrCUkEYDcC60Vl1kjKVRP+ AO1xSsVwAd8Xd7bq1Yt3PaIVsVlXBL7XX2H8zDBWGmq0ll2y5p2gVf0vbn1VwEA/roDN G9vjvhvmRSgtUOztoWxdQrRC56A1EpsD2cbiLobHcDyJ3ptqKuCwtXu5Rklkyfo5Hw7l Vr6g== X-Forwarded-Encrypted: i=1; AL+hErEZ7w8mHXtsvNsWfCq77GV6m6zx3JKTWI9lxx1X0wZeqq1UhYIvi/yQRzqa260OE1eYkAI=@vger.kernel.org X-Gm-Message-State: APuU4Z+ciq1ZbVIX2xdCsTvWRfp5zQfYy8Pr4+t0rS32G0iwBTjsLWQr iRTKiEJ1eAfu92jk4NrLEJQ+g4WJ5TWDTrumi2FawpPfFfDxZwCn424rYOSJwRo4TiA= X-Gm-Gg: AZFdTZfngf7d3ylPWC/y4U6RDNsmL1ITd8LcD32gUPGnv/mfDUQyPRyy76pG74gAhU8 peKAW2HzRTa/0LbJfOS22l7zVmyHb+5q9TkEk80SEUJc/J4AsHwXROKYP6SAK6CXu+A4RJME7bG MDcOipw874dgZGgiBeq/iog6+KvbytewFpiRCb1SzKHTzrfybrKu6Hj6+JxsKIPvjcX7TwsZHXf biExBNU1y2ppFd4VYS82YW65PEXYLYithA62ky618+nxdp9Uznor5Gm9SfGhnQTeU3T3GoPMret JTL/5nsvf8CpmzNOpq4SBVsrvtwBBrfiz6j8oKgQUfKF7CY89TzSBLFINb4dHytUbtmNIRmWkzX DaUTx/B/1Lnh98dpXXWcTkEE+Q2SHNYfzWUgwLKuDakCitgJWDb1bhzYUT0FJYMCn74+du0UzE3 jYXPETt/JLp5iLZbL64kSOMW0io+GGVvnmgz0M9a+d5FhktK0TA5gDL9WEK/DnErmbe+1G3IRlt W9ofUROQTdB6ZKDXmBcUhpoH9wgla2MlCmHW8FuD39WEJGBg0qbTYZpJp959e92qTZ94Ki/eHbZ TyAbR+ijC9ZChEcICARFUHan/w7KDd8NLEfapJnAEsnqtch2qcNrAb+vZ8EFhaQYDVf1wYW4lp4 HyZnfhzzsKUvcdD4Ui9BZKUl7fx+qIRenFXlLEXRo+Tab/Q9CYUagtKegHi+uH51Zh40GIQkhzs FSVtbfaEhW3rVF7VC0HnfZ4BzCbE0zTxgsOZLYMvet4kQTlIC+7FjOrswI3PY7SAFvn/S4iUW4Y npsN1lQBS6a2mqrSXhm0vpLo4s/EqJBnLRDcmQ6P7KI 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: bpf@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