From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796010500; b=TrrtTRPrdfpZSa3eHv6OtxBkoLqvrOAvYkFM/XxxI8BLMgLxqakf/knc8Ruv3vAPVTBM HLA3U7WMIfoLZrA1v22CU5zsUwT6JfexDPjSezqXXKVcRwYnZkuCW5DydAEs+BesitlD3 fvwmoHzPxMiCLHbSBWvrBAelC4yrUA96fEFL1bDM4zTmxw7FfGkVompbmgJ3lQhlSdB2I WcWyLCskQzpORRLzd0brqEeSIV3RSt/+RZRkKkDdU8z9vZ/iOuNS8S/JXS8MeyFjfD2xg a/SRxms59W8VA4o3lzqkou+RRtnoJ/wsO2/ZbINMeDktU+IR2pYmlV8kPbGiH4itO5Q== 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=JHOklnWQ+IUEVHFzFqw9M1r/CR2xJva4R+WacuASBtHDlJIpKwv6OUN2dHjAJJ52PayO VxlS4qY9G4Gn2NHCrez2zMRqzSLjlPx2WLlJREC8ZCVz/TqOkdtD4m+jHMpazcHvvXN/T oujOicTdNvebsAPincysJjWCO8IFl9DRPl4BA5NvaSg0/yq+vBUJ5hD7b4CDF2BBfAdA0 sWKPkc54HoOx7esN2rHqhUzdUhIfI9WK1z4pDEZ6cT3Go4Wjb18ysgmnpRRfrY1XGmsLk Mz/802rdBdN8mhRevFzvBQBojqZFboKyBQXsCzZT8AS7GQs4KLm1SNpVQsxtfFP8ncw== 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=JuRC3QSA; arc=none smtp.remote-ip=209.85.128.170 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (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 64AA1606A325 for ; Mon, 30 Nov 2026 03:48:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 64AA1606A325 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, unprotected) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=JuRC3QSA Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-8b51871c5c4so66946087b3.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=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=LHVw51i2WE5jXW+U5dt960l/MiJtxpVtsnQjUtE+9ag=; b=JuRC3QSAG9Onf7STMyd4gG2spkyI1bcASu3UMBXIwpVaQMCjUi4N/DaPjnSj3p97XM qKcYlyt3Z8epebMe6oplJId0QV0lPAQKnpyyqDwNRpFrnRsGLHf7eLJRRzfisXMuZ5Li v0iSAw73ErRCrMqurh5aTjMfFWJPAG7wQOsnM= 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=WB6KtfFqEJ4QIAGLk1TjbMYcDJOOGiijvyaekAXSFbTdtMSpMLT5dmQqLFE2pt51Vb bhuTGMFxglakpkd8AVbtoeNfLs0/NJ8+vCO6VpqpOMJdfUzVTZgIXApLpZjXp6VleiIh TiOPQAgOOz01KDsv6S0TRK4KvkbN8ecphKh3Kl6sjJVFeU8bxXRAu6C8VeUgqGOFqjuR BzNRBXLTMnvQ/8uwzjuf0rGqME+c1Rn2taK7/YnBuN0Wj1zAJhH3F0Jv81NNXSVoWzfE 0QLnxXZt5FsCuzrkM6rvod+CQqSbmdoByf8DMylRsy7AxaAMtgwL0tXTYksZYn4aqeOH wvNg== X-Forwarded-Encrypted: i=1; AL+hErGQdswrRxYHfLqzB2DGZVE7nPw9W8HB+MuruE4YgoaRa4wQViV5yJYUqC/fuKwIJejPEN2qdmzg0itgSQ==@lists.linux.dev X-Gm-Message-State: APuU4Z80biOkEJLY7j+Jk84D9pqaseCTUbCylBcKmw+R4fW+rFI4zayV gwcrGoWYJwKAJJbD4kdwd2lfem/LDpIDfmeYBe9RF+ewZSLq9rdJEFHjaYlff/ncPNo= X-Gm-Gg: AZFdTZeCx6/3p3WLVW8epmvagzXhcgsvP7AqAUt65ppijsnXGakDFSqJUlGZi7ZaMJH TmQtecllIaZ5o4LHcXD92SLL5XdvIUkDiAtEoiMe4mogTw1Pnhx/o4ObJmvVXn35EPA4bfzLw2L t54uWOpnrXBDo+LICZeFDrOi8ObZqYyZh9mj0/65mtlC4wtP/Qo94siIh+3XCunmycrRE0JQGPw wMu0D3JxalKRbNs1cIKfSI/OhelyF9/PVjoLx6wQeFf8a+pGFcrOkATPwaCo5VIfKTrLUd/GUyR YxVoCE5DgdkPfttP+AOilZ67boRwznkp/jJX7eFiFoV70KxlFaMwO81BbIbfK/n9A07GPGmuILW ePHfRuplJCcJCFc9GUAx9YO6u+/M6ZA3Q/ruL2Y0hFq3UnD3P+xPOMHaWK71Eh9B9pWnFk2MOz3 7qJ1thX1zES+F3IyRnbMqmPP6Lak81mwOAbiVC3Ti6KAftegg9ymmVI5EVdqLyleLLvYtHtVHFZ rqG21qaRJBNqRj7OgZoeUKSd5/xmW3hCbSjSmlmt2wngeCsaeV7bkLNrUFy49LYoW3gtBK9lbLp HMB2TT4RDfe9RfP4l/OlBRY3bk+y2DQzhkkO4bNvck3coD7gK4QlyFdtHCswEntevO+1g0ktR1x UWIeh7Zl6Io40pgJ5Z/LC+eOB0QU5hFwdHDkN4BGpM+3WHwdlWVmbLhbnQth0rI2wjbQJlazksv I86Llr1WDKqRxpBZ9u/+SmmpxbpCd/M5ooQFgVVcIZHglqbHxk6J1rOs3O/71YS2tCGRSFWyL7u 0Q/Tg1Sw+703c0ypJWyGew= 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: 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, 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