From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796010501; b=js6FQoy628q1fbLx2DxaDJ9OGgMM0Z09VqU5DlzmM2NPQecDXAse6e2DIdFAv7n+QAlv OW+gn5BUwYBTtqtrIN1VU1ZFFP2W58HPeBlfyySEn8sjx4Yu3ehvi9RQg5Vd2InuW16X7 b8z3d4zrZb/b0bjkE0Uk/d+i5QfP2bCQo82+TE0aW84UvWlw9f0aP3bZtVZnAnRYezpLg Q0tnAcpBrBYcz1sO45Bkjt7jJLuZ1vn7DHYpXCEn14DbNaegJOGTxJn+ZPyQ7+N+gxEXp wNpQKaUxBy5DM4jJWTpS6E0PmPuZbeVBJd1J2hRNsnGtUbeXMBq3WXBlE/w6MO+8wuQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796010501; 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=UdYjFUQn51n3DomU+4FzkLH1mSn28b23e3h+fxSgigsHT/GMLxq1PQRFFuRCRWTtAMY4 ulgq6CrllraSy08MTwsAxZmNVEyg/iaiqk0LvN/tBxig6jQ0qmChI+M3nbgPyfvnGNM7R +IQkKq2OcopKQIc/pW1ao3l0lVoSEiNTszacwqZ95OLidQm+meSq13deAdqLIKpJDqc6g TuyC32C//bj0hcTrCcF4+QAe2XscpXAweLXImK5TGBChBy3teGdchLQZRyZJ6zb1PGo6Q vhL5BxZ3b3O21VqMyyNIO8vzlQbj2Jo2y1+i855SRwAhtZy94j3spap5zM06/asQTbA== 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.169 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) (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 62BAC606A31C for ; Mon, 30 Nov 2026 03:48:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 62BAC606A31C 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-f169.google.com with SMTP id 00721157ae682-8b4fb5d96b3so151203937b3.1 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=JoZKcwVBwKkbRkiVwwCP+Jzh9LHo1E5BZQIkjAcK9ZiubtFnvrOxR21a5bkFdqZlue 5HQ2OpRTSBL64xErqqFcgG4Y4b+6KV7Kd05jUXihUhRtPM3ZXACPAUo24QbbU8odVdZ5 NG7xYoUWmD9ceHdR0UgjfxX+ylUT1fON8dthHSSlTiFeoczB6A9yEaF0caPGzEeX2rU1 JV2h/xUuquE6D8UA4H6J02v3xzSKJw8E0+DLwJNRGehlRHhTiJptHWg+xL1WpGtzOS0I udeuXhWsU9yOkU7jo8gWK6koI4ckN28g84p5tlQMieu7Pu9kZdj33dauBEWFrK0CRGZS 1dwA== X-Forwarded-Encrypted: i=1; AL+hErGKMN9Jt+/Kwqkkwko9WKnxpPxh0669qC9Mlxk090rgc1tEkt4RQtXNibsM8134CCJOJRM=@vger.kernel.org X-Gm-Message-State: APuU4Z+nT91hhWPrLS+2pXx7ik8XVregBohdde1fZ/JfP9f3OGK/jM5D QH77qBuSD7OCMwQTXynVW2jKfFS3CwgsTqHhHAAFv5ymEXpCHQZxcsmj8TdubEKHAeg= X-Gm-Gg: AZFdTZfi6ATpD6263ZdSh0gZ1xvXP5SoZ5F8YjKBy24E+MAMLRP8qUwvrJV+rTsM+In Cdgqf9jo5qfTifgTTZ9jH4xT+zfdX70sRmeK9Wk+EJorLKWZ5N1ca8Okbj/5gruPhtgrA4/nDWs yCgHNrqg84aU2JxZpnsJsAVpets3Z8ilDrjk2HKDMkvcoGdNU6vQbtSeT9cfh4cqmbizxjI+eH1 iciHXoDKMNMHeFvilhpSQYSqCbKotMzBEMtO228h3aliePGJtHnSe2U1aP+lvrapzHhhqk68grn zlSluHgGIhd58HK+9R+YstBzAVhwkchFVy7EtR4zwUbvKf0x7qlx362uNZc2WygGDB9zI7Hw591 yTx89mA7i4ACfM6rM6u9dwy5KKkFwgByPvkewxpBoJT/4spC7GPAVW90dG4KNnU32PBKPDIYROI pL1oSytP00np3eq0sa67ehjLFJ4z5VYraqJkHVl/KmepEXpiyibCbMeXbN/BvT7zo3Ehx0Cc3S/ NBYoQdCu1aVF5nT9VFBVsydd9az1vJPk1uNEGQIRsUBlg+lsdlcmoMe46319ldy6tJ/jvyDnoq/ tKkHCI+SOLXiNCDEVoZslzJf9ae3y5+OhWh9iYQHOYWDbV6ql+I3dPTU3x/AcQeAZj0NITdOyuM UOn+sHaWXaW+H9JZu8orML6QR5uiftvTORRhrzf3YS967qIdNVfBBra3FgOSx2VPNzZvPphoUux 9woAyKbmYceo+vAKnePw08+7sOZuDfBcZegsUt5U4Qx1vrOR+qpq6AtlkIjeAan2g00IMYcXXvS dhV1BXDQb4N1E0jEY5WjmM= 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: 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, 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