[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] bitops/32: Convert variable_ffs() and fls() zero-case handling to C



On April 29, 2025 3:04:30 PM PDT, Linus Torvalds 
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>On Tue, 29 Apr 2025 at 14:59, Andrew Cooper <andrew.cooper3@xxxxxxxxxx> wrote:
>>
>> do_variable_ffs() doesn't quite work.
>>
>> REP BSF is LZCNT, and unconditionally writes it's output operand, and
>> defeats the attempt to preload with -1.
>>
>> Drop the REP prefix, and it should work as intended.
>
>Bah. That's what I get for just doing it blindly without actually
>looking at the kernel source. I just copied the __ffs() thing - and
>there the 'rep' is not for the zero case - which we don't care about -
>but because lzcnt performs better on newer CPUs.
>
>So you're obviously right.
>
>            Linus

Yeah, the encoding of lzcnt was a real mistake, because the outputs are 
different (so you still need instruction-specific postprocessing.)



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.