linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/memcontrol.c: drains percpu charge caches in memory.reclaim
@ 2022-11-10  6:53 Lu Jialin
  2022-11-10 14:42 ` Michal Koutný
  0 siblings, 1 reply; 7+ messages in thread
From: Lu Jialin @ 2022-11-10  6:53 UTC (permalink / raw)
  To: Johannes Weiner, Andrew Morton, Michal Hocko, Roman Gushchin,
	Shakeel Butt, Muchun Song
  Cc: Lu Jialin, cgroups, linux-kernel, linux-mm

When user use memory.reclaim to reclaim memory, after drain percpu lru
caches, drain percpu charge caches for given memcg stock in the hope
of introducing more evictable pages.

Signed-off-by: Lu Jialin <lujialin4@huawei.com>
---
 mm/memcontrol.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 2d8549ae1b30..768091cc6a9a 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6593,10 +6593,13 @@ static ssize_t memory_reclaim(struct kernfs_open_file *of, char *buf,
 		/*
 		 * This is the final attempt, drain percpu lru caches in the
 		 * hope of introducing more evictable pages for
-		 * try_to_free_mem_cgroup_pages().
+		 * try_to_free_mem_cgroup_pages(). Also, drain all percpu
+		 * charge caches for given memcg.
 		 */
-		if (!nr_retries)
+		if (!nr_retries) {
 			lru_add_drain_all();
+			drain_all_stock(memcg);
+		}
 
 		reclaimed = try_to_free_mem_cgroup_pages(memcg,
 						nr_to_reclaim - nr_reclaimed,
-- 
2.17.1



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

end of thread, other threads:[~2022-11-11 20:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10  6:53 [PATCH] mm/memcontrol.c: drains percpu charge caches in memory.reclaim Lu Jialin
2022-11-10 14:42 ` Michal Koutný
2022-11-10 19:35   ` Yosry Ahmed
2022-11-10 19:45     ` Yosry Ahmed
2022-11-11 10:08     ` Michal Koutný
2022-11-11 18:24       ` Yosry Ahmed
2022-11-11 20:31         ` Johannes Weiner

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