• Sebastian Andrzej Siewior's avatar
    crypto: scompress - Use per-CPU struct instead multiple variables · 71052dcf
    Sebastian Andrzej Siewior authored
    Two per-CPU variables are allocated as pointer to per-CPU memory which
    then are used as scratch buffers.
    We could be smart about this and use instead a per-CPU struct which
    contains the pointers already and then we need to allocate just the
    scratch buffers.
    Add a lock to the struct. By doing so we can avoid the get_cpu()
    statement and gain lockdep coverage (if enabled) to ensure that the lock
    is always acquired in the right context. On non-preemptible kernels the
    lock vanishes.
    It is okay to use raw_cpu_ptr() in order to get a pointer to the struct
    since it is protected by the spinlock.
    
    The diffstat of this is negative and according to size scompress.o:
       text    data     bss     dec     hex filename
       1847     160      24    2031     7ef dbg_before.o
       1754     232       4    1990     7c6 dbg_after.o
       1799      64      24    1887     75f no_dbg-before.o
       1703      88       4    1795     703 no_dbg-after.o
    
    The overall size increase difference is also negative. The increase in
    the data section is only four bytes without lockdep.
    Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    71052dcf
scompress.c 7.01 KB