Re: [PATCH v2 07/13] x86/bitops: Improve arch_ffs() in the general case

2024-06-02 Thread Jan Beulich
On 01.06.2024 03:47, Andrew Cooper wrote: > On 28/05/2024 2:12 pm, Jan Beulich wrote: >> On 28.05.2024 14:30, Andrew Cooper wrote: >>> On 27/05/2024 2:37 pm, Jan Beulich wrote: On 27.05.2024 15:27, Jan Beulich wrote: > On 24.05.2024 22:03, Andrew Cooper wrote: >> --- a/xen/arch/x86/inc

Re: [PATCH v2 07/13] x86/bitops: Improve arch_ffs() in the general case

2024-05-31 Thread Andrew Cooper
On 28/05/2024 2:12 pm, Jan Beulich wrote: > On 28.05.2024 14:30, Andrew Cooper wrote: >> On 27/05/2024 2:37 pm, Jan Beulich wrote: >>> On 27.05.2024 15:27, Jan Beulich wrote: On 24.05.2024 22:03, Andrew Cooper wrote: > --- a/xen/arch/x86/include/asm/bitops.h > +++ b/xen/arch/x86/includ

Re: [PATCH v2 07/13] x86/bitops: Improve arch_ffs() in the general case

2024-05-28 Thread Jan Beulich
On 28.05.2024 14:30, Andrew Cooper wrote: > On 27/05/2024 2:37 pm, Jan Beulich wrote: >> On 27.05.2024 15:27, Jan Beulich wrote: >>> On 24.05.2024 22:03, Andrew Cooper wrote: --- a/xen/arch/x86/include/asm/bitops.h +++ b/xen/arch/x86/include/asm/bitops.h @@ -432,12 +432,28 @@ static

Re: [PATCH v2 07/13] x86/bitops: Improve arch_ffs() in the general case

2024-05-28 Thread Andrew Cooper
On 27/05/2024 2:37 pm, Jan Beulich wrote: > On 27.05.2024 15:27, Jan Beulich wrote: >> On 24.05.2024 22:03, Andrew Cooper wrote: >>> --- a/xen/arch/x86/include/asm/bitops.h >>> +++ b/xen/arch/x86/include/asm/bitops.h >>> @@ -432,12 +432,28 @@ static inline int ffsl(unsigned long x) >>> >>> stati

Re: [PATCH v2 07/13] x86/bitops: Improve arch_ffs() in the general case

2024-05-27 Thread Jan Beulich
On 27.05.2024 15:27, Jan Beulich wrote: > On 24.05.2024 22:03, Andrew Cooper wrote: >> --- a/xen/arch/x86/include/asm/bitops.h >> +++ b/xen/arch/x86/include/asm/bitops.h >> @@ -432,12 +432,28 @@ static inline int ffsl(unsigned long x) >> >> static always_inline unsigned int arch_ffs(unsigned int

Re: [PATCH v2 07/13] x86/bitops: Improve arch_ffs() in the general case

2024-05-27 Thread Jan Beulich
On 24.05.2024 22:03, Andrew Cooper wrote: > --- a/xen/arch/x86/include/asm/bitops.h > +++ b/xen/arch/x86/include/asm/bitops.h > @@ -432,12 +432,28 @@ static inline int ffsl(unsigned long x) > > static always_inline unsigned int arch_ffs(unsigned int x) > { > -int r; > +unsigned int r; >

Re: [PATCH v2 07/13] x86/bitops: Improve arch_ffs() in the general case

2024-05-27 Thread Jan Beulich
On 24.05.2024 22:03, Andrew Cooper wrote: > The asm in arch_ffs() is safe but inefficient. > > CMOV would be an improvement over a conditional branch, but for 64bit CPUs > both Intel and AMD have provided enough details about the behaviour for a zero > input. It is safe to pre-load the destinatio

[PATCH v2 07/13] x86/bitops: Improve arch_ffs() in the general case

2024-05-24 Thread Andrew Cooper
The asm in arch_ffs() is safe but inefficient. CMOV would be an improvement over a conditional branch, but for 64bit CPUs both Intel and AMD have provided enough details about the behaviour for a zero input. It is safe to pre-load the destination register with -1 and drop the conditional logic.