From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795930704; b=zPtsQUojkZIf+mCwFw4on8bpAY5HiTuqCHL6K/KrT7EyfdWAobdGcuajutmwjQjOM348 2xYtrxn8QbQZI9XGXsADL00wZTdP3yNx3KfAmXTM6xeIRF/bKt8nvzoPljpRvHqvdHyHp A8/8EuGSsBgw6sppjwapkXwZAuYB+y60B/5gDRR1pWLCMHIxfkeCw9S6o66Zs6alLlUpc rrJRGcXJkTBgc5aFCdJfCojFay9XOCDrg0J9EUhFhGjoKaFvqy5scehKcIzVC0fcI/Y7Z ssAGw5DgLQQaDbycbSVNjFNvObT/byOQK+WKARnq3n133S2ToaZ2AXsHu+gGp8JeQ4Q== 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=r+7AcnEeJxfboB0rgl1sGxGdY1ty72JntLy0QEaTEopK0sFerhbbZo5QasGn1uQmqvdw D5ZqYD+UVOScwQPGy476gLuMB2yCairF5Vthh7s/ieVpBmIwLJ0ihaqNFZL/TmYBRjmh2 GgOkS+Y/zqUqhI1gq7YurXAU2upns3MRzz6RrKyK/gO9Fa8qErLjRj8bowVIFZQXuK+hJ F54QppioJZ2TUEclqEwpAptKeM8zW8WEIixn5+TIzTpzeUOIanyaBQ97IZgMe0H4twFkD 8dC4eP0mPMlSavlBTufBMAxR/jdvP3wIF/lZL/Q9dfaN84jlfECKbdBQF+unb1pUmHA== 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=t+ZLO11c; arc=none smtp.remote-ip=74.125.224.52 Received: from mail-yx1-f52.google.com (mail-yx1-f52.google.com [74.125.224.52]) (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 6F0E9606A327 for ; Sun, 29 Nov 2026 05:38:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6F0E9606A327 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=t+ZLO11c Received: by mail-yx1-f52.google.com with SMTP id 956f58d0204a3-67db8985419so11501039d50.1 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=lists.linux.dev; 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=t+ZLO11cnJP0p7c4eeVgSCn2eyfew/Zk1I+OJlUR5XNWWH813TwwJHezRWvvl30Ngn bPIm9Kr9O6X0qEL1yr2BopTR7hF4ghTP+FSASCdaW9j2ETUlMNMBKl59AeGGR8X91khX iS0IMpPW4EORIiHkqUcmH4SZtgvRz7CDc9c5I= 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=rFCkU0GREMM8L8RAucS+PiyCa3cQ5ICqRTCCUHnocA0WzqfD+amcW6le6k82WF2p0f BeEM+xvKleZN0CnaNe5tTwnsb/4j+ZLK2D4qkJTEqGUAoFMJNRakevYVpuZXyZNYvcov KLmabKv/weTPitWDc8oTDui9zJtO9o06iUid5Vn6ozj5Utghp3V6gexnaMnTq/Y2+THt ULUy/uxzmfUY0WfyMx/c3yn/LuJ8jYIp/9orbuggRB1XOM928nta0iu98SS2IPm13SFX 7ge/GQzhNPSwkCZlwayfM8/zqDjSgUdk2zaU0IQLbVUeWDSilxVhV1+IW2zZNGjvnXhT /d7g== X-Forwarded-Encrypted: i=1; AL+hErGzIpibWmViCqZg2QO9KQH/908aOd+n4NeeRROKtGKqOai+Tg9oHpyMun1Rsf5OiW/TmYZkZWLtgNl05Q==@lists.linux.dev X-Gm-Message-State: APuU4Z83Rnd4KpEYYnK6f+tc7xCbGLXD4N+kaexO1n5+pHRrNvjAArYl G88fc32TgnGfY5+xHYboTE/xwVMO8Q8yyQnEgLk+Wmk4IABul7bnMZx9Ci9mE5/S7N4= X-Gm-Gg: AZFdTZfmI8KaZwv55slB60Jr9Ys2RNwgR7TzKAoGoCmpZXsfrOxlZVTJyT3tyhGoDIU d8FUNylwv7fx6FoTYZ9064nw43tlrALnyeQaGbJ2Rgm7AhpHbLnSp/QXrUTuzyW0KPua4WYNheN ZpwsVMCWm9/MyJIwNhA8zkcN7NuMNJ/8mfV+lTjz7exABXrN9qs1p4PGTwK+ztehCCjaD6K2bhd zymYWnGfL29/5VuGuALOyz8KRnKf+Q9SaZkn2Z6iQdRZb8ab9d5nKincqC1Elb8kEI2ZROrO1Tl mK51+p5jLJy2/i+DCeBUYMYsqzRLcxEsQpMvnJ4zZzwcOYzn6qheFFbDqWOo+Yii1vBRapahOsi kWQ2kSLhO1A7Mm5+rfFTsk3oveKDMw2yW2cs49BIh+M4Udq72xpf7r/ZXjH3ihxtNwziE/kSzQZ sUUaosPEZRSmz3W1dfmGOwS7EiFrIwb1hD0QWeUn5IhDdpHNInQGCV0gtBaU7aN+PwVS8WgWQg/ Gcz9bJ080w6/s/EWCQ0V0aRixocRSrGSPQebz4K1CpuewpQGK0lsLcTyM90LXU9wKP3W1Jao9eq zip/Yqv/gAMDHWl5bFpw7UqB1FkB5FtGcZERzNiLns4lh7zxNZwwTB9bDW6LXQAM0Jk07Yorlce 3oKm+LbSiz0kAoLs/Q75LRSxMKAbQ0BnkGUqGWstC8t3DR1hevOzmBrgcVXKlNbNQNXyf3S9Apt w01ulfv2hoCwwCy5JpMtUpJ7vyXJAIYPg/kGq1igbSOGkkwFlc2zRc1X5Np32fgTXqb33AhGTRv 5JqzKw6Ud1PzkbllMYR9iyuB59STM4kFZQz13ISS6D+ 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: driver-core@lists.linux.dev 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