public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 00/16] btrfs: offload compression to hardware accelerators
@ 2025-11-28 19:04 Giovanni Cabiddu
  2025-11-28 14:25 ` Giovanni Cabiddu
                   ` (17 more replies)
  0 siblings, 18 replies; 42+ messages in thread
From: Giovanni Cabiddu @ 2025-11-28 19:04 UTC (permalink / raw)
  To: clm, dsterba, terrelln, herbert
  Cc: linux-btrfs, linux-crypto, qat-linux, cyan, brian.will,
	weigang.li, senozhatsky, Giovanni Cabiddu

This patch series applies to:
  https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git

This series adds support for hardware-accelerated compression and decompression
in BTRFS using the acomp APIs in the Crypto Framework.  While the
implementation is generic and should work with any acomp-compatible
implementation, the initial enablement targets Intel QAT devices.

Supported operations:
  - zlib: compression and decompression (all QAT generations)
  - zstd: compression only (GEN4 and GEN6)

This is a rework of the earlier RFC series [1].

Changes in this series:
  1. Re-enable zlib-deflate in the Crypto API and QAT driver. These were
     removed in [2] due to lack of in-kernel users. This series reverts
     those commits to restore the functionality.

  2. Add compression level support to the acomp framework. The core
     implementation is from Herbert Xu [3]; I've rebased it and
     addressed checkpatch style issues.
     Compression levels are enabled in deflate, zstd, and the QAT driver.

  3. Add compression offload to QAT accelerators in BTRFS using the acomp
     layer enabled with runtime control via sysfs.
     This feature is wrapped in CONFIG_BTRFS_EXPERIMENTAL.

Note that I included to this set also the bug fix `crypto: zstd - fix
double-free in per-CPU stream cleanup`, even if this is already merged
to crypto-2.6. This is just in case someone wants to test the series.

Feedback Requested:
  1. General approach on integration of acomp with BTRFS
  2. Folio-to-scatterlist conversion.
     @Herbert, any thoughts on this? Would it make sense to do it in the
     acomp layer instead?
  3. Compression level changes.
  4. Offload threshold strategy. Should acomp implementations report
     optimal data size thresholds, possibly per compression level and
     direction?
  5. Optimizations on the LZ4s to sequences algorithm used for GEN4.
     @Yann, any suggestions on how to improve it?
  5. What benchmarks are required for acceptance?

Performance Results. I'm including here the results from the
**previous implementation**, just to have an idea of the performance.
I still need to formally benchmark the new implementation.

Benchmarked on a dual-socket Intel Xeon Platinum 8470N system:
  - 512GB RAM (16x32GB DDR5 4800 MT/s)
  - 4 NVMe drives (349.3GB Intel SSDPE21K375GA each)
  - 2 QAT 4xxx devices (one per socket, compression-only configuration)

Test: 4 parallel processes writing 50GB each (Silesia corpus) to separate
drives

+---------------------------+---------+---------+---------+---------+
|                           | QAT-L9  | ZSTD-L3 | ZLIB-L3 | LZO-L1  |
+---------------------------+---------+---------+---------+---------+
| Disk Write TPUT (GiB/s)   | 6.5     | 5.2     | 2.2     | 6.5     |
+---------------------------+---------+---------+---------+---------+
| CPU utils %age @208 cores | 4.56%   | 15.67%  | 12.79%  | 19.85%  |
+---------------------------+---------+---------+---------+---------+
| Compression Ratio         | 34%     | 35%     | 37%     | 58%     |
+---------------------------+---------+---------+---------+---------+

Results: QAT zlib-deflate L9 achieves the best throughput with significantly
lower CPU utilization and provides better compression
ratio compared with software zstd-l3, zlib-l3 and lzo. 

Changes since v1:
  - Addressed review comments from previous series.
  - Refactored from zlib-specific to generic acomp implementation.
  - Reworked to support folios instead of pages.
  - Added support for zstd compression.
  - Added runtime enable/disable via sysfs (/sys/fs/btrfs/$UUID/offload_compress).
  - Moved buffer allocations from data path to workspace initialization
  - Added compression level support.

[1] https://lore.kernel.org/all/20240426110941.5456-1-giovanni.cabiddu@intel.com/
[2] https://lore.kernel.org/all/ZO8ULhlJSrJ0Mcsx@gondor.apana.org.au/
[3] https://lore.kernel.org/all/cover.1716202860.git.herbert@gondor.apana.org.au/

Giovanni Cabiddu (12):
  crypto: zstd - fix double-free in per-CPU stream cleanup
  Revert "crypto: qat - remove unused macros in qat_comp_alg.c"
  Revert "crypto: qat - Remove zlib-deflate"
  crypto: qat - use memcpy_*_sglist() in zlib deflate
  Revert "crypto: testmgr - Remove zlib-deflate"
  crypto: deflate - add support for deflate rfc1950 (zlib)
  crypto: acomp - add NUMA-aware stream allocation
  crypto: deflate - add support for compression levels
  crypto: qat - increase number of preallocated sgl descriptors
  crypto: qat - add support for zstd
  crypto: qat - add support for compression levels
  btrfs: add compression hw-accelerated offload

Herbert Xu (3):
  crypto: scomp - Add setparam interface
  crypto: acomp - Add setparam interface
  crypto: acomp - Add comp_params helpers

Suman Kumar Chakraborty (1):
  crypto: zstd - add support for compression levels

 crypto/842.c                                  |   4 +-
 crypto/acompress.c                            | 133 +++-
 crypto/compress.h                             |   9 +-
 crypto/deflate.c                              | 118 ++-
 crypto/lz4.c                                  |   4 +-
 crypto/lz4hc.c                                |   4 +-
 crypto/lzo-rle.c                              |   4 +-
 crypto/lzo.c                                  |   4 +-
 crypto/scompress.c                            |  43 +-
 crypto/testmgr.c                              |  10 +
 crypto/testmgr.h                              |  75 ++
 crypto/zstd.c                                 |  48 +-
 drivers/crypto/intel/qat/Kconfig              |   1 +
 .../intel/qat/qat_420xx/adf_420xx_hw_data.c   |   1 +
 .../intel/qat/qat_4xxx/adf_4xxx_hw_data.c     |   1 +
 .../intel/qat/qat_6xxx/adf_6xxx_hw_data.c     |  19 +-
 drivers/crypto/intel/qat/qat_common/Makefile  |   1 +
 .../intel/qat/qat_common/adf_accel_devices.h  |   8 +-
 .../intel/qat/qat_common/adf_common_drv.h     |   6 +-
 drivers/crypto/intel/qat/qat_common/adf_dc.c  |   5 +-
 drivers/crypto/intel/qat/qat_common/adf_dc.h  |   3 +-
 .../intel/qat/qat_common/adf_gen2_hw_data.c   |  16 +-
 .../intel/qat/qat_common/adf_gen4_hw_data.c   |  29 +-
 .../crypto/intel/qat/qat_common/adf_init.c    |   6 +-
 .../crypto/intel/qat/qat_common/icp_qat_fw.h  |   7 +
 .../intel/qat/qat_common/icp_qat_fw_comp.h    |   2 +
 .../crypto/intel/qat/qat_common/icp_qat_hw.h  |   3 +-
 drivers/crypto/intel/qat/qat_common/qat_bl.h  |   2 +-
 .../intel/qat/qat_common/qat_comp_algs.c      | 712 +++++++++++++++++-
 .../intel/qat/qat_common/qat_comp_req.h       |  11 +
 .../qat/qat_common/qat_comp_zstd_utils.c      | 120 +++
 .../qat/qat_common/qat_comp_zstd_utils.h      |  13 +
 .../intel/qat/qat_common/qat_compression.c    |  23 +-
 fs/btrfs/Makefile                             |   2 +-
 fs/btrfs/acomp.c                              | 470 ++++++++++++
 fs/btrfs/acomp_workspace.h                    |  61 ++
 fs/btrfs/compression.c                        |  66 ++
 fs/btrfs/compression.h                        |  30 +
 fs/btrfs/disk-io.c                            |   6 +
 fs/btrfs/fs.h                                 |   8 +
 fs/btrfs/sysfs.c                              |  29 +
 fs/btrfs/zlib.c                               |  81 ++
 fs/btrfs/zstd.c                               |  64 ++
 include/crypto/acompress.h                    |  27 +
 include/crypto/internal/acompress.h           |  15 +-
 include/crypto/internal/scompress.h           |  27 +
 46 files changed, 2253 insertions(+), 78 deletions(-)
 create mode 100644 drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.c
 create mode 100644 drivers/crypto/intel/qat/qat_common/qat_comp_zstd_utils.h
 create mode 100644 fs/btrfs/acomp.c
 create mode 100644 fs/btrfs/acomp_workspace.h


base-commit: ebbdf6466b30e3b37f3b360826efd21f0633fb9e
-- 
2.51.1


^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2025-12-04 10:06 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-28 19:04 [RFC PATCH 00/16] btrfs: offload compression to hardware accelerators Giovanni Cabiddu
2025-11-28 14:25 ` Giovanni Cabiddu
2025-11-28 16:13   ` Chris Mason
2025-11-28 19:04 ` [RFC PATCH 01/16] crypto: zstd - fix double-free in per-CPU stream cleanup Giovanni Cabiddu
2025-11-28 19:04 ` [RFC PATCH 02/16] Revert "crypto: qat - remove unused macros in qat_comp_alg.c" Giovanni Cabiddu
2025-11-28 19:04 ` [RFC PATCH 03/16] Revert "crypto: qat - Remove zlib-deflate" Giovanni Cabiddu
2025-11-28 19:04 ` [RFC PATCH 04/16] crypto: qat - use memcpy_*_sglist() in zlib deflate Giovanni Cabiddu
2025-11-28 19:04 ` [RFC PATCH 05/16] Revert "crypto: testmgr - Remove zlib-deflate" Giovanni Cabiddu
2025-11-28 19:04 ` [RFC PATCH 06/16] crypto: deflate - add support for deflate rfc1950 (zlib) Giovanni Cabiddu
2025-11-28 19:04 ` [RFC PATCH 07/16] crypto: scomp - Add setparam interface Giovanni Cabiddu
2025-11-28 19:04 ` [RFC PATCH 08/16] crypto: acomp " Giovanni Cabiddu
2025-11-28 19:04 ` [RFC PATCH 09/16] crypto: acomp - Add comp_params helpers Giovanni Cabiddu
2025-11-28 19:04 ` [RFC PATCH 10/16] crypto: acomp - add NUMA-aware stream allocation Giovanni Cabiddu
2025-11-28 19:04 ` [RFC PATCH 11/16] crypto: deflate - add support for compression levels Giovanni Cabiddu
2025-11-28 19:05 ` [RFC PATCH 12/16] crypto: zstd " Giovanni Cabiddu
2025-11-28 19:05 ` [RFC PATCH 13/16] crypto: qat - increase number of preallocated sgl descriptors Giovanni Cabiddu
2025-11-28 19:05 ` [RFC PATCH 14/16] crypto: qat - add support for zstd Giovanni Cabiddu
2025-11-28 19:05 ` [RFC PATCH 15/16] crypto: qat - add support for compression levels Giovanni Cabiddu
2025-11-28 19:05 ` [RFC PATCH 16/16] btrfs: add compression hw-accelerated offload Giovanni Cabiddu
2025-11-28 21:55   ` Qu Wenruo
2025-11-28 22:40     ` Giovanni Cabiddu
2025-11-28 23:59       ` Qu Wenruo
2025-11-29  0:23         ` Qu Wenruo
2025-12-01 14:32           ` Giovanni Cabiddu
2025-12-01 15:10             ` Giovanni Cabiddu
2025-12-01 20:57               ` Qu Wenruo
2025-12-01 22:18                 ` Giovanni Cabiddu
2025-12-01 23:13                   ` Qu Wenruo
2025-12-02 17:09                     ` Giovanni Cabiddu
2025-12-02 20:38                       ` Qu Wenruo
2025-12-02 22:37                         ` Giovanni Cabiddu
2025-12-02 22:59                           ` Qu Wenruo
2025-11-29  1:00         ` David Sterba
2025-11-29  1:08       ` David Sterba
2025-12-02  7:53 ` [RFC PATCH 00/16] btrfs: offload compression to hardware accelerators Christoph Hellwig
2025-12-02 15:46   ` Jani Partanen
2025-12-02 17:19     ` Giovanni Cabiddu
2025-12-03  7:00     ` Christoph Hellwig
2025-12-03 10:15       ` Giovanni Cabiddu
2025-12-04  9:59         ` Christoph Hellwig
2025-12-03 10:47       ` Simon Richter
2025-12-04 10:06         ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox