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=DxIzpKuBe75BNBRoin9ZnofxousH4qUzR+GhSfvXv52RFBkQrfQdLIlwuSiDQsy0Xt5U KijXH3LuPvxqw/nrym15tMiIBB9RvfwJIvNpqLQmQH6kl6yy8VNMmuB3zn9DadBOFa36X gKMC5cfwsBNb3zIXe4u3GViRJNP6cn7DAwld0resEcyL4ZFMoT38NOEgHULCLW6hd8fmc ol6si9f2ZA4w7x6ugE4sZ74G0dFeCc8xY7ioBNdGhiyqtKZvyxixBUkAlDygovUNCy8ZQ Qw7mD004njl/U9jPYFZHZpCw/Bpi6NTXJeJOWoOSHSUceKWei2otGcvc2gUxJfZEs/w== 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=Y2Q/vuyVhyXwItyWSeXbuyuQdKTBpCc0/tvw8MokSgO9BwFlSm2hPmuhcDa0SaituGzE VNDTZ0k/mPZJXzwV7U8jUiCfThSjOdaYJ93lkVuaGO7p5fQEWm66q/LAmAUKy44S73Zbb zww/9WOU6O/lDNn5awPS/KzVAANirljvWKBwB82WL/lvkp6XL0ZYbzTeP6Yh721NOI9S/ WP4DSZ9x4G388MLil2a5H8ZzRIn5StrH2VxYAqRsxjcHEjRPD5AX9eDfczIKajtq6U0ZP JaNCkqoxjpT/goASTMreDgzgnWJz12Dy7oQysZY6Av1EfVxw3bSYMzk0EhseVdrCWgw== 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 6481D606A325 for ; Sun, 29 Nov 2026 05:38:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6481D606A325 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-67db8985419so11501037d50.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=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=qrQW91W7H9ks0YWEMXtPoBQouLaQ6syB70MV3IivnZf3xmwmd6b77l+e8l4scDHC2M zOVEguHQn3ihy/Vs6PfLT3T7CtVG7z+p3wUynZlIWGxtYTw8RS7wO0aVCbDUKMea+rrM BKwUc2E1T+spfcJ+fjNu6645cHa+yMq2PdFqii1CsIQzDlxu9ogMRoIE1BMchBOwZgzv yCKk4oowCRx94fcx475xB9SyVFXmD0HiDGJHMaTgikmth2i4TDpnMOKrDY5pxZ4KZiR+ 2u41ePyAwXm8Fmcuz2FbX0BI2qliL6dyGi7MP5lx0XT8u1bL/WOZuO0fLnTFM9vHtiKO qPlw== X-Forwarded-Encrypted: i=1; AL+hErHyt4T2S/Y42dElwxixfbxelwnp/5AUMAy5X3YTFFX6vPovazio3dodPjCK5BOHgZ4RzJPnoCcz@vger.kernel.org X-Gm-Message-State: APuU4Z8PuKPaFZ741+ZemNSuJ6i/A4LUJ4bvxFcIHDCRa4Dr/lYQH1Ud Sq5AVxx0RF1ox0Yfa5zSnWRx+KrOSQIzEMXdLStVoBRZyZaXiAMpE9633m0WA7uybdU= X-Gm-Gg: AZFdTZdsU0sFHo/2A7qECj6onycDDC3j2hSZWQqSi1jfPnD1gHFpvL1BB7HecB8Qkhh GgT26gssP4Ny3Ro04bzxmtMJtP0uhL4nw2AVn6hN5l0RSSWNTfHJMofXuKAqg3HgHx3wBHvDmk0 9ZzwE7nMKWCkqZpP5gRgx9zbXY3XowWaLDxjaSz70CWgo4Etw3E0zOnXKX3ml3pKPRYPmEiZzpz blqEfpgdVoQJ6nzG3ZIA3I4z6BUZJvrJNYizBlplaboVlvlUOB7G6/OpUHxYQ5dFuoHA2e2CRRi 5g/+ZLvhVxVHYnlKkLhXA+moHhRDA2aVxqe7kEt0dtZ537/F07QKlMfrt5V63yiuDx1x7ZFKGUv /0WWr/KMKhwhBNjFrmGyyWeSkGWYeNBWXwCHotjHL20a1Rc5cB0hC/yEiF6vbQ8IdcmCqebDl/i Bc4V7VyXsEoaCyLxvm/53+0/1fHtkhv2XYXlIqIKazNzYZ0evmtiJGUyeKJ05gDFN9ovGt1Cwjg +IDZNwX+myTY5dNK8jk0/FADGMmoePssFzVSPef93B/JRjtvT5ES409usXTI+7MhKmQrw3I0sfN XPyeQhiMIPFeUm/tZBCVvDzyjkb7kYZ9znFK5BYFPYMRryXxpxHOwBjnGJYl6EBMJei3fUiUDDQ dPVNpyGV+SUDYY/M8mdrCqIqAzTf3oh2aAjaPyyOx22whtVHUsV5arooJKEOfhajuZmcCvLH0q/ bQYVvZDyZS1m2azje9AoFyOlhV3QgjY4z9/rC9g0X3pJzKkErgR/meEB4jfx/MEG02igGbXd14Z 8F96+CPgqRf6LqIx8MbJovnIWbLEK/BBrHgZAjOTNl0 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: 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. 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