2014-05-07 06:35:54

by Dmitry Kasatkin

[permalink] [raw]
Subject: ahash vs. shash

Hi,

ahash allows to use HW acceleration, but usually it comes at a cost of
additional HW related configuration overhead, such as configuring hash
module, DMA, etc. For that reason hashing small chucks of data is
faster doing it with shash (CPU) rather than HW acceleration.

I measured long time ago on omap-sham driver but cannot recall any data.

Does anyone have any experience under what data size it is still
better to use shash?


Thanks,

Dmitry


2014-05-14 01:39:43

by Herbert Xu

[permalink] [raw]
Subject: Re: ahash vs. shash

Dmitry Kasatkin <[email protected]> wrote:
> Hi,
>
> ahash allows to use HW acceleration, but usually it comes at a cost of
> additional HW related configuration overhead, such as configuring hash
> module, DMA, etc. For that reason hashing small chucks of data is
> faster doing it with shash (CPU) rather than HW acceleration.
>
> I measured long time ago on omap-sham driver but cannot recall any data.
>
> Does anyone have any experience under what data size it is still
> better to use shash?

It's going to be hardware-specific. It'll also depend on whether
you're coming from user-space or not as that would entail a bigger
per-request overhead, meaning that you need more data to break
even.

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2014-05-14 07:52:32

by Dmitry Kasatkin

[permalink] [raw]
Subject: Re: ahash vs. shash

On 14 May 2014 04:39, Herbert Xu <[email protected]> wrote:
> Dmitry Kasatkin <[email protected]> wrote:
>> Hi,
>>
>> ahash allows to use HW acceleration, but usually it comes at a cost of
>> additional HW related configuration overhead, such as configuring hash
>> module, DMA, etc. For that reason hashing small chucks of data is
>> faster doing it with shash (CPU) rather than HW acceleration.
>>
>> I measured long time ago on omap-sham driver but cannot recall any data.
>>
>> Does anyone have any experience under what data size it is still
>> better to use shash?
>
> It's going to be hardware-specific. It'll also depend on whether
> you're coming from user-space or not as that would entail a bigger
> per-request overhead, meaning that you need more data to break
> even.
>
> Cheers,
> --
> Email: Herbert Xu <[email protected]>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Thanks for the reply.

Integrity subsystem hashing files and file sizes of course are much different.
It is nice to minimize overall hashing time.

I made a patch for ahash support, but without removing shash.
It defines kernel command line parameter for file size threshold when
start using ahash.
It may be adjusted/tuned based on the particular HW.

http://git.kernel.org/cgit/linux/kernel/git/kasatkin/linux-digsig.git/commit/?h=ima-experimental&id=85189d1265da83c4a5c537071b1fe4cddec59a54


-Dmitry