Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kanchana P. Sridhar" <kanchanapsridhar2026@gmail.com>,
	hannes@cmpxchg.org, yosry@kernel.org, nphamcs@gmail.com,
	chengming.zhou@linux.dev, akpm@linux-foundation.org,
	linux-mm@kvack.org, herbert@gondor.apana.org.au,
	davem@davemloft.net, linux-crypto@vger.kernel.org
Cc: rientjes@google.com, willy@infradead.org, senozhatsky@chromium.org
Subject: Re: [PATCH v5 7/9] mm: zswap: Store large folios in batches.
Date: Wed, 02 Dec 2026 05:38:37 +0000	[thread overview]
Message-ID: <sashiko-outbox-244915@kernel.org> (raw)
In-Reply-To: <20261201053711.8090-8-kanchanapsridhar2026@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] mm: zswap: signedness mismatch in min() in zswap_store() on
  32-bit
--

commit 33d59deafe5bd8836dd31d0cfe74c0ce9f35c05c
Author: Kanchana P. Sridhar <kanchanapsridhar2026@gmail.com>

mm: zswap: Store large folios in batches.

This commit replaces single-page stores in zswap with batched stores of up
to ZSWAP_MAX_BATCH_SIZE pages, allocating per-CPU destination buffers and
slab entries in batches.

> diff --git a/mm/zswap.c b/mm/zswap.c
> index c0c00696599b1..acfb29f3404b8 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -85,6 +85,9 @@ static bool zswap_pool_reached_full;
>  
>  #define ZSWAP_PARAM_UNSET ""
>  
> +/* Limit the batch size to limit per-CPU memory usage for dst buffers. */
> +#define ZSWAP_MAX_BATCH_SIZE 4U
> +
>  static int zswap_setup(void);

[ ... ]

> @@ -1620,10 +1728,14 @@ bool zswap_store(struct folio *folio)
>  	swp_entry_t swp = folio->swap;
>  	struct obj_cgroup *objcg = NULL;
>  	struct mem_cgroup *memcg = NULL;
> -	struct zswap_pool *pool;
> +	int nid = folio_nid(folio);
>  	bool ret = false;
> -	bool wb_enabled;
> -	long index;
> +	struct zswap_pool *pool;
> +	long start, end;
> +	struct zswap_store_context zc = {
> +		.folio = folio,
> +		.nid = nid,
> +	};

[ ... ]

> @@ -1658,11 +1770,22 @@ bool zswap_store(struct folio *folio)
>  	}
>  
>  	rcu_read_lock();
> -	wb_enabled = mem_cgroup_zswap_writeback_enabled(folio_memcg(folio));
> +	zc.wb_enabled = mem_cgroup_zswap_writeback_enabled(folio_memcg(folio));
>  	rcu_read_unlock();
>  
> -	for (index = 0; index < nr_pages; ++index) {
> -		if (!zswap_store_page(folio, index, objcg, pool, wb_enabled))
> +	/*
> +	 * For batching and non-batching compressors, store the folio in
> +	 * batches of ZSWAP_MAX_BATCH_SIZE, where the pages in the batch
> +	 * are compressed in batches of the compressor's batch_size. This gives
> +	 * better performance than invoking zswap_store_pages() per-page,
> +	 * due to cache locality of working set structures.
> +	 */
> +	for (start = 0; start < nr_pages; start += ZSWAP_MAX_BATCH_SIZE) {
> +		end = min(start + ZSWAP_MAX_BATCH_SIZE, nr_pages);

[Severity: Low]
Can min(start + ZSWAP_MAX_BATCH_SIZE, nr_pages) fail to build on 32-bit
architectures?

Because ZSWAP_MAX_BATCH_SIZE is unsigned int (4U) while start and nr_pages
are signed long, start + ZSWAP_MAX_BATCH_SIZE promotes to unsigned long on
32-bit builds, mixing unsigned long and signed long in min() and triggering
its signedness BUILD_BUG_ON_MSG when the compiler does not fold nr_pages >= 0.
Dropping the U suffix on ZSWAP_MAX_BATCH_SIZE (or using unsigned types for
start, end, and nr_pages) avoids the mismatch.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201053711.8090-1-kanchanapsridhar2026@gmail.com?part=7


  reply	other threads:[~2026-12-02  5:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  5:37 [PATCH v5 0/9] Batched zswap_store() framework with compression batching Kanchana P. Sridhar
2026-12-01  5:37 ` [PATCH v5 1/9] crypto: acomp - Define a unit_size in struct acomp_req to enable batching. mm: zswap: Set the unit size for zswap to PAGE_SIZE Kanchana P. Sridhar
2026-12-01  5:37 ` [PATCH v5 2/9] crypto: acomp - Add bit to indicate segmentation support Kanchana P. Sridhar
2026-12-01  5:37 ` [PATCH v5 3/9] crypto: acomp - Add trivial segmentation wrapper Kanchana P. Sridhar
2026-12-01  5:37 ` [PATCH v5 4/9] crypto: acomp - Add API to get a compression algorithm's batch-size Kanchana P. Sridhar
2026-12-01  5:37 ` [PATCH v5 5/9] mm: zswap: Store the folio's node id in the zswap_entry Kanchana P. Sridhar
2026-12-02  5:38   ` sashiko-bot
2026-12-01  5:37 ` [PATCH v5 6/9] mm: zswap: Obtain folio's wb_enabled status once in zswap_store() Kanchana P. Sridhar
2026-12-02  5:38   ` sashiko-bot
2026-12-01  5:37 ` [PATCH v5 7/9] mm: zswap: Store large folios in batches Kanchana P. Sridhar
2026-12-02  5:38   ` sashiko-bot [this message]
2026-12-01  5:37 ` [PATCH v5 8/9] mm: zswap: Refactor and optimize zswap_store_pages() batch operations Kanchana P. Sridhar
2026-12-01  5:37 ` [PATCH v5 9/9] mm: zswap: Batched zswap_compress() for storing large folios in batches Kanchana P. Sridhar
2026-12-02  5:38   ` sashiko-bot

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=sashiko-outbox-244915@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=chengming.zhou@linux.dev \
    --cc=davem@davemloft.net \
    --cc=hannes@cmpxchg.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=kanchanapsridhar2026@gmail.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=rientjes@google.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=senozhatsky@chromium.org \
    --cc=willy@infradead.org \
    --cc=yosry@kernel.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