summaryrefslogtreecommitdiff
path: root/drivers/block/zram/zcomp.h
diff options
context:
space:
mode:
authorSergey Senozhatsky <senozhatsky@chromium.org>2024-09-02 13:56:07 +0300
committerAndrew Morton <akpm@linux-foundation.org>2024-09-10 02:39:10 +0300
commitb8f03cb703a160e14f87a467a4443adc5d940087 (patch)
tree29d4a762e4c14258cf7b4e6c3838ce61331b097c /drivers/block/zram/zcomp.h
parent6a81bdfeb35094c3097650306a5fda9a990d8a97 (diff)
downloadlinux-b8f03cb703a160e14f87a467a4443adc5d940087.tar.xz
zram: move immutable comp params away from per-CPU context
Immutable params never change once comp has been allocated and setup, so we don't need to store multiple copies of them in each per-CPU backend context. Move those to per-comp zcomp_params and pass it to backends callbacks for requests execution. Basically, this means parameters sharing between different contexts. Also introduce two new backends callbacks: setup_params() and release_params(). First, we need to validate params in a driver-specific way; second, driver may want to allocate its specific representation of the params which is needed to execute requests. Link: https://lkml.kernel.org/r/20240902105656.1383858-20-senozhatsky@chromium.org Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> Cc: Minchan Kim <minchan@kernel.org> Cc: Nick Terrell <terrelln@fb.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'drivers/block/zram/zcomp.h')
-rw-r--r--drivers/block/zram/zcomp.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/block/zram/zcomp.h b/drivers/block/zram/zcomp.h
index 1d8920c2d449..ad5762813842 100644
--- a/drivers/block/zram/zcomp.h
+++ b/drivers/block/zram/zcomp.h
@@ -7,10 +7,18 @@
#define ZCOMP_PARAM_NO_LEVEL INT_MIN
+/*
+ * Immutable driver (backend) parameters. The driver may attach private
+ * data to it (e.g. driver representation of the dictionary, etc.).
+ *
+ * This data is kept per-comp and is shared among execution contexts.
+ */
struct zcomp_params {
void *dict;
size_t dict_sz;
s32 level;
+
+ void *drv_data;
};
/*
@@ -38,13 +46,17 @@ struct zcomp_req {
};
struct zcomp_ops {
- int (*compress)(struct zcomp_ctx *ctx, struct zcomp_req *req);
- int (*decompress)(struct zcomp_ctx *ctx, struct zcomp_req *req);
+ int (*compress)(struct zcomp_params *params, struct zcomp_ctx *ctx,
+ struct zcomp_req *req);
+ int (*decompress)(struct zcomp_params *params, struct zcomp_ctx *ctx,
+ struct zcomp_req *req);
- int (*create_ctx)(struct zcomp_params *params,
- struct zcomp_ctx *ctx);
+ int (*create_ctx)(struct zcomp_params *params, struct zcomp_ctx *ctx);
void (*destroy_ctx)(struct zcomp_ctx *ctx);
+ int (*setup_params)(struct zcomp_params *params);
+ void (*release_params)(struct zcomp_params *params);
+
const char *name;
};