summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorAlexandre Ghiti <alex@ghiti.fr>2026-09-21 17:13:03 +0200
committerAndrew Morton <akpm@linux-foundation.org>2026-09-29 23:13:37 -0700
commit771da70595ad9a20dc047168c46c439f3262bd5d (patch)
tree78258167b9f74feaa67baa642507fdfcb5d10088 /include/linux
parent12445795cf4208cc59cce5ae979651f6018f14d0 (diff)
downloadlinux-next-771da70595ad9a20dc047168c46c439f3262bd5d.tar.gz
linux-next-771da70595ad9a20dc047168c46c439f3262bd5d.zip
mm: swap: drop dropbehind swap cache folios on writeback completion
A PG_dropbehind folio is dropped from its cache once writeback completes rather than left for reclaim to find later; this is implemented for file folios in folio_end_dropbehind(). Extend it to swap cache folios. The drop blocks on the folio lock, so it cannot run in interrupt context. Set BIO_COMPLETE_IN_TASK on the write, as the file dropbehind paths do, and drop the folio directly from folio_end_writeback(). It has to block rather than trylock: the folio is off the LRU, so skipping it would leave it in the swap cache with nothing able to reclaim it, and it cannot be put back while another thread holds its lock. Link: https://lore.kernel.org/20260921151306.625134-3-alex@ghiti.fr Signed-off-by: Alexandre Ghiti <alex@ghiti.fr> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Suggested-by: Yosry Ahmed <yosry@kernel.org> Suggested-by: Johannes Weiner <hannes@cmpxchg.org> Suggested-by: Nhat Pham <nphamcs@gmail.com> Reviewed-by: Nhat Pham <nphamcs@gmail.com> Reviewed-by: Kunwu Chan <kunwu.chan@gmail.com> 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> Cc: Christian Brauner (Amutable) <brauner@kernel.org> Cc: "David Hildenbrand (arm)" <david@kernel.org> Cc: Jan Kara <jack@suse.cz> Cc: Kairui Song <kasong@tencent.com> 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: Usama Arif <usama.arif@linux.dev> Cc: Wei Xu <weixugc@google.com> Cc: Youngjun Park <youngjun.park@lge.com> Cc: Yuanchu Xie <yuanchu@google.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/swap.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 82f0bfec611f..cb434cccd653 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -336,6 +336,9 @@ static inline bool lru_cache_disabled(void)
extern unsigned long shrink_all_memory(unsigned long nr_pages);
long remove_mapping(struct address_space *mapping, struct folio *folio);
+long remove_mapping_set_shadow(struct address_space *mapping,
+ struct folio *folio,
+ struct mem_cgroup *target_memcg);
#if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
extern int reclaim_register_node(struct node *node);
@@ -421,6 +424,8 @@ void swap_put_entries_direct(swp_entry_t entry, int nr);
*/
bool folio_free_swap(struct folio *folio);
+void swap_writeback_dropbehind_folio(struct folio *folio);
+
/* Allocate / free (hibernation) exclusive entries */
swp_entry_t swap_alloc_hibernation_slot(int type);
void swap_free_hibernation_slot(swp_entry_t entry);
@@ -431,6 +436,7 @@ static inline void put_swap_device(struct swap_info_struct *si)
}
#else /* CONFIG_SWAP */
+static inline void swap_writeback_dropbehind_folio(struct folio *folio) {}
static inline struct swap_info_struct *get_swap_device(swp_entry_t entry)
{
return NULL;