zstd: track allocator statistics

Note that this only tracks sizes as requested by the caller.
Actual allocated space will almost always be bigger (e.g., rounded up to
the next power of 2 or page size). Additionally the allocated buffer may
be holding other areas hostage. Nonetheless, this is a starting point
for tracking memory usage in zstd.

Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Closes #11129
This commit is contained in:
Mateusz Guzik
2020-10-30 23:26:10 +01:00
committed by GitHub
parent e8beeaa111
commit c4ede65bdf
2 changed files with 15 additions and 6 deletions
+4 -2
View File
@@ -75,9 +75,11 @@ typedef struct zfs_zstd_header {
* kstat helper macros
*/
#define ZSTDSTAT(stat) (zstd_stats.stat.value.ui64)
#define ZSTDSTAT_INCR(stat, val) \
#define ZSTDSTAT_ADD(stat, val) \
atomic_add_64(&zstd_stats.stat.value.ui64, (val))
#define ZSTDSTAT_BUMP(stat) ZSTDSTAT_INCR(stat, 1)
#define ZSTDSTAT_SUB(stat, val) \
atomic_sub_64(&zstd_stats.stat.value.ui64, (val))
#define ZSTDSTAT_BUMP(stat) ZSTDSTAT_ADD(stat, 1)
/* (de)init for user space / kernel emulation */
int zstd_init(void);