Re: [RFC PATCH] cpumask: Implement "random" version of cpumask_any_but()

From: Kuan-Wei Chiu
Date: Mon Jan 13 2025 - 05:13:19 EST


Hi I Hsin,

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".
>
> Re-implement the function so we can choose a random cpu by randomly
> select the value of "n" and choose the nth cpu in "mask"
>
This patch may slow down the efficiency of cpumask_any_but(). Are there
any in-tree users of cpumask_any_but() that require it to return a
truly random id, or benefit from such behavior?

Regards,
Kuan-Wei