06 Jan, 2021

2 commits

  • commit 605cc30dea249edf1b659e7d0146a2cf13cbbf71 upstream.

    In commit 11fb479ff5d9 ("zlib: export S390 symbols for zlib modules"), I
    added EXPORT_SYMBOL()s to dfltcc_inflate.c but then Mikhail said that
    these should probably be in dfltcc_syms.c with the other
    EXPORT_SYMBOL()s.

    However, that is contrary to the current kernel style, which places
    EXPORT_SYMBOL() immediately after the function that it applies to, so
    move all EXPORT_SYMBOL()s to their respective function locations and
    drop the dfltcc_syms.c file. Also move MODULE_LICENSE() from the
    deleted file to dfltcc.c.

    [rdunlap@infradead.org: remove dfltcc_syms.o from Makefile]
    Link: https://lkml.kernel.org/r/20201227171837.15492-1-rdunlap@infradead.org

    Link: https://lkml.kernel.org/r/20201219052530.28461-1-rdunlap@infradead.org
    Fixes: 11fb479ff5d9 ("zlib: export S390 symbols for zlib modules")
    Signed-off-by: Randy Dunlap
    Cc: Acked-by: Ilya Leoshkevich
    Acked-by: Christian Borntraeger
    Cc: Zaslonko Mikhail
    Cc: Heiko Carstens
    Cc: Vasily Gorbik
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     
  • commit f0bb29e8c4076444d32df00c8d32e169ceecf283 upstream.

    Decompressing zlib streams on s390 fails with "incorrect data check"
    error.

    Userspace zlib checks inflate_state.flags in order to byteswap checksums
    only for zlib streams, and s390 hardware inflate code, which was ported
    from there, tries to match this behavior. At the same time, kernel zlib
    does not use inflate_state.flags, so it contains essentially random
    values. For many use cases either zlib stream is zeroed out or checksum
    is not used, so this problem is masked, but at least SquashFS is still
    affected.

    Fix by always passing a checksum to and from the hardware as is, which
    matches zlib_inflate()'s expectations.

    Link: https://lkml.kernel.org/r/20201215155551.894884-1-iii@linux.ibm.com
    Fixes: 126196100063 ("lib/zlib: add s390 hardware support for kernel zlib_inflate")
    Signed-off-by: Ilya Leoshkevich
    Tested-by: Christian Borntraeger
    Acked-by: Mikhail Zaslonko
    Acked-by: Christian Borntraeger
    Cc: Heiko Carstens
    Cc: Vasily Gorbik
    Cc: Mikhail Zaslonko
    Cc: [5.6+]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Ilya Leoshkevich
     

07 Dec, 2020

1 commit

  • Fix build errors when ZLIB_INFLATE=m and ZLIB_DEFLATE=m and ZLIB_DFLTCC=y
    by exporting the 2 needed symbols in dfltcc_inflate.c.

    Fixes these build errors:

    ERROR: modpost: "dfltcc_inflate" [lib/zlib_inflate/zlib_inflate.ko] undefined!
    ERROR: modpost: "dfltcc_can_inflate" [lib/zlib_inflate/zlib_inflate.ko] undefined!

    Fixes: 126196100063 ("lib/zlib: add s390 hardware support for kernel zlib_inflate")
    Reported-by: kernel test robot
    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Acked-by: Ilya Leoshkevich
    Cc: Mikhail Zaslonko
    Cc: Heiko Carstens
    Cc: Vasily Gorbik
    Cc: Christian Borntraeger
    Link: https://lkml.kernel.org/r/20201123191712.4882-1-rdunlap@infradead.org
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     

01 Feb, 2020

4 commits

  • Add a new function to zlib.h checking if s390 Deflate-Conversion
    facility is installed and enabled.

    Link: http://lkml.kernel.org/r/20200103223334.20669-6-zaslonko@linux.ibm.com
    Signed-off-by: Mikhail Zaslonko
    Cc: Chris Mason
    Cc: Christian Borntraeger
    Cc: David Sterba
    Cc: Eduard Shishkin
    Cc: Heiko Carstens
    Cc: Ilya Leoshkevich
    Cc: Josef Bacik
    Cc: Richard Purdie
    Cc: Vasily Gorbik
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mikhail Zaslonko
     
  • Add the new kernel command line parameter 'dfltcc=' to configure s390
    zlib hardware support.

    Format: { on | off | def_only | inf_only | always }
    on: s390 zlib hardware support for compression on
    level 1 and decompression (default)
    off: No s390 zlib hardware support
    def_only: s390 zlib hardware support for deflate
    only (compression on level 1)
    inf_only: s390 zlib hardware support for inflate
    only (decompression)
    always: Same as 'on' but ignores the selected compression
    level always using hardware support (used for debugging)

    Link: http://lkml.kernel.org/r/20200103223334.20669-5-zaslonko@linux.ibm.com
    Signed-off-by: Mikhail Zaslonko
    Cc: Chris Mason
    Cc: Christian Borntraeger
    Cc: David Sterba
    Cc: Eduard Shishkin
    Cc: Heiko Carstens
    Cc: Ilya Leoshkevich
    Cc: Josef Bacik
    Cc: Richard Purdie
    Cc: Vasily Gorbik
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mikhail Zaslonko
     
  • Add decompression functions to zlib_dfltcc library. Update zlib_inflate
    functions with the hooks for s390 hardware support and adjust workspace
    structures with extra parameter lists required for hardware inflate
    decompression.

    Link: http://lkml.kernel.org/r/20200103223334.20669-4-zaslonko@linux.ibm.com
    Signed-off-by: Ilya Leoshkevich
    Signed-off-by: Mikhail Zaslonko
    Co-developed-by: Ilya Leoshkevich
    Cc: Chris Mason
    Cc: Christian Borntraeger
    Cc: David Sterba
    Cc: Eduard Shishkin
    Cc: Heiko Carstens
    Cc: Josef Bacik
    Cc: Richard Purdie
    Cc: Vasily Gorbik
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mikhail Zaslonko
     
  • Patch series "S390 hardware support for kernel zlib", v3.

    With IBM z15 mainframe the new DFLTCC instruction is available. It
    implements deflate algorithm in hardware (Nest Acceleration Unit - NXU)
    with estimated compression and decompression performance orders of
    magnitude faster than the current zlib.

    This patchset adds s390 hardware compression support to kernel zlib.
    The code is based on the userspace zlib implementation:

    https://github.com/madler/zlib/pull/410

    The coding style is also preserved for future maintainability. There is
    only limited set of userspace zlib functions represented in kernel.
    Apart from that, all the memory allocation should be performed in
    advance. Thus, the workarea structures are extended with the parameter
    lists required for the DEFLATE CONVENTION CALL instruction.

    Since kernel zlib itself does not support gzip headers, only Adler-32
    checksum is processed (also can be produced by DFLTCC facility). Like
    it was implemented for userspace, kernel zlib will compress in hardware
    on level 1, and in software on all other levels. Decompression will
    always happen in hardware (when enabled).

    Two DFLTCC compression calls produce the same results only when they
    both are made on machines of the same generation, and when the
    respective buffers have the same offset relative to the start of the
    page. Therefore care should be taken when using hardware compression
    when reproducible results are desired. However it does always produce
    the standard conform output which can be inflated anyway.

    The new kernel command line parameter 'dfltcc' is introduced to
    configure s390 zlib hardware support:

    Format: { on | off | def_only | inf_only | always }
    on: s390 zlib hardware support for compression on
    level 1 and decompression (default)
    off: No s390 zlib hardware support
    def_only: s390 zlib hardware support for deflate
    only (compression on level 1)
    inf_only: s390 zlib hardware support for inflate
    only (decompression)
    always: Same as 'on' but ignores the selected compression
    level always using hardware support (used for debugging)

    The main purpose of the integration of the NXU support into the kernel
    zlib is the use of hardware deflate in btrfs filesystem with on-the-fly
    compression enabled. Apart from that, hardware support can also be used
    during boot for decompressing the kernel or the ramdisk image

    With the patch for btrfs expanding zlib buffer from 1 to 4 pages (patch
    6) the following performance results have been achieved using the
    ramdisk with btrfs. These are relative numbers based on throughput rate
    and compression ratio for zlib level 1:

    Input data Deflate rate Inflate rate Compression ratio
    NXU/Software NXU/Software NXU/Software
    stream of zeroes 1.46 1.02 1.00
    random ASCII data 10.44 3.00 0.96
    ASCII text (dickens) 6,21 3.33 0.94
    binary data (vmlinux) 8,37 3.90 1.02

    This means that s390 hardware deflate can provide up to 10 times faster
    compression (on level 1) and up to 4 times faster decompression (refers
    to all compression levels) for btrfs zlib.

    Disclaimer: Performance results are based on IBM internal tests using DD
    command-line utility on btrfs on a Fedora 30 based internal driver in
    native LPAR on a z15 system. Results may vary based on individual
    workload, configuration and software levels.

    This patch (of 9):

    Create zlib_dfltcc library with the s390 DEFLATE CONVERSION CALL
    implementation and related compression functions. Update zlib_deflate
    functions with the hooks for s390 hardware support and adjust workspace
    structures with extra parameter lists required for hardware deflate.

    Link: http://lkml.kernel.org/r/20200103223334.20669-2-zaslonko@linux.ibm.com
    Signed-off-by: Ilya Leoshkevich
    Signed-off-by: Mikhail Zaslonko
    Co-developed-by: Ilya Leoshkevich
    Cc: Chris Mason
    Cc: Christian Borntraeger
    Cc: David Sterba
    Cc: Eduard Shishkin
    Cc: Heiko Carstens
    Cc: Josef Bacik
    Cc: Richard Purdie
    Cc: Vasily Gorbik
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mikhail Zaslonko