linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosry.ahmed@linux.dev>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
	linux-mm@kvack.org
Subject: Re: [RFC PATCH 7/7] mm: zswap: Use acomp virtual address interface
Date: Thu, 27 Feb 2025 18:11:04 +0000	[thread overview]
Message-ID: <Z8CquB-BZrP5JFYg@google.com> (raw)
In-Reply-To: <153c340a52090f2ff82f8f066203186a932d3f99.1740651138.git.herbert@gondor.apana.org.au>

On Thu, Feb 27, 2025 at 06:15:09PM +0800, Herbert Xu wrote:
> Use the acomp virtual address interface.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

I can't speak to the rest of the series, but I like what this patch is
doing in zswap. Together with the recent zsmalloc changes, we should be
able to drop the alternative memcpy path completely, without needing to
use kmap_to_page() or removing the warning the highmem code.

Thanks for doing this!

> ---
>  mm/zswap.c | 23 ++++++++---------------
>  1 file changed, 8 insertions(+), 15 deletions(-)
> 
> diff --git a/mm/zswap.c b/mm/zswap.c
> index 6504174fbc6a..2b5a2398a9be 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -925,27 +925,20 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry,
>  			   struct zswap_pool *pool)
>  {
>  	struct crypto_acomp_ctx *acomp_ctx;
> -	struct scatterlist input, output;
>  	int comp_ret = 0, alloc_ret = 0;
>  	unsigned int dlen = PAGE_SIZE;
>  	unsigned long handle;
>  	struct zpool *zpool;
> +	const u8 *src;
>  	char *buf;
>  	gfp_t gfp;
>  	u8 *dst;
>  
>  	acomp_ctx = acomp_ctx_get_cpu_lock(pool);
> +	src = kmap_local_page(page);
>  	dst = acomp_ctx->buffer;
> -	sg_init_table(&input, 1);
> -	sg_set_page(&input, page, PAGE_SIZE, 0);
>  
> -	/*
> -	 * We need PAGE_SIZE * 2 here since there maybe over-compression case,
> -	 * and hardware-accelerators may won't check the dst buffer size, so
> -	 * giving the dst buffer with enough length to avoid buffer overflow.
> -	 */
> -	sg_init_one(&output, dst, PAGE_SIZE * 2);
> -	acomp_request_set_params(acomp_ctx->req, &input, &output, PAGE_SIZE, dlen);
> +	acomp_request_set_virt(acomp_ctx->req, src, dst, PAGE_SIZE, dlen);
>  
>  	/*
>  	 * it maybe looks a little bit silly that we send an asynchronous request,
> @@ -960,6 +953,7 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry,
>  	 * acomp instance, so multiple threads can do (de)compression in parallel.
>  	 */
>  	comp_ret = crypto_wait_req(crypto_acomp_compress(acomp_ctx->req), &acomp_ctx->wait);
> +	kunmap_local(src);
>  	dlen = acomp_ctx->req->dlen;
>  	if (comp_ret)
>  		goto unlock;
> @@ -994,9 +988,9 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry,
>  static void zswap_decompress(struct zswap_entry *entry, struct folio *folio)
>  {
>  	struct zpool *zpool = entry->pool->zpool;
> -	struct scatterlist input, output;
>  	struct crypto_acomp_ctx *acomp_ctx;
>  	u8 *src;
> +	u8 *dst;
>  
>  	acomp_ctx = acomp_ctx_get_cpu_lock(entry->pool);
>  	src = zpool_map_handle(zpool, entry->handle, ZPOOL_MM_RO);
> @@ -1016,11 +1010,10 @@ static void zswap_decompress(struct zswap_entry *entry, struct folio *folio)
>  		zpool_unmap_handle(zpool, entry->handle);
>  	}
>  
> -	sg_init_one(&input, src, entry->length);
> -	sg_init_table(&output, 1);
> -	sg_set_folio(&output, folio, PAGE_SIZE, 0);
> -	acomp_request_set_params(acomp_ctx->req, &input, &output, entry->length, PAGE_SIZE);
> +	dst = kmap_local_folio(folio, 0);
> +	acomp_request_set_virt(acomp_ctx->req, src, dst, entry->length, PAGE_SIZE);
>  	BUG_ON(crypto_wait_req(crypto_acomp_decompress(acomp_ctx->req), &acomp_ctx->wait));
> +	kunmap_local(dst);
>  	BUG_ON(acomp_ctx->req->dlen != PAGE_SIZE);
>  
>  	if (src != acomp_ctx->buffer)
> -- 
> 2.39.5
> 


  reply	other threads:[~2025-02-27 18:11 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27 10:14 [PATCH 0/7] crypto: acomp - Add request chaining and virtual address support Herbert Xu
2025-02-27 10:14 ` [PATCH 1/7] crypto: iaa - Test the correct request flag Herbert Xu
2025-02-27 10:14 ` [PATCH 2/7] crypto: acomp - Remove acomp request flags Herbert Xu
2025-02-27 10:15 ` [PATCH 3/7] crypto: acomp - Add request chaining and virtual addresses Herbert Xu
2025-02-27 18:33   ` Eric Biggers
2025-02-27 10:15 ` [PATCH 4/7] crypto: testmgr - Remove NULL dst acomp tests Herbert Xu
2025-02-27 10:15 ` [PATCH 5/7] crypto: scomp - Remove support for non-trivial SG lists Herbert Xu
2025-02-27 10:15 ` [PATCH 6/7] crypto: scomp - Add chaining and virtual address support Herbert Xu
2025-02-27 10:15 ` [RFC PATCH 7/7] mm: zswap: Use acomp virtual address interface Herbert Xu
2025-02-27 18:11   ` Yosry Ahmed [this message]
2025-02-27 18:38     ` Eric Biggers
2025-02-27 21:43       ` Yosry Ahmed
2025-02-28  8:13         ` Herbert Xu
2025-02-28  9:54           ` Herbert Xu
2025-02-28 15:56             ` Yosry Ahmed
2025-03-01  6:36               ` Herbert Xu
2025-03-01  7:03                 ` Herbert Xu
2025-03-03 20:17                   ` Yosry Ahmed
2025-03-04  3:29                     ` Herbert Xu
2025-03-04  4:30                       ` Yosry Ahmed
2025-03-04  6:10                         ` Herbert Xu
2025-03-04  8:33                           ` Sergey Senozhatsky
2025-03-04  8:42                             ` Herbert Xu
2025-03-04  8:45                               ` Sergey Senozhatsky
2025-03-04 13:19                           ` Sergey Senozhatsky
2025-03-04 20:47                             ` Yosry Ahmed
2025-03-05  3:45                               ` Herbert Xu
     [not found]                                 ` <Z8fssWOSw0kfggsM@google.com>
2025-03-05  7:41                                   ` Herbert Xu
2025-03-05 17:07                                     ` Nhat Pham
2025-03-06  2:48                                       ` Sergey Senozhatsky
2025-03-05  3:40                             ` Herbert Xu
     [not found]                               ` <Z8fsXZNgEbVkZrJP@google.com>
2025-03-05  7:46                                 ` Herbert Xu
2025-03-05 14:10                                   ` Herbert Xu
2025-03-05 16:25                                     ` Yosry Ahmed
2025-03-06  0:40                                       ` Herbert Xu
2025-03-06 16:58                                         ` Yosry Ahmed
2025-03-01  7:34       ` Herbert Xu
2025-03-01  7:38         ` Herbert Xu
2025-02-27 18:11 ` [PATCH 0/7] crypto: acomp - Add request chaining and virtual address support Yosry Ahmed
2025-02-28  9:02   ` Herbert Xu

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=Z8CquB-BZrP5JFYg@google.com \
    --to=yosry.ahmed@linux.dev \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-mm@kvack.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