linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/memcontrol.c: speed up to force empty a memory cgroup
@ 2018-03-19  8:29 Li RongQing
  2018-03-19  8:53 ` Michal Hocko
  2018-03-23 10:34 ` Michal Hocko
  0 siblings, 2 replies; 17+ messages in thread
From: Li RongQing @ 2018-03-19  8:29 UTC (permalink / raw)
  To: linux-kernel, linux-mm; +Cc: cgroups, hannes, mhocko

mem_cgroup_force_empty() tries to free only 32 (SWAP_CLUSTER_MAX) pages
on each iteration, if a memory cgroup has lots of page cache, it will
take many iterations to empty all page cache, so increase the reclaimed
number per iteration to speed it up. same as in mem_cgroup_resize_limit()

a simple test show:

  $dd if=aaa  of=bbb  bs=1k count=3886080
  $rm -f bbb
  $time echo 100000000 >/cgroup/memory/test/memory.limit_in_bytes

Before: 0m0.252s ===> after: 0m0.178s

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 670e99b68aa6..8910d9e8e908 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2480,7 +2480,7 @@ static int mem_cgroup_resize_limit(struct mem_cgroup *memcg,
 		if (!ret)
 			break;
 
-		if (!try_to_free_mem_cgroup_pages(memcg, 1,
+		if (!try_to_free_mem_cgroup_pages(memcg, 1024,
 					GFP_KERNEL, !memsw)) {
 			ret = -EBUSY;
 			break;
@@ -2610,7 +2610,7 @@ static int mem_cgroup_force_empty(struct mem_cgroup *memcg)
 		if (signal_pending(current))
 			return -EINTR;
 
-		progress = try_to_free_mem_cgroup_pages(memcg, 1,
+		progress = try_to_free_mem_cgroup_pages(memcg, 1024,
 							GFP_KERNEL, true);
 		if (!progress) {
 			nr_retries--;
-- 
2.11.0

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

end of thread, other threads:[~2018-03-23 12:29 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19  8:29 [PATCH] mm/memcontrol.c: speed up to force empty a memory cgroup Li RongQing
2018-03-19  8:53 ` Michal Hocko
     [not found]   ` <2AD939572F25A448A3AE3CAEA61328C23745764B@BC-MAIL-M28.internal.baidu.com>
2018-03-19 10:37     ` 答复: " Michal Hocko
2018-03-19 10:51       ` 答复: " Li,Rongqing
2018-03-19 17:51         ` David Rientjes
2018-03-20  8:39           ` Michal Hocko
2018-03-20 20:29             ` David Rientjes
2018-03-20 22:08               ` Andrey Ryabinin
2018-03-20 22:15                 ` David Rientjes
2018-03-20 22:35                   ` Andrey Ryabinin
2018-03-20 22:45                     ` David Rientjes
2018-03-21  9:59                     ` Michal Hocko
2018-03-23  2:58         ` Li,Rongqing
2018-03-23 10:08           ` Michal Hocko
2018-03-23 12:04             ` 答复: " Li,Rongqing
2018-03-23 12:29               ` Michal Hocko
2018-03-23 10:34 ` Michal Hocko

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).