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=1796325778; b=dOcR1wmW055a+RMQBEjBGBTKHYaykVvE2WuVKQSY9rIXZaOF88e9dv/LiWIrMBp8+Ixo PTmiD50MC+4yLuj0EcgRSsZ4wuevEUboyI+eQgAoh96W7yzHQDEnnKjACxRuHIWd7tnbz 9jUEtv3LKc9JQG9sxD5UoTb6UiKVxLXNzslvH4lGnacZkIo1iViLeQCugkBMxnN2U278q WJk/fs1ybtBlfAyMYBKsnBlkReFgPJDrPQ9SIS8X08S3YNL9iH8RP5xA0OuWUfycV+wLo xQniCms0gMhoP3nqIk4gfG6QWlNkv1wgk0mfqCS81HSxi92FjeMMF4O9ycM0Cx/zF7w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796325778; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=uCg1KCoAy20Xm3JEPAYMXStUUT2m/yaa3Dyzj0lCau4=; b=aPyVQdHdK/ZBBrrEfkpAp9cqzYBeCFK1xX3QzSpLPdhp4XfHmGlhE6azwfXkfgvRtfbL LBu1Q2yHrCet0/OKzduDW/d26fm52q473xsgQH4W3nLIaZntv9Gp2LH/twthcoHJi9sSc n3AchdR/Oxmzvyu91TIXtxAbiVyFrJq8Ujo44qoZkNIszt6PJvLdBsjxkey8N5nJnri4N 64MJZRbXLFDmPiGPSAyHHy4BQ6rm67q2MMj8ynAgIRDDR4YbLEPVevC53qo0ZlVcuP2Ng lzIK3w40DmsTnW/80+3pYEyfWIzVNRG8Ji1HCoA5mPAaFumF4gM1kVkT0NapEeMfLNQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="irImOV/X"; 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 17583606A68A; Thu, 3 Dec 2026 19:22:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=irImOV/X Received: by smtp.kernel.org (Postfix) with ESMTPSA id A93501F00939; Thu, 3 Dec 2026 19:22:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796325777; bh=uCg1KCoAy20Xm3JEPAYMXStUUT2m/yaa3Dyzj0lCau4=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=irImOV/Xr2NwiuWhcdXWghkeCwtaJBNsv/fZQ/Gr9hMYwpV21YsJzkCUOUXdAyCpS fSA0Mcz47UnuiS55ewAQAtSZ1Hnj8ZNAlCRraPc1+AxI7Lrc10aW9TWD0xm7rapa1P WkPrcByQcqG6eMUGn9zSLJxi/+ovcmg+hFAt68X8rANyBKMX+xqJgCbSwfhMYR18Vj uD3VaIvqRX7z3jOkprPY0aQzsz/zlvjA2cMpHlgokatbxuV5oFc26eajWlKm2KVTF7 8KoVvZ7waSL0JZMKsigktE7LeLgD0og/l+iC7dlJnbTxwF/WYmdxqFQ4Wa7+FzAFcW Wh0/zdHYEgTlw== Date: Thu, 3 Dec 2026 19:22:50 +0000 From: "Lorenzo Stoakes (ARM)" To: Waiman Long Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Nick Terrell , David Sterba , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-kernel@vger.kernel.org, "David Hildenbrand (Arm)" , llvm@lists.linux.dev Subject: Re: [PATCH v2] locking/rwsem: don't let readers retain the lock past a queued writer Message-ID: References: <20261126-rwsem-dont-steal-from-queued-writer-v2-1-9772914de49e@kernel.org> X-Mailing-List: llvm@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 In-Reply-To: On Tue, Dec 01, 2026 at 11:27:59AM -0500, Waiman Long wrote: > On 11/26/26 5:14 PM, Lorenzo Stoakes (ARM) wrote: > > This still permits reader stealing if a writer last held the lock, as > > failing to do so can starve readers in favour of writers. This maintains > > fairness. > Yes, I like this idea of maintaining some fairness. Thanks :) Yeah the numbers showed that this was a good idea. > > Writer latency (microbenchmark, bare metal, p99) > > ------------------------------------------------ > > readers base patched > > 2 3813 us 17 us > > 4 3868 us 29 us > > 16 5369 us 4008 us (within expected stddev) > > 62 4612 us 3835 us (ditto) > > 2, one CCD 3865 us 17 us > > 7, one CCD 3951 us 35 us > > > > Writer throughput +35-54% at 2 and 4 readers and in both one-CCD cases. > > Reader steals in this test: 4.8M -> 8. > Just to confirm if the reader steals had dropped from 4.8M to just 8. That > is really low. What is the test duration? Yeah this is accurate :) Each test run is 7 runs of 5 seconds each, with: * one writer calling mprotect() on a single page ever 1ms * vs. [1,2,4,16,62,2^,7^] readers looping madvise(MADV_POPULATE_READ) over 64 pages. ^ = pinned to one CCD So basically contrived to be the case this change is addressing. So either the writer holds the lock or is at the head of the queue of a reader-owned rwsem, thus won't steal. Stats were: base patched rlock_steal 4809477 8 sleep_writer 4408523 22979 wake_writer 4823875 46499 wlock 17385 22926 rlock 229735 249025 So this is basically 'does this change do what we need' and yes :) And as per the bench results there's no impact elsewhere. > Other than a question about the drop in reader stealing count, the patch > looks reasonable to me and the benchmark results look good too. > > Reviewed-by: Waiman Long Great thanks! :) -- Cheers, Lorenzo