bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH 0/4] Use AF_ALG in checksum utilities


From: Bruno Haible
Subject: Re: [PATCH 0/4] Use AF_ALG in checksum utilities
Date: Mon, 23 Apr 2018 15:54:33 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-119-generic; KDE/5.18.0; x86_64; ; )

Hi Matteo,

> > Marvell Armada 8040 - MACCHIATOBin Dual shot:
> >
> >     $ dd if=/dev/zero bs=1G count=10 |time -p sha1sum
> >     a0b6e2ca4e28360a929943e8eb966f703a69dc44  2g.bin
> >
> >     real  0m49.390s
> >     user  0m46.852s
> >     sys  0m2.076s
> >     $ dd if=/dev/zero bs=1G count=10 |time -p ./sha1sum-afalg
> >     a0b6e2ca4e28360a929943e8eb966f703a69dc44  2g.bin
> >
> >     real  0m15.104s
> >     user  0m0.052s
> >     sys  0m15.008s

These are exciting speed improvements!

> Linux kernel cryptographic API via the AF_ALG address family.

Can you briefly explain:

  * <https://en.wikipedia.org/wiki/Crypto_API_(Linux)> says that on x86
    platforms the same functions can be done through CPU instructions. Are these
    instructions privileged? If not, then what are - for this frequent case of
    Intel CPUs - the advantages and tradeoffs of user-space vs. kernel-space
    use of this crypto instructions?

  * What is the best way to detect that the Linux kernel support for this API
    is present? Is it that the socket(AF_ALG) call fails? Or is there some hint
    in the /proc/cpu or /proc/sys file system?

A few hints regarding the gnulib coding style:

  * As you already noticed, we need to avoid build failures and runtime failures
    on platforms where this is not supported.

  * We don't use github, but this mailing list, for discussion and code reviews,
    as github is a proprietary and somewhat closed environment.

  * In the module description, section 'Include', you should not list all 
include
    files but only those that the user is supposed to include. In this case,
    I think, the af_alg business is invisible to the caller of the 4 modules.

  * In an include file, such as lib/af_alg.h, we include only the minimum of
    header files that are required for parsing it. In this case, I think it
    would only be <stdio.h>. The other header files can be included in the .c
    files, with the appropriate #if conditions.

  * The 'Hey Emacs!' section is only needed in files that contains non-ASCII
    characters.

  * Put '} else {' on 3 separate lines.

  * Use 'size_t', not 'int', for variables that denote the length of a memory
    segment.

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]