• Ondrej Mosnacek's avatar
    crypto: lrw - Do not use auxiliary buffer · ac3c8f36
    Ondrej Mosnacek authored
    This patch simplifies the LRW template to recompute the LRW tweaks from
    scratch in the second pass and thus also removes the need to allocate a
    dynamic buffer using kmalloc().
    
    As discussed at [1], the use of kmalloc causes deadlocks with dm-crypt.
    
    PERFORMANCE MEASUREMENTS (x86_64)
    Performed using: https://gitlab.com/omos/linux-crypto-bench
    Crypto driver used: lrw(ecb-aes-aesni)
    
    The results show that the new code has about the same performance as the
    old code. For 512-byte message it seems to be even slightly faster, but
    that might be just noise.
    
    Before:
           ALGORITHM KEY (b)        DATA (B)   TIME ENC (ns)   TIME DEC (ns)
            lrw(aes)     256              64             200             203
            lrw(aes)     320              64             202             204
            lrw(aes)     384              64             204             205
            lrw(aes)     256             512             415             415
            lrw(aes)     320             512             432             440
            lrw(aes)     384             512             449             451
            lrw(aes)     256            4096            1838            1995
            lrw(aes)     320            4096            2123            1980
            lrw(aes)     384            4096            2100            2119
            lrw(aes)     256           16384            7183            6954
            lrw(aes)     320           16384            7844            7631
            lrw(aes)     384           16384            8256            8126
            lrw(aes)     256           32768           14772           14484
            lrw(aes)     320           32768           15281           15431
            lrw(aes)     384           32768           16469           16293
    
    After:
           ALGORITHM KEY (b)        DATA (B)   TIME ENC (ns)   TIME DEC (ns)
            lrw(aes)     256              64             197             196
            lrw(aes)     320              64             200             197
            lrw(aes)     384              64             203             199
            lrw(aes)     256             512             385             380
            lrw(aes)     320             512             401             395
            lrw(aes)     384             512             415             415
            lrw(aes)     256            4096            1869            1846
            lrw(aes)     320            4096            2080            1981
            lrw(aes)     384            4096            2160            2109
            lrw(aes)     256           16384            7077            7127
            lrw(aes)     320           16384            7807            7766
            lrw(aes)     384           16384            8108            8357
            lrw(aes)     256           32768           14111           14454
            lrw(aes)     320           32768           15268           15082
            lrw(aes)     384           32768           16581           16250
    
    [1] https://lkml.org/lkml/2018/8/23/1315Signed-off-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    ac3c8f36
lrw.c 10.8 KB