mm-entirely-remove-lru_add_drain-in-do_swap_page.patch removed from -mm tree
The quilt patch titled
Subject: mm: entirely remove lru_add_drain in do_swap_page
has been removed from the -mm tree. Its filename was
mm-entirely-remove-lru_add_drain-in-do_swap_page.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: "Barry Song (Xiaomi)" <[email protected]>
Subject: mm: entirely remove lru_add_drain in do_swap_page
Date: Thu, 2 Jul 2026 07:59:54 +0800
We are doing a lot of redundant lru_add_drain() calls in do_swap_page(), especially for synchronous I/O devices. For example, the test program below currently ends up draining lru_cache 100% of the time:
int main(int argc, char *argv[])
{
int i;
#define SIZE 100*1024*1024
while(1) {
volatile int *p = mmap(0, SIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
for (int i = 0; i < SIZE/sizeof(int); i++)
p[i] = i%64;
madvise((void *)p, SIZE, MADV_PAGEOUT);
for (int i = 0; i < SIZE/sizeof(int); i++)
p[i] = i%64;
munmap(p, SIZE);
}
return 0;
}Folio reuse now relies primarily on the exclusive hint, making lru_cache draining to drop the refcount in lru_cache largely irrelevant. For a kernel build with a minimal configuration running in a 1 GB memcg, this patch skips more than 43,000 redundant local LRU drains.
---
mm/memory.c | 10 ---------- 1 file changed, 10 deletions(-)
mm/memory.c renamed from mm/memory.c~mm-entirely-remove-lru_add_drain-in-do_swap_page +0 -10
@@ -4894,16 +4894,6 @@ vm_fault_t do_swap_page(struct vm_fault }else if (folio != swapcache) page =folio_page (folio,0 ); -/* -* If we want to map a page that's in the swapcache writable, we -* have to detect via the refcount if we're really the exclusive -* owner. Try removing the extra reference from the local LRU -* caches if required. -*/ -if ((vmf->flags &FAULT_FLAG_WRITE ) && - !folio_test_ksm (folio) && !folio_test_lru (folio)) -lru_add_drain (); -folio_throttle_swaprate (folio,GFP_KERNEL );/*
_
Patches currently in -mm which might be from [email protected] are
arm64-hugetlb-extend-batching-of-multiple-cont_pte-in-a-single-pte-setup.patch arm64-vmalloc-allow-arch_vmap_pte_range_map_size-to-batch-multiple-cont_pte.patch mm-vmalloc-extend-page-table-walk-to-support-larger-page_shift-sizes-and-eliminate-page-table-rewalk.patch mm-vmalloc-map-contiguous-pages-in-batches-for-vmap-if-possible.patch mm-vmalloc-align-vm_area-so-vmap-can-batch-mappings.patch