From: Li RongQing <lirongqing@baidu.com>
To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com,
cgroups@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] mm: avoid the unnecessary waiting when force empty a cgroup
Date: Tue, 3 Apr 2018 15:12:09 +0800 [thread overview]
Message-ID: <1522739529-5602-1-git-send-email-lirongqing@baidu.com> (raw)
The number of writeback and dirty page can be read out from memcg,
the unnecessary waiting can be avoided by these counts
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
mm/memcontrol.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 9ec024b862ac..5258651bd4ec 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2613,9 +2613,13 @@ static int mem_cgroup_force_empty(struct mem_cgroup *memcg)
progress = try_to_free_mem_cgroup_pages(memcg, 1,
GFP_KERNEL, true);
if (!progress) {
+ unsigned long num;
+
+ num = memcg_page_state(memcg, NR_WRITEBACK) +
+ memcg_page_state(memcg, NR_FILE_DIRTY);
nr_retries--;
- /* maybe some writeback is necessary */
- congestion_wait(BLK_RW_ASYNC, HZ/10);
+ if (num)
+ congestion_wait(BLK_RW_ASYNC, HZ/10);
}
}
--
2.11.0
next reply other threads:[~2018-04-03 7:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-03 7:12 Li RongQing [this message]
2018-04-03 8:05 ` Michal Hocko
2018-04-03 8:29 Li,Rongqing
2018-04-03 8:40 ` Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1522739529-5602-1-git-send-email-lirongqing@baidu.com \
--to=lirongqing@baidu.com \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=vdavydov.dev@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox