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 5/9] mm: zswap: Store the folio's node id in the zswap_entry.
Date: Wed, 02 Dec 2026 05:38:35 +0000 [thread overview]
Message-ID: <sashiko-outbox-244913@kernel.org> (raw)
In-Reply-To: <20261201053711.8090-6-kanchanapsridhar2026@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] mm: zswap: shrink_memcg() skips non-N_NORMAL_MEMORY nodes in
zswap_list_lru
--
commit 3dca6b735f1c7e1dee1dc2d9901ad7cbacbdefc6
Author: Kanchana P. Sridhar <kanchanapsridhar2026@gmail.com>
mm: zswap: Store the folio's node id in the zswap_entry.
This commit stores the folio's NUMA node ID in struct zswap_entry for
list_lru indexing and makes zswap_entry slab allocations node-agnostic.
> diff --git a/mm/zswap.c b/mm/zswap.c
> index 9ee20b576eff8..cdca497ef8dbb 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
[ ... ]
> @@ -680,14 +685,8 @@ static int zswap_enabled_param_set(const char *val,
> * lru functions
> **********************************/
>
> -static inline int entry_to_nid(struct zswap_entry *entry)
> -{
> - return page_to_nid(virt_to_page(entry));
> -}
> -
> static void zswap_lru_add(struct zswap_entry *entry)
> {
> - int nid = entry_to_nid(entry);
> struct mem_cgroup *memcg;
>
> /*
> @@ -704,19 +703,18 @@ static void zswap_lru_add(struct zswap_entry *entry)
> rcu_read_lock();
> memcg = obj_cgroup_memcg(entry->objcg);
> /* will always succeed */
> - list_lru_add(&zswap_list_lru, &entry->lru, nid, memcg);
> + list_lru_add(&zswap_list_lru, &entry->lru, entry->nid, memcg);
> rcu_read_unlock();
> }
[ ... ]
> @@ -1537,9 +1536,10 @@ static bool zswap_store_page(struct folio *folio, long index,
> {
> swp_entry_t page_swpentry = folio_swap_entry(folio, index);
> struct zswap_entry *entry, *old;
> + int nid = folio_nid(folio);
>
> /* allocate entry */
> - entry = zswap_entry_cache_alloc(GFP_KERNEL, folio_nid(folio));
> + entry = zswap_entry_cache_alloc(GFP_KERNEL);
> if (!entry) {
> zswap_reject_kmemcache_fail++;
> return false;
> @@ -1554,6 +1554,7 @@ static bool zswap_store_page(struct folio *folio, long index,
> * to an unrelated live pool.
> */
> entry->pool_idx = pool->idx;
> + entry->nid = nid;
[Severity: Medium]
Can shrink_memcg() miss zswap entries queued on nodes without normal
memory?
Previously, entry_to_nid() derived the list_lru node ID from the
GFP_KERNEL slab page backing struct zswap_entry, so entries were always
queued on a node in N_NORMAL_MEMORY. Now entry->nid is set to
folio_nid(folio), which for movable user folios can be a node in N_MEMORY
that has only ZONE_MOVABLE (such as a CXL memory-tier node or hotplugged
movable node) and is not in N_NORMAL_MEMORY.
However, shrink_memcg() only walks N_NORMAL_MEMORY nodes:
mm/zswap.c:shrink_memcg() {
...
for_each_node_state(nid, N_NORMAL_MEMORY) {
unsigned long nr_to_walk = SWAP_CLUSTER_MAX;
shrunk += list_lru_walk_one(&zswap_list_lru, nid, memcg,
&shrink_memcg_cb, &ctl, &nr_to_walk);
scanned += SWAP_CLUSTER_MAX - nr_to_walk;
}
...
}
As a result, both per-memcg and global zswap pool limit reclaim in
shrink_memcg() will skip entries originating from non-N_NORMAL_MEMORY
nodes. Should shrink_memcg() iterate over N_MEMORY instead?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201053711.8090-1-kanchanapsridhar2026@gmail.com?part=5
next prev parent 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 [this message]
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
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-244913@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