linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: fix draining remote pageset
@ 2023-08-11  9:08 Huang Ying
  2023-08-11  9:35 ` Michal Hocko
  0 siblings, 1 reply; 16+ messages in thread
From: Huang Ying @ 2023-08-11  9:08 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, linux-kernel, Huang Ying, Christoph Lameter,
	Mel Gorman, Vlastimil Babka, Michal Hocko

If there is no memory allocation/freeing in the remote pageset after
some time (3 seconds for now), the remote pageset will be drained to
avoid memory wastage.

But in the current implementation, vmstat updater worker may not be
re-queued when we are waiting for the timeout (pcp->expire != 0) if
there are no vmstat changes, for example, when CPU goes idle.

This is fixed via guaranteeing that the vmstat updater worker will
always be re-queued when we are waiting for the timeout.

We can reproduce the bug via allocating/freeing pages from remote
node, then go idle.  And the patch can fix it.

Fixes: 7cc36bbddde5 ("vmstat: on-demand vmstat workers V8")
Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Michal Hocko <mhocko@kernel.org>
---
 mm/vmstat.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index b731d57996c5..111118741abf 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -856,8 +856,10 @@ static int refresh_cpu_vm_stats(bool do_pagesets)
 				continue;
 			}
 
-			if (__this_cpu_dec_return(pcp->expire))
+			if (__this_cpu_dec_return(pcp->expire)) {
+				changes++;
 				continue;
+			}
 
 			if (__this_cpu_read(pcp->count)) {
 				drain_zone_pages(zone, this_cpu_ptr(pcp));
-- 
2.39.2



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

end of thread, other threads:[~2023-09-06  4:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-11  9:08 [PATCH] mm: fix draining remote pageset Huang Ying
2023-08-11  9:35 ` Michal Hocko
2023-08-14  1:59   ` Huang, Ying
2023-08-16  6:49     ` Michal Hocko
2023-08-16  7:08       ` Huang, Ying
2023-08-16 20:23         ` Lameter, Christopher
2023-08-21  7:55         ` Michal Hocko
2023-08-21  8:30           ` Huang, Ying
2023-08-21  9:27             ` Michal Hocko
2023-08-21 22:31               ` Huang, Ying
2023-08-22  8:09                 ` Michal Hocko
2023-08-25 17:06                   ` Lameter, Christopher
2023-08-29  6:08                     ` Huang, Ying
2023-08-29 18:05                       ` Lameter, Christopher
2023-09-05 16:52                     ` Vlastimil Babka
2023-09-06  4:17                       ` Huang, Ying

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox