linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][RFC] fs/writeback: only do memory cgroup related writeback
@ 2018-07-02  7:06 Li RongQing
  0 siblings, 0 replies; only message in thread
From: Li RongQing @ 2018-07-02  7:06 UTC (permalink / raw)
  To: linux-mm, linux-fsdevel

When a mechine has hundreds of memory cgroups, and some cgroups
generate more or less dirty pages, but a cgroup of them has lots
of memory pressure and always tries to reclaim dirty page, then it
will trigger all cgroups to writeback, which is less efficient,
since other cgroups can wait more time to merge write request.

so replace the full flush with flushing writeback of memory cgroup
whose tasks tries to reclaim memory and trigger writeback

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 fs/fs-writeback.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index abafc9bd4622..75adf7343666 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -1976,8 +1976,20 @@ static void __wakeup_flusher_threads_bdi(struct backing_dev_info *bdi,
 	if (!bdi_has_dirty_io(bdi))
 		return;
 
-	list_for_each_entry_rcu(wb, &bdi->wb_list, bdi_node)
-		wb_start_writeback(wb, reason);
+	list_for_each_entry_rcu(wb, &bdi->wb_list, bdi_node) {
+#ifdef CONFIG_CGROUP_WRITEBACK
+		if (reason == WB_REASON_VMSCAN) {
+			struct cgroup_subsys_state *memcg_css;
+
+			memcg_css = task_css(current, memory_cgrp_id);
+			if (!memcg_css->parent || memcg_css == wb->memcg_css)
+				wb_start_writeback(wb, reason);
+		}
+		else
+#endif
+			wb_start_writeback(wb, reason);
+
+	}
 }
 
 void wakeup_flusher_threads_bdi(struct backing_dev_info *bdi,
-- 
2.16.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-07-02  7:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-02  7:06 [PATCH][RFC] fs/writeback: only do memory cgroup related writeback Li RongQing

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