[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241022070635.GY16066@noisy.programming.kicks-ass.net>
Date: Tue, 22 Oct 2024 09:06:35 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Christoph Hellwig <hch@...radead.org>
Cc: "Paul E. McKenney" <paulmck@...nel.org>, rcu@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel-team@...a.com,
rostedt@...dmis.org, andrii@...nel.org
Subject: Re: [PATCH rcu] srcu: Guarantee non-negative return value from
srcu_read_lock()
On Mon, Oct 21, 2024 at 11:51:40PM -0700, Christoph Hellwig wrote:
> On Mon, Oct 21, 2024 at 03:13:05PM -0700, Paul E. McKenney wrote:
> > For almost 20 years, the int return value from srcu_read_lock() has
> > been always either zero or one. This commit therefore documents the
> > fact that it will be non-negative.
>
> If it is always zero or one, wouldn't bool the better return value
> type?
What is returned is an array index -- and SRCU is currently built using
an array of size 2. Using larger arrays is conceivable (IIRC some
versions of preemptible RCU used up to 4 or something).
So while the values 0,1 are possible inside bool, that does not reflect
the nature of the numbers, which is an array index. Mapping that onto
bool would be slightly confusing (and limit possible future extention of
using larger arrays for SRCU).
Powered by blists - more mailing lists