From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796010500; b=qfM5KPO22f5Ol16r4Ze6Hbo8NZCtsEGT4K86466CPe/nocRwxX2opFEEL+vIwYLfZW3h aSp7q4/Op02UIgM6XwyaoFbaLQEfwIlPwSp3wLutW3fSpe8JnM7gpCL9o/FhKT6XAm7rP 5qKxS72DQs/JfRikbvTf3PyKiwxugEx/A6LMLyJbIAy1VNOKHsYFaAucjn7RimC2hYHPp BbyNU+v3FPMQagfYBrjXYziFLSl9Ys55Fa+vMtousgNQnDDNkvrztQLmQFUEi+pXtnQbp SHcRbcc+yrOy/+i7odYJ7uU7MoBIL4AtBVlf4EC1BUKOCoocgwh79m7PrpTJVRFwzWA== 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=EYXpx69YuCEbMQ+jSkDCmYd/E6aFux78kBcAGCwjvMOEQGiQuVvtEIr+VBglCZu3GxY1 r59+TpBavfsSpKDlfJiZKlHXhar1dF59UvEJz2Sx76Dzs4/2rfAJiCuKQImqxH1PQu3AZ 845jGq10PgNQMACLyN5tZjwcFXU7BbugP0J2ZXjHsl2izZsxU6hC6Fuyln24Ny2VAhEby QkNUIP5nsuYXzVYHzv8uNtg9ty9PWiNS8mjbG7+gfW1AmpH1hmhjaY7o/7hNGERQC8yjX o/DzpWjrmu4kf2nIk0rsPgSeVTv7IYJFSZq05gwAqOnc0yTYrucBjGPNxMnlnBbFVcg== 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.181 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 67534606A327 for ; Mon, 30 Nov 2026 03:48:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 67534606A327 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-f181.google.com with SMTP id 00721157ae682-8b4d07494b0so103956557b3.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=Fd7IVHssRSGqRgUtMYU7h5uytv+qwrU04qi6QdYbWvXMbHlPyn24L2x+DgRKnpFr3I zBKeihpJhvTU6Zb4S2cOa/W1/y8X6QNoN+4zNUfUqzS6Gj/sEVYrUzUqaxswKaOvThuw dxIs5w3tr9nXGp06mUNuZw3fhiO7QdVIEjjzkkJvTdJopwRMeNOc/BIgIuoHYKV2iail XwwBcbrXW8D5xYS971Wb2ZKewgbWX995WDdBArPxPHgRN11r4qvniRknLFMJo3EDPFBL vhN57iNUccdH3W0n8V+puprPnv5mKl8F8EFpEvbux57foJmMDQ/gnIc1EujHLiOKHZPj JUOQ== X-Forwarded-Encrypted: i=1; AL+hErH8/PFwWWgGDth9M/wGnn8J9eKdw0W0EfeVt3CQ/X+HPPAGbxSX0e+Q6QEc2glOqRxuAW88OqG2tpduMMg=@vger.kernel.org X-Gm-Message-State: APuU4Z+sz/gJxdKyxJsr8jipzoXwvexKL1Wxnq1V5eo0D5fIhlkRL++3 hQwakOx+sG+/aAwvlx8XXA5IW9G8/HvxaPsa80CzExizfMc3E/3u+8tpICMZyVb4Kwo= X-Gm-Gg: AZFdTZfdAqVeR281X3/7D/FqYL3sk85lyWE9Ba1hp4ljLS/h1+F5ptTPy/RoWraIiOw XbGSUUhNIdIdS6orlTfl3sFmLckfXynQcLRUFtEnUyQi7OHE5NVu8yhQQ1VI+aCWxQzCWZt58xH 37DLm0vDEUBZMRl61bzfX4jkwAfxDZ14Y+IR/pby7iYMLu6mJmGFIA28hciT+I+cjLgdDby8tVO 4lFUrqUEVnI2paAuGntjqsUzHfHNRuvMCy8ef0XpV/subcIfABNpGRQLJ11qU7tMPDl9vfrFSYz +uDWiB6RypcmlTzFYthUhS2+NDog4t+7kNAhL9s1p1T0I7jrW46g56GOwr/dCDethgiQY0UtVXd BhlXBcNT2UPzDqW7i6rhodrXeKJ0mzmUpKCbAoGC+aRKJDaOQqL7HNXOCx4rSkBqw524buWdj/A HFAlfquLf3wAT5H9iG+fZq0Ny9Nen7z3VhJuim3vldI8k+c2NhL+1xoguBgxMxB1pKSbex6BQLj kIWNdKTBQ9OQZsUEXPcrZmTj4Mj9EGtFu4odOFLwV0zrXK6+ijaq4ZvyfIgbBzJ13wrQVW/JQYj 4FryvtH3X0wvoUdZid4DPyx2OQxTrr7oeqhIn2mKa4yO59OZho+yEx0IPFo+o7kXWc1FrgrxJEK MRgmmJvBQE6arNIpuoDbOZuQof66EDw7elS6laZPgPCPsRbCRlRRVhYPMqXXpa0n/xPKH00dDRW xroydetjhUsAvr4gZRH8nQ3FEMneKatJ4neyf2M8DCcVTfCEa1KIUpO7uU+XUKberKKtJjb3tDY gsxvAH7BBu7YEq0+czzM24= 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: 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, 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