diff options
| author | Alexandre Ghiti <alex@ghiti.fr> | 2026-09-21 17:13:02 +0200 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-10-12 21:26:21 -0700 |
| commit | 4154a1cf2f70ec542c4e24355b43ddaff32c31d6 (patch) | |
| tree | e56f92541d8ddf1ef366896b04630c36160ea38d /tools/perf/scripts/python/stackcollapse.py | |
| parent | d8020965b2f841fc5d71488c4261864ee9cbbec2 (diff) | |
mm: swap: move LRU insertion out of the swap cache allocator
Patch series "mm: zswap: free cold writeback folios promptly", v6.
When zswap writes an entry back, it allocates an order-0 swap cache folio,
decompresses into it, and issues the write. The folio is cold by
construction, yet today it is left on the LRU for page reclaim to find and
free later. That wastes a reclaim scan and keeps cold memory resident
longer than necessary.
Rather than implement this in zswap, extend the existing dropbehind
mechanism to swap cache folios and have zswap opt into it (Yosry). A
PG_dropbehind folio is already dropped from its cache once writeback
completes instead of being left for reclaim; for a swap cache folio that
"drop" is removing it from the swap cache.
Patch 1 - move LRU insertion out of the swap cache allocator into its
callers, so zswap writeback can allocate off the LRU.
Patch 2 - drop dropbehind swap cache folios on writeback completion.
Patch 3 - zswap allocates its writeback folio off the LRU and marks it
dropbehind, opting into the mechanism above.
This patch (of 3):
This is a preparatory patch.
swap_cache_alloc_folio() adds the new folio to the LRU itself, which
leaves its callers no way to act on the folio before it becomes visible
to reclaim. Two users need exactly that:
- moving the refault evaluation out of the swap cache folio allocation
requires it to happen before folio_add_lru(): that consumes PG_active
to file the folio on the inactive or the active list, and under MGLRU
it also reads PG_workingset to pick the generation. Setting either
flag afterwards does not move the folio;
- zswap writeback dropbehind needs the buffer folio to stay off the LRU
entirely, as the per-CPU LRU batch would hold a reference on it and
keep remove_mapping() from freeing it once writeback completes.
Defer the LRU insertion to the callers and rename the helper to
__swap_cache_alloc_folio(): each caller adds the folio right after the
allocation, so there is no functional change intended.
Link: https://lore.kernel.org/20260921151306.625134-1-alex@ghiti.fr
Link: https://lore.kernel.org/20260921151306.625134-2-alex@ghiti.fr
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Kairui Song <kasong@tencent.com>
Reviewed-by: Kairui Song <kasong@tencent.com>
Reviewed-by: Nhat Pham <nphamcs@gmail.com>
Reviewed-by: Kunwu Chan <kunwu.chan@gmail.com>
Acked-by: Usama Arif <usama.arif@linux.dev>
Reviewed-by: Barry Song <baohua@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Baoquan He <baoquan.he@linux.dev>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Chis Li <chrisl@kernel.org> (Google)
Cc: Christian Brauner (Amutable) <brauner@kernel.org>
Cc: "David Hildenbrand (arm)" <david@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>
Cc: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Qi Zheng <qi.zheng@linux.dev>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Tal Zussman <tz2294@columbia.edu>
Cc: Wei Xu <weixugc@google.com>
Cc: Yosry Ahmed <yosry@kernel.org>
Cc: Youngjun Park <youngjun.park@lge.com>
Cc: Yuanchu Xie <yuanchu@google.com>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions
