linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [v2 PATCH] mm: vmscan: correct nr_reclaimed for THP
@ 2019-05-10 16:23 Yang Shi
  2019-05-13  8:09 ` Michal Hocko
  0 siblings, 1 reply; 10+ messages in thread
From: Yang Shi @ 2019-05-10 16:23 UTC (permalink / raw)
  To: ying.huang, hannes, mhocko, mgorman, kirill.shutemov, hughd,
	shakeelb, william.kucharski, akpm
  Cc: yang.shi, linux-mm, linux-kernel

Since commit bd4c82c22c36 ("mm, THP, swap: delay splitting THP after
swapped out"), THP can be swapped out in a whole.  But, nr_reclaimed
still gets inc'ed by one even though a whole THP (512 pages) gets
swapped out.

This doesn't make too much sense to memory reclaim.  For example, direct
reclaim may just need reclaim SWAP_CLUSTER_MAX pages, reclaiming one THP
could fulfill it.  But, if nr_reclaimed is not increased correctly,
direct reclaim may just waste time to reclaim more pages,
SWAP_CLUSTER_MAX * 512 pages in worst case.

This change may result in more reclaimed pages than scanned pages showed
by /proc/vmstat since scanning one head page would reclaim 512 base pages.

Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Hugh Dickins <hughd@google.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
---
v2: Added Shakeel's Reviewed-by
    Use hpage_nr_pages instead of compound_order per Huang Ying and William Kucharski

 mm/vmscan.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index fd9de50..4226d6b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1446,7 +1446,11 @@ static unsigned long shrink_page_list(struct list_head *page_list,
 
 		unlock_page(page);
 free_it:
-		nr_reclaimed++;
+		/* 
+		 * THP may get swapped out in a whole, need account
+		 * all base pages.
+		 */
+		nr_reclaimed += hpage_nr_pages(page);
 
 		/*
 		 * Is there need to periodically free_page_list? It would
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-05-21  6:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-10 16:23 [v2 PATCH] mm: vmscan: correct nr_reclaimed for THP Yang Shi
2019-05-13  8:09 ` Michal Hocko
     [not found]   ` <c3c26c7a-748c-6090-67f4-3014bedea2e6@linux.alibaba.com>
2019-05-13 21:45     ` Michal Hocko
2019-05-14  4:36       ` Yang Shi
2019-05-14  6:20         ` Michal Hocko
2019-05-14 20:44           ` Yang Shi
2019-05-16 15:10             ` Johannes Weiner
2019-05-20  9:43               ` Yang Shi
2019-05-21  3:16                 ` Yang Shi
2019-05-21  6:54               ` Yang Shi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).