[PATCH] powerpc/xive: fix the fuzz value in xive_pick_irq_target()

Michael Ellerman mpe at ellerman.id.au
Thu Aug 3 19:52:10 AEST 2017


Benjamin Herrenschmidt <benh at kernel.crashing.org> writes:

> On Thu, 2017-08-03 at 09:45 +0200, Cédric Le Goater wrote:
>> On 08/02/2017 11:57 PM, Benjamin Herrenschmidt wrote:
>> > On Wed, 2017-08-02 at 18:43 +0200, Cédric Le Goater wrote:
>> > > If xive_find_target_in_mask() fails to find a cpu, the fuzz value used
>> > > in xive_pick_irq_target() is decremented and reused in the last
>> > > returning call to xive_find_target_in_mask(). This can result in such
>> > > WARNINGs if the initial fuzz value is zero :
>> > 
>> > Ah indeed ... would have worked better if "fuzz" had been unsigned.
>> 
>> but 'fuzz' is unsigned ! 
>
> Haha right.
>
>> With a -1, unsigned or not, the 'first' cpu  becomes out of range for
>> the calculation below :
>> 
>> 	/* Pick up a starting point CPU in the mask based on  fuzz */
>> 	num = cpumask_weight(mask);
>> 	first = fuzz % num;
>
> How can it ? fuzz % num should then return something that's
>
> 	0 <= first < num
>
> Regardless of the value of fuzz.

What if num is 0?

Which it would be in the fallback case, if the affinity mask is empty,
AFAICS.

cheers


More information about the Linuxppc-dev mailing list