From patchwork Mon Jul 2 07:06:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li,Rongqing" X-Patchwork-Id: 10500553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 599666035E for ; Mon, 2 Jul 2018 07:15:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43E9F287A8 for ; Mon, 2 Jul 2018 07:15:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37A70287B1; Mon, 2 Jul 2018 07:15:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8086A287A8 for ; Mon, 2 Jul 2018 07:15:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753300AbeGBHPc (ORCPT ); Mon, 2 Jul 2018 03:15:32 -0400 Received: from mx57.baidu.com ([61.135.168.57]:58115 "EHLO tc-sys-mailedm03.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753088AbeGBHPb (ORCPT ); Mon, 2 Jul 2018 03:15:31 -0400 Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm03.tc.baidu.com (Postfix) with ESMTP id DD973624007; Mon, 2 Jul 2018 15:06:25 +0800 (CST) From: Li RongQing To: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: [PATCH][RFC] fs/writeback: only do memory cgroup related writeback Date: Mon, 2 Jul 2018 15:06:25 +0800 Message-Id: <1530515185-15354-1-git-send-email-lirongqing@baidu.com> X-Mailer: git-send-email 1.7.10.1 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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,