History

mm: deactivations shouldn't bias the LRU balance

Operations like MADV_FREE, FADV_DONTNEED etc. currently move any affected active pages to the inactive list to accelerate their reclaim (good) but also steer page reclaim toward that LRU type, or away from the other (bad). The reason why this is undesirable is that such operations are not part of the regular page aging cycle, and rather a fluke that doesn't say much about the remaining pages on that list; they might all be in heavy use, and once the chunk of easy victims has been purged, the VM continues to apply elevated pressure on those remaining hot pages. The other LRU, meanwhile, might have easily reclaimable pages, and there was never a need to steer away from it in the first place. As the previous patch outlined, we should focus on recording actually observed cost to steer the balance rather than speculating about the potential value of one LRU list over the other. In that spirit, leave explicitely deactivated pages to the LRU algorithm to pick up, and let rotations decide which list is the easiest to reclaim. [cai@lca.pw: fix set-but-not-used warning] Link: http://lkml.kernel.org/r/20200522133335.GA624@Qians-MacBook-Air.local Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Minchan Kim <minchan@kernel.org> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Rik van Riel <riel@surriel.com> Cc: Qian Cai <cai@lca.pw> Link: http://lkml.kernel.org/r/20200520232525.798933-10-hannes@cmpxchg.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Johannes Weiner committed 6 years ago

Commit fbbb6021 parent 1431d4d1 file · +1 −6Browse files

Unified · Split

mm/swap.c+1−6
@@ -498,7 +498,7 @@ void lru_cache_add_active_or_unevictable(struct page *page, · 497 unmodified lines
498static void lru_deactivate_file_fn(struct page *page, struct lruvec *lruvec,498static void lru_deactivate_file_fn(struct page *page, struct lruvec *lruvec,
499 void *arg)499 void *arg)
500{500{
501 int lru, file;501 int lru;
502 bool active;502 bool active;
503 503
504 if (!PageLRU(page))504 if (!PageLRU(page))
@@ -512,7 +512,6 @@ static void lru_deactivate_file_fn(struct page *page, struct lruvec *lruvec, · 7 unmodified lines
512 return;512 return;
513 513
514 active = PageActive(page);514 active = PageActive(page);
515 file = page_is_file_lru(page);
516 lru = page_lru_base_type(page);515 lru = page_lru_base_type(page);
517 516
518 del_page_from_lru_list(page, lruvec, lru + active);517 del_page_from_lru_list(page, lruvec, lru + active);
@@ -538,14 +537,12 @@ static void lru_deactivate_file_fn(struct page *page, struct lruvec *lruvec, · 19 unmodified lines
538 537
539 if (active)538 if (active)
540 __count_vm_event(PGDEACTIVATE);539 __count_vm_event(PGDEACTIVATE);
541 lru_note_cost(lruvec, !file, hpage_nr_pages(page));
542}540}
543 541
544static void lru_deactivate_fn(struct page *page, struct lruvec *lruvec,542static void lru_deactivate_fn(struct page *page, struct lruvec *lruvec,
545 void *arg)543 void *arg)
546{544{
547 if (PageLRU(page) && PageActive(page) && !PageUnevictable(page)) {545 if (PageLRU(page) && PageActive(page) && !PageUnevictable(page)) {
548 int file = page_is_file_lru(page);
549 int lru = page_lru_base_type(page);546 int lru = page_lru_base_type(page);
550 547
551 del_page_from_lru_list(page, lruvec, lru + LRU_ACTIVE);548 del_page_from_lru_list(page, lruvec, lru + LRU_ACTIVE);
@@ -554,7 +551,6 @@ static void lru_deactivate_fn(struct page *page, struct lruvec *lruvec, · 2 unmodified lines
554 add_page_to_lru_list(page, lruvec, lru);551 add_page_to_lru_list(page, lruvec, lru);
555 552
556 __count_vm_events(PGDEACTIVATE, hpage_nr_pages(page));553 __count_vm_events(PGDEACTIVATE, hpage_nr_pages(page));
557 lru_note_cost(lruvec, !file, hpage_nr_pages(page));
558 }554 }
559}555}
560 556
@@ -579,7 +575,6 @@ static void lru_lazyfree_fn(struct page *page, struct lruvec *lruvec, · 18 unmodified lines
579 575
580 __count_vm_events(PGLAZYFREE, hpage_nr_pages(page));576 __count_vm_events(PGLAZYFREE, hpage_nr_pages(page));
581 count_memcg_page_event(page, PGLAZYFREE);577 count_memcg_page_event(page, PGLAZYFREE);
582 lru_note_cost(lruvec, 0, hpage_nr_pages(page));
583 }578 }
584}579}
585 580

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t