Re: [RFC PATCH 3/3] mm: entirely remove lru_add_drain in do_swap_page
From: Shakeel Butt
Date: Thu Jun 11 2026 - 14:41:02 EST
On Thu, Jun 11, 2026 at 06:51:24PM +0800, Barry Song (Xiaomi) wrote:
> 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.
>
> Signed-off-by: Barry Song (Xiaomi) <baohua@xxxxxxxxxx>
Acked-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>