From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796010500; b=ftaZe4xNQaBtiOB1gEPqI1TBnQ+MBSDt1n+xFMNTVGMHZZQATXm2k6HIFfw0qhST7aZr fibyBX6E6DB6WQbPqri0KUXIDyouV1U4FSr4hj28rfotdKD/3AXCGpGeeM4QDHGBxt1Wy PK9pTWdJfOPIwbSs0my6++utwojEMKJarfmNIlZdhnOkpxLg5cPzFniGhNlYzdVJESnKj 7atxbj+rMdN8HUU7OBrPht0ypoL54gG3bHJ/QfEs0q0sJW0Kc4vr1Y5dbp/tvftehL8fT hO+3KQ6ZbJerQVGI7CmifYKdVonAg36VGHWR4xxry/UI1osmC6zq/I8tri1nKPWpMlQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796010500; 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=LHVw51i2WE5jXW+U5dt960l/MiJtxpVtsnQjUtE+9ag=; b=mJZdNHpPxhvdsH5Og55dj8r9M80v5Gj9iCDnmDto96elyWab8GbfE5gPwAep+h0jK4Nc IjNzZXMMh1ifMOfExLf9TXKQ+AsA3kTqguWDIF4nXGvNsujse90VYo0V2hKsM6+D7Q0TV Akqq0wVPFx6w2hH31uMixn1GiM0lrlR1TeZOco9ZokbgbAhVNJKsetF2+DoOxVarKz6n9 neDUS0Dh8q7HhAJEcwEILHghY+admipSWnVtqCoNkwa2T6smwFkbU81nOBT518Su7cqem iuDdeNnuGo05G8F/lXOM+wpk/VeqApK/7cIthzEOuIl2WO6zSFhDDLN9BWfKH30nwCg== 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=jIOC346a; arc=none smtp.remote-ip=209.85.128.182 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) (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 72348606A329 for ; Mon, 30 Nov 2026 03:48:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 72348606A329 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=jIOC346a Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-8b4d07494b0so103956527b3.0 for ; Sun, 29 Nov 2026 19:48:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1796010499; x=1796615299; 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=LHVw51i2WE5jXW+U5dt960l/MiJtxpVtsnQjUtE+9ag=; b=jIOC346amwdeyxRq+cCBH4nHeHooJ3tPyW2MT4TotsNN3fsGwZLxr95xpo/x6TeljG eP8YwofTm5dZFso2LHDcFi6P4wve3gOIjkmxawuNfBAQ6tNAAN5CfJu/TftmKqEveKcS q9emYQIm3kUc2i0rM7Mb44Y+jhsAWNQ7o+lOI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796010499; x=1796615299; 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=LHVw51i2WE5jXW+U5dt960l/MiJtxpVtsnQjUtE+9ag=; b=1JRzJiFwWJorZdkwgrwKfHtm8rlFJS8DVMoeqMKrujzVt4anwYOQPv+jHTzyaVCLDA vpuBB8aw4f88kUbq+6e1zXv9CXkBAdF1uJW9XKBk0mTY8ZZPQd3Hvr3uRaYAbJ/tpY5M FFLFrTEvWhSRDATmNoTkEVkr/WvBW8TG3OJHmy1is+Jih+j6J2VJKJmlbdMRCb8Xy1C8 eRK/6VB8WpDRezRh3iLHfC+EG+OtnvDBtI6L8c3zMWCn5kg5Iy1Y98p11u7yf8GZ7ias 0JMcDuDizx2+p9jr7VwCA4G5GGh3IbTivysGEhCEFtSvjWr/9t6ytb0bWXkh4hv0ScLN Jf+Q== X-Forwarded-Encrypted: i=1; AL+hErEfb1Kv+KotbpElpfBzToU3hcVT3/xHu/+DEOrrQwJNo5h6z8TMnNqluHse2HnT4GbXfZkh2aMx@vger.kernel.org X-Gm-Message-State: APuU4Z9dqWGt7nEyyvDsQN0ohh8zulNXHdiiqgBZ1R3PN0k9RwtHdo4h vj1zjHJAKItIPsNdMGlOvp/OdnAopCY9WKGlZzyQrL0bih19bVvygRbf54AMNnSiM64= X-Gm-Gg: AZFdTZeb1JyIgB9fQJhuMcNXiX9oSbtpJJZoRqmIxS4fGJ+Pb6KRCMSw4H0YVHU0DKy iXfADD7yPUvO1eZbszYsR2ZqArw8h2AMyDwmAfHMOF0PIzhujz3IbP5GTTAFxQSi0XFayiv257z Z/P/p6Z2QmYZ/rCdRotEVwVbNplXlQqzNiW8ureM/7RL20z4famPJkJzl82o2XpprN1ubX5VSGn gP2jc5c25Sd0MJTf5UFmieYYczGJYOT/WwxFV38IxK6SXhqoV0dKiTwcjZMO1zqXmd9CN2avcDX dtnTGmELWzVFbo1hkWWt1atX7I40sF5WElqxciWu318lRW/WMULzq+sPRAG485gO/8Rz43n8HXD I7ZSD8NyuXtTr4YLW9WhNpowDf0xTK1y+vrz4cQ/nSINnRX+aHodbb4QyuAe7bJoI+5SwoBjrUN YpqX1hy81eqvuAMeRqADFvaDTqSf1PaD8eraO8Ul8uMeZHpDrqqw2CQqR7zgWw/xfgagIQhIy0k xNxTY4hxPbRQOH1rlHA16dt4BRURyfq52/GPdMtmsiWiilWMEJ+UqOGqkwvG9XOE8D45kcPTtZ1 +4S4PfiCF2g3uDEGdV0m477Uoia/rGPOGyMbRzFCHQWm0TK2RhitPzzgOFYkBWsyDlfllYfHAeI 22ax06vwtKttEp+RO8/eDUkYDd6tQSpZX3aQHEwNbGG/jbIkwvhR7de7SM3bLiyqsl8Vl7jFc9B eFNavjMZLDTogfLtPwaUMnPVMTr5qvqmeg5iE7y9TFio4Ma4xvEOs8muIh7kNKnhgtx1rp2YEdM 4TdGFpkrs5m2HwvvVah9YA= X-Received: by 2002:a05:690c:3603:b0:8b4:dd8c:8549 with SMTP id 00721157ae682-8b5204ebdccmr100138607b3.28.1796010499402; Sun, 29 Nov 2026 19:48:19 -0800 (PST) Received: from [172.20.0.3] (c-73-207-185-9.hsd1.ga.comcast.net. [73.207.185.9]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b52030df7bsm126908427b3.31.2026.11.29.19.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 19:48:17 -0800 (PST) Date: Sun, 29 Nov 2026 19:48:15 -0800 Message-ID: From: Chris Down Subject: [PATCH v3 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, sashiko-bot@kernel.org X-Mailing-List: cgroups@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, with "..." in front of it. 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, 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