mm: move MADV_FREE pages into LRU_INACTIVE_FILE list
Subsystems (5)
[email protected]
maintainerPATCH 20/102 mm: move MADV_FREE pages into LRU_INACTIVE_FILE list
From: Shaohua Li <[email protected]>
Subject: mm: move MADV_FREE pages into LRU_INACTIVE_FILE list
madv()'s MADV_FREE indicate pages are 'lazyfree'. They are still anonymous pages, but they can be freed without pageout. To distinguish these from normal anonymous pages, we clear their SwapBacked flag.
MADV_FREE pages could be freed without pageout, so they pretty much like used once file pages. For such pages, we'd like to reclaim them once there is memory pressure. Also it might be unfair reclaiming MADV_FREE pages always before used once file pages and we definitively want to reclaim the pages before other anonymous and file pages.
To speed up MADV_FREE pages reclaim, we put the pages into LRU_INACTIVE_FILE list. The rationale is LRU_INACTIVE_FILE list is tiny nowadays and should be full of used once file pages. Reclaiming MADV_FREE pages will not have much interfere of anonymous and active file pages. And the inactive file pages and MADV_FREE pages will be reclaimed according to their age, so we don't reclaim too many MADV_FREE pages too. Putting the MADV_FREE pages into LRU_INACTIVE_FILE_LIST also means we can reclaim the pages without swap support. This idea is suggested by Johannes.
This patch doesn't move MADV_FREE pages to LRU_INACTIVE_FILE list yet to avoid bisect failure, next patch will do it.
The patch is based on Minchan's original patch.
---
include/linux/swap.h | 2 - include/linux/vm_event_item.h | 2 - mm/huge_memory.c | 3 - mm/madvise.c | 2 - mm/swap.c | 49 ++++++++++++++++++-------------- mm/vmstat.c | 1 6 files changed, 31 insertions(+), 28 deletions(-)
include/linux/swap.h renamed from include/linux/swap.h~mm-move-madv_free-pages-into-lru_inactive_file-list +1 -1
@@ -279,7 +279,7 @@ extern void lru_add_drain_cpu(int cpu);extern void lru_add_drain_all (void );extern void rotate_reclaimable_page (struct page *page);extern void deactivate_file_page (struct page *page); -extern void deactivate_page (struct page *page); +extern void mark_page_lazyfree (struct page *page);extern void swap_setup (void );extern void add_page_to_unevictable_list (struct page *page);
include/linux/vm_event_item.h renamed from include/linux/vm_event_item.h~mm-move-madv_free-pages-into-lru_inactive_file-list +1 -1
@@ -25,7 +25,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSFOR_ALL_ZONES (PGALLOC ),FOR_ALL_ZONES (ALLOCSTALL ),FOR_ALL_ZONES (PGSCAN_SKIP ), -PGFREE ,PGACTIVATE ,PGDEACTIVATE , +PGFREE ,PGACTIVATE ,PGDEACTIVATE ,PGLAZYFREE ,PGFAULT ,PGMAJFAULT ,PGLAZYFREED , PGREFILL,
mm/huge_memory.c renamed from mm/huge_memory.c~mm-move-madv_free-pages-into-lru_inactive_file-list +0 -3
@@ -1564,9 +1564,6 @@ bool madvise_free_huge_pmd(struct mmu_gaClearPageDirty (page);unlock_page (page); -if (PageActive (page)) -deactivate_page (page); -if (pmd_young (orig_pmd) ||pmd_dirty (orig_pmd)) {pmdp_invalidate (vma, addr, pmd); orig_pmd =pmd_mkold (orig_pmd);
mm/madvise.c renamed from mm/madvise.c~mm-move-madv_free-pages-into-lru_inactive_file-list +0 -2
@@ -411,8 +411,6 @@ static int madvise_free_pte_range(pmd_t ptent =pte_mkold (ptent); ptent =pte_mkclean (ptent);set_pte_at (mm, addr, pte, ptent); -if (PageActive (page)) -deactivate_page (page);tlb_remove_tlb_entry (tlb, pte, addr); } }
mm/swap.c renamed from mm/swap.c~mm-move-madv_free-pages-into-lru_inactive_file-list +28 -21
93 lines not on this page · raw message
mm/vmstat.c renamed from mm/vmstat.c~mm-move-madv_free-pages-into-lru_inactive_file-list +1 -0
@@ -991,6 +991,7 @@ const char * const vmstat_text[] = {"pgfree" ,"pgactivate" ,"pgdeactivate" , +"pglazyfree" ,"pgfault" , "pgmajfault",
_