[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZxiacAA9LIWv70Xp@infradead.org>
Date: Tue, 22 Oct 2024 23:40:48 -0700
From: Christoph Hellwig <hch@...radead.org>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: paulmck@...nel.org, Christoph Hellwig <hch@...radead.org>,
Peter Zijlstra <peterz@...radead.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 Tue, Oct 22, 2024 at 10:29:13AM -0700, Andrii Nakryiko wrote:
> >
> > Would this work?
> >
> > #define SRCU_INVALID_INDEX -1
> >
>
> But why?
Becaue it very clearly documents what is going on.
>It's a nice property to have an int-returning API where valid
> values are only >= 0, so callers are free to use the entire negative
> range (not just -1) for whatever they need to store in case there is
> no srcu_idx value.
Well, if you have a concrete use case for that we can probably live
with it, but I'd rather have that use case extremely well documented,
as it will be very puzzling to the reader.
Powered by blists - more mailing lists