[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z4Z8oz_5nOZ5jH5p@J2N7QTR9R3.cambridge.arm.com>
Date: Tue, 14 Jan 2025 15:02:59 +0000
From: Mark Rutland <mark.rutland@....com>
To: I Hsin Cheng <richard120310@...il.com>
Cc: Yury Norov <yury.norov@...il.com>, linux@...musvillemoes.dk,
jserv@...s.ncku.edu.tw, linux-kernel@...r.kernel.org,
visitorckw@...il.com
Subject: Re: [RFC PATCH] cpumask: Implement "random" version of
cpumask_any_but()
On Tue, Jan 14, 2025 at 03:15:43PM +0800, I Hsin Cheng wrote:
> On Mon, Jan 13, 2025 at 01:00:56PM -0500, Yury Norov wrote:
> > On Mon, Jan 13, 2025 at 11:05:19AM +0000, Mark Rutland wrote:
> > > On Mon, Jan 13, 2025 at 02:18:39PM +0800, I Hsin Cheng wrote:
> > > > Original implementation of "cpumask_any_but()" isn't actually random as
> > > > the comment claims itself to be. It's behavior is in fact to select the
> > > > first cpu in "mask" which isn't equal to "cpu".
> > >
> > > What it says specifically is:
> > >
> > > cpumask_any_but - return a "random" in a cpumask, but not this one.
> > >
> > > ... and by "random", it really means "arbitrary".
> > >
> > > The idea here is that the caller is specifying that it doesn't care
> > > which specific CPU is chosen, but this is not required to be a random
> > > selection.
> I now realize "random" here is more of a convention for the caller to
> states that it doesn't matter which cpu it gets, maybe we should
> rephrase the comment to make it less confusing? Because I think "random"
> itself does stands for a particular meaning.
FWIW, I agree. I reckon (as above), we could replace "random" with
arbitrary, i.e. replace
return a "random" cpu in a cpumask ...
... with:
return an arbitrary cpu in a cpumask ...
Looking again I see that the comment for cpumask_any_but() misses the
word "cpu" too, so it'd be nice to clean that up regardless.
Mark.
Powered by blists - more mailing lists