[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
- To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- From: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Apr 2025 15:04:30 -0700
- Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, x86@xxxxxxxxxx, Juergen Gross <jgross@xxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Alexander Usyskin <alexander.usyskin@xxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Mateusz Jończyk <mat.jonczyk@xxxxx>, Mike Rapoport <rppt@xxxxxxxxxx>, Ard Biesheuvel <ardb@xxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Tue, 29 Apr 2025 22:05:00 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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
|