public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* Re: [PATCH 0/4] RISC-V CRC optimizations
       [not found]     ` <20250302220426.GC2079@quark.localdomain>
@ 2025-03-08 12:58       ` Ignacio Encinas Rubio
  2025-03-10 12:34         ` Alexandre Ghiti
  0 siblings, 1 reply; 2+ messages in thread
From: Ignacio Encinas Rubio @ 2025-03-08 12:58 UTC (permalink / raw)
  To: Eric Biggers, Björn Töpel, Palmer Dabbelt
  Cc: linux-kernel-mentees, linux-kernel, linux-crypto, linux-riscv,
	Zhihang Shao, Ard Biesheuvel, Xiao Wang, Charlie Jenkins,
	Alexandre Ghiti, skhan

Hello!

On 2/3/25 23:04, Eric Biggers wrote:
> So, quite positive results.  Though, the fact the msb-first CRCs are (still) so
> much slower than lsb-first ones indicates that be64_to_cpu() is super slow on
> RISC-V.  That seems to be caused by the rev8 instruction from Zbb not being
> used.  I wonder if there are any plans to make the endianness swap macros use
> rev8, or if I'm going to have to roll my own endianness swap in the CRC code.
> (I assume it would be fine for the CRC code to depend on both Zbb and Zbc.)

I saw this message the other day and started working on a patch, but I
would like to double-check I'm on the right track:

- be64_to_cpu ends up being __swab64 (include/uapi/linux/swab.h) 

If Zbb was part of the base ISA, turning CONFIG_ARCH_USE_BUILTIN_BSWAP 
would take care of the problem, but it is not the case. 

Therefore, we have to define __arch_swab<X> like some "arches"(?) do in 
arch/<ARCH>/include/uapi/asm/swab.h

For those functions to be correct in generic kernels, we would need to 
use ALTERNATIVE() macros like in arch/riscv/include/asm/bitops.h.
Would this be ok? I'm not sure if the ALTERNATIVEs overhead can be a
problem here.

Thanks in advance :)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 0/4] RISC-V CRC optimizations
  2025-03-08 12:58       ` [PATCH 0/4] RISC-V CRC optimizations Ignacio Encinas Rubio
@ 2025-03-10 12:34         ` Alexandre Ghiti
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Ghiti @ 2025-03-10 12:34 UTC (permalink / raw)
  To: Ignacio Encinas Rubio, Eric Biggers, Björn Töpel,
	Palmer Dabbelt
  Cc: linux-kernel-mentees, linux-kernel, linux-crypto, linux-riscv,
	Zhihang Shao, Ard Biesheuvel, Xiao Wang, Charlie Jenkins,
	Alexandre Ghiti, skhan

Hi Ignacio,

On 08/03/2025 13:58, Ignacio Encinas Rubio wrote:
> Hello!
>
> On 2/3/25 23:04, Eric Biggers wrote:
>> So, quite positive results.  Though, the fact the msb-first CRCs are (still) so
>> much slower than lsb-first ones indicates that be64_to_cpu() is super slow on
>> RISC-V.  That seems to be caused by the rev8 instruction from Zbb not being
>> used.  I wonder if there are any plans to make the endianness swap macros use
>> rev8, or if I'm going to have to roll my own endianness swap in the CRC code.
>> (I assume it would be fine for the CRC code to depend on both Zbb and Zbc.)
> I saw this message the other day and started working on a patch, but I
> would like to double-check I'm on the right track:
>
> - be64_to_cpu ends up being __swab64 (include/uapi/linux/swab.h)
>
> If Zbb was part of the base ISA, turning CONFIG_ARCH_USE_BUILTIN_BSWAP
> would take care of the problem, but it is not the case.
>
> Therefore, we have to define __arch_swab<X> like some "arches"(?) do in
> arch/<ARCH>/include/uapi/asm/swab.h
>
> For those functions to be correct in generic kernels, we would need to
> use ALTERNATIVE() macros like in arch/riscv/include/asm/bitops.h.
> Would this be ok? I'm not sure if the ALTERNATIVEs overhead can be a
> problem here.


Yes, using alternatives here is the right way to go. And the only 
overhead when Zbb is available would be a nop (take a look at lib/csum.c).

Thanks for working on this, looking forward to your patch,

Alex


> Thanks in advance :)
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-03-10 12:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20250216225530.306980-1-ebiggers@kernel.org>
     [not found] ` <20250224180614.GA11336@google.com>
     [not found]   ` <87ikorl0r5.fsf@all.your.base.are.belong.to.us>
     [not found]     ` <20250302220426.GC2079@quark.localdomain>
2025-03-08 12:58       ` [PATCH 0/4] RISC-V CRC optimizations Ignacio Encinas Rubio
2025-03-10 12:34         ` Alexandre Ghiti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox