From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796461292; b=2ZOtHjOIf1jAEV9riFAbVtX1A8dBg2L3ZdSK7m/5PB64k5mAhnpjOEo+KLdRg0dBgqy5 P+4KPdTL2pozpbmlYDM7lTftGITb/pWOq4plncgMn2BxrQ0x+FABLvDZZxhTEcjiSTg8M 8o2RzXGXUSYz+upXZkNYmQor7F+egYxx2za1lKtLJUEGvflTSBguWzDm++mz64/0RFwhY PivppmVr+W0XNmEQAxtWMpy//9yJLn6MSbtS+qFuwGIiJ0ZPY2pCyvyhPZ4TQxscVO9Hx bOQAdiHUR33xZIzmVys7kes4+rjhB685TvqvQwdvsyDTmdjOtXtmyS6KQW1YMsB1jbA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796461292; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-Id: In-Reply-To:References:X-Mailer:Mime-Version:Content-Type: Content-Transfer-Encoding; bh=ypb6bj1ZoKEXE/CEQama+y/r3hID7G7PsdXilqlXBCI=; b=K6eGIOUW3hPMBTBACbrleClpDJuabzbJjej1SCBfFCoGMGVjxEPG1WwIJA+CRC/Er2X3 BReswcWq+ni650TkSaLmBjWNSsQKlewLyW0ZsiUNmzVqknVZOXvT89oSkNdBFkYbSZ0VQ 7YMVGJqLPQc6r3Bj/PZedY22moD/iqmzvxcyJ81FlSJmoN1bqu19bsehPU130RT3yj2fk f/LgGtVe4jruyj5Ye/NfHftpcQYv9mm3RPRp+qr6g/U9zqOH+eLziZWjGj1WR9ZQfP1H6 wgpOMeg8ZM+36s0kfYJfLjdClusw8xH+Mjf1eh1LKuWDSD5MUCg1yI1+x6SusN61f1g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=dadLujve; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4EE9606A322; Sat, 5 Dec 2026 09:01:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=dadLujve Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAD391F00936; Sat, 5 Dec 2026 09:01:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796461292; bh=ypb6bj1ZoKEXE/CEQama+y/r3hID7G7PsdXilqlXBCI=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=dadLujve4T+TZ9NQiSc6nScm43w4cV5ImStjBGXv/G9EHb+EZOj8qWyuxqBKaOIe+ tkW4GDZ8ylme2JntaIW0Pnqs8e6VSM6yGgrYK/J0wsJRfsa0OTDgsdA6ynfBULqdoo liSTvofdwuDzt23EAYxkDC/B9dkQptkgPY8tROHE= Date: Sat, 5 Dec 2026 01:01:31 -0800 From: Andrew Morton To: Shakeel Butt Cc: Christian Brauner , Greg Kroah-Hartman , Tejun Heo , Ian Kent , Jori Koolstra , "T . J . Mercier" , Meta kernel team , cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/3] kernfs: list directories without kernfs_rwsem Message-Id: <20261205010131.9a59b80224e5d8a74936c141@linux-foundation.org> In-Reply-To: <20261204211034.3436390-1-shakeel.butt@linux.dev> References: <20261204211034.3436390-1-shakeel.butt@linux.dev> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Fri, 4 Dec 2026 13:10:29 -0800 Shakeel Butt wrote: > kernfs_fop_readdir() takes kernfs_rwsem for reading for each entry, and > there is one kernfs_rwsem for the whole hierarchy. So a listing of any > cgroup directory waits whenever a writer anywhere in cgroupfs holds the > lock or waits for it, for example a mkdir that is preempted with the > lock held. Monitors such as oomd and below list cgroup directories all > the time. In a week of data from our 6.16 fleet, on 92% of the hosts > where oomd or below got stuck in a kernfs read, it was in > kernfs_fop_readdir(). > > This series lets readdir run under RCU with a sequence count in each > directory. Writers keep kernfs_rwsem, and a listing step falls back to > it only if the directory keeps changing under it. Nice. > It is one step toward kernfs readers that never wait for writers. > Andrew is working on another: keeping kernfs path walks in RCU walk, > with lockless permission checks. The two do not depend on each other > and apply together. I need to get that sent out. Also working on a thing which attacks osq_lock() and gets up to 4.2x speedup. Another which gets 4x on cgroupfs same-file concurrent open/close. Another which gets 40x on many-cpu sysfs symlink chasing. For this series, thumbs up on A/B functionality/correctness testing: : On B, the kernfs selftests passed 14/14 on normal, KASAN plus lockdep, : and KCSAN kernels. The cgroup test ran 6,005 concurrent mkdir/rmdir : pairs and 2,781 reads, then checked for missing or repeated entries. : I also tested short getdents64 buffers, resume after unlink, sysfs : netdev renames, and namespace changes. : : Test-only delays and trace points widened insertion and removal races : with readdir. They recorded 495 sequence-count retries and 145 : fallbacks to kernfs_rwsem. I forced cursor pin failure and the retry : limit, filled the dir_emit buffer, and faulted both new allocations. : Each allocation failure returned -ENOMEM; the same fd then completed : a unique listing. No failure was found in the selected code. KCSAN : reported 11 warnings outside kernfs. The over-PATH_MAX in-kernel name : path was not injected. > In a 16 CPU VM, with 8 tasks listing cgroup directories of 36 entries > (ranges over two or three runs): > > before after > with a SCHED_IDLE mkdir/rmdir loop sharing a CPU with a busy loop: > slowest listing 205-271 ms 0.19-0.86 ms > listings per second 48k-51k 1.26M-1.28M > with 4 mkdir/rmdir loops: > listings per second 96k-98k 1.26M-1.27M > mkdir+rmdir pairs per second 280-285 7.2k-7.4k Nice. There's low-hanging-fruit in there! > 15 tasks listing one directory with no writers went from 157k-172k to > 549k-690k listings per second. Listing /sys/class/net in the root > namespace, which skips 1000 devices in other namespaces, went from > 20k-21k to 29k-30k per second. > Performance testing was not all thumbs up. Faster: : In 64-vCPU guests, 64 readers listing one shared directory with 128 : child cgroups completed 125,099 listings/s before the series and : 856,659 after it, a 6.85x increase. With one concurrent writer, the : rates were 66,565 and 347,354 listings/s, a 5.22x increase. With four : writers, the gain fell to 1.11x. : : When each of the 64 readers listed its own 128-child directory, the : rates rose from 146,414 to 3,680,126 listings/s, a 25.1x increase. : These are medians of three one-second A/B runs per workload. The gains : do not extend to every workload: a single reader of a 2,048-child : directory was 19% slower, and the namespace-heavy sysfs test was : substantially slower. Not faster: : On a stable cgroup directory with 2,048 children and one reader, the : three-patch kernel fell from 3,457 to 2,797 listings/s with a 128-byte : getdents64 buffer, a 19% loss. With a 32 KiB buffer it fell from 6,090 : to 5,025 listings/s, a 17% loss. The earlier 4,096-child A/B run also : found a 19-23% slowdown. : : The larger regression was in /sys/class/net with 1,001 devices hidden : in other namespaces. With one reader and a 32 KiB buffer, throughput : fell from 85,008 to 24,595 listings/s, a 71% loss. Across 1, 8, 32 and : 64 readers and both buffer sizes, B was 56-71% slower than A. This is : consistent with the new walk searching the rbtree again for each hidden : entry.