mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Minchan Kim <minchan@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCHv5 04/23] zram: introduce custom comp backends API
Date: Sat, 6 Jul 2024 09:50:57 +0200	[thread overview]
Message-ID: <8fe873d4-b9c4-47ad-b779-e1012677011e@t-8ch.de> (raw)
In-Reply-To: <20240706045641.631961-5-senozhatsky@chromium.org>

On 2024-07-06 13:56:06+0000, Sergey Senozhatsky wrote:
> Moving to custom backends implementation gives us ability to
> have our own minimalistic and extendable API, and algorithms
> tunings becomes possible.
> 
> The list of compression backends is empty at this point,
> we will add backends in the followup patches.
> 
> Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> ---
>  drivers/block/zram/Kconfig    |  39 +--------
>  drivers/block/zram/zcomp.c    | 151 +++++++++++-----------------------
>  drivers/block/zram/zcomp.h    |  29 ++++---
>  drivers/block/zram/zram_drv.c |   9 +-
>  4 files changed, 76 insertions(+), 152 deletions(-)

<snip>

> --- a/drivers/block/zram/zcomp.h
> +++ b/drivers/block/zram/zcomp.h
> @@ -1,7 +1,4 @@
>  /* SPDX-License-Identifier: GPL-2.0-or-later */
> -/*
> - * Copyright (C) 2014 Sergey Senozhatsky.
> - */
>  
>  #ifndef _ZCOMP_H_
>  #define _ZCOMP_H_
> @@ -12,13 +9,26 @@ struct zcomp_strm {
>  	local_lock_t lock;
>  	/* compression/decompression buffer */
>  	void *buffer;
> -	struct crypto_comp *tfm;
> +	void *ctx;
> +};
> +
> +struct zcomp_ops {
> +	int (*compress)(void *ctx, const unsigned char *src, size_t src_len,
> +			unsigned char *dst, size_t *dst_len);
> +
> +	int (*decompress)(void *ctx, const unsigned char *src, size_t src_len,
> +			  unsigned char *dst, size_t dst_len);
> +
> +	void *(*create_ctx)(void);
> +	void (*destroy_ctx)(void *ctx);
> +
> +	const char *name;
>  };
>  
>  /* dynamic per-device compression frontend */
>  struct zcomp {
>  	struct zcomp_strm __percpu *stream;
> -	const char *name;
> +	struct zcomp_ops *ops;

If this is "const struct zcomp_ops *ops" then all the backend struct
zcomp_ops definitions could be constified, improving security.

"zcomp_ops" could also be added to scripts/const_structs.checkpatch,
but there probably won't be many of them anyways.

>  	struct hlist_node node;
>  };

<snip>

  reply	other threads:[~2024-07-06  7:51 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-06  4:56 [PATCHv5 00/23] zram: compression algorithms tunables Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 01/23] lib: zstd: export API needed for dictionary support Sergey Senozhatsky
2024-07-06  8:20   ` [PATCH v5 " Markus Elfring
2024-07-06  4:56 ` [PATCHv5 02/23] lib: lz4hc: export LZ4_resetStreamHC symbol Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 03/23] lib: zstd: fix null-deref in ZSTD_createCDict_advanced2() Sergey Senozhatsky
2024-07-06  7:20   ` [PATCH v5 " Markus Elfring
2024-07-06  4:56 ` [PATCHv5 04/23] zram: introduce custom comp backends API Sergey Senozhatsky
2024-07-06  7:50   ` Thomas Weißschuh [this message]
2024-07-07  1:31     ` Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 05/23] zram: add lzo and lzorle compression backends support Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 06/23] zram: add lz4 compression backend support Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 07/23] zram: add lz4hc " Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 08/23] zram: add zstd " Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 09/23] zram: pass estimated src size hint to zstd Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 10/23] zram: add zlib compression backend support Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 11/23] zram: add 842 " Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 12/23] zram: check that backends array has at least one backend Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 13/23] zram: introduce zcomp_params structure Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 14/23] zram: recalculate zstd compression params once Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 15/23] zram: extend comp_algorithm attr write handling Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 16/23] zram: add support for dict comp config Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 17/23] zram: introduce zcomp_req structure Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 18/23] zram: introduce zcomp_ctx structure Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 19/23] zram: move immutable comp params away from per-CPU context Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 20/23] zram: add dictionary support to lz4 Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 21/23] zram: add dictionary support to lz4hc Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 22/23] zram: add dictionary support to zstd backend Sergey Senozhatsky
2024-07-06  4:56 ` [PATCHv5 23/23] Documentation/zram: add documentation for algorithm parameters Sergey Senozhatsky
2024-07-06  5:01 ` [PATCHv5 00/23] zram: compression algorithms tunables Sergey Senozhatsky
2024-07-06  7:03 ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8fe873d4-b9c4-47ad-b779-e1012677011e@t-8ch.de \
    --to=linux@weissschuh.net \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=senozhatsky@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®