Received: by 10.213.65.68 with SMTP id h4csp3204020imn; Tue, 3 Apr 2018 00:13:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+SK6rU5AO1UTo3rTGnoOhkUHjwyk4RQpTBMr6qN/5ohXem7Oel0OSespiMLz9jQtsoxsKk X-Received: by 2002:a17:902:b617:: with SMTP id b23-v6mr12710771pls.191.1522739630892; Tue, 03 Apr 2018 00:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522739630; cv=none; d=google.com; s=arc-20160816; b=KeSKASTN8/PJEkEMBhbsOhuO6qeCW3GjdqyFQ2Xs9a+FgLHofW+IqV4siCb9IxsjHq 7RMLDWeM8iIcYfa74wZ7t2Q7e8B0dMbg/T7GDswsmEwS6CKEjWIOdCTmpeTGZHj9Mk7n 1ruflvnEreQLdxqXhDKMQDMCiAtgwZ3LhFG2THliu6y58L4OPRubq+E/8O5w+TcPyjG/ ASoZy7VdEEMtOe/dq6kgIdLqK8JhLL7sK+16hADixfDoGr95NbEbKWw04Sw6UrJqYpgZ 1uJKIcfMkob0EN6ACPmg4GEvzV5oSIYL2xC/4YWKmdusjQUhzX+cCJMR3udZAe7vGdsu gNUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:to:from :arc-authentication-results; bh=wrLIGWfT2YLxyFJEPOKSJCqNK4NIpAMVPWBAuN8JuD8=; b=EzhdSusDHloNUmWNM1Q6gweKYTLCJQQTp/A4BDhryUbMkbJdtt0S/mFyfmu0XFh2lB 1FnA34F0EtCIIU1slLT+qzWs4VMtHY7bCJbv4oBERd41kVCsgl2Cjjfx34knP0eEmhY8 FMLDtEyAg5rBD8+q2PJjHHlcnK6M98q2TZwL8IAOTDI4RAqUwha84tBo3HH4+WignC8t MI75XK9HmPEDMFuZMomrXrLpNr/uYBfocSRuG9+ASvva/2+L8y0XUAMe+A9E/2lr9Kmm 2IL4Kqy1d65s4eiPlImsv5tUIx9L/hCpf32ihwI/YeFZ3goX6qUt6+QEXHLpri1RZnyO lO6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si1519100pgs.430.2018.04.03.00.13.36; Tue, 03 Apr 2018 00:13:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753399AbeDCHMe (ORCPT + 99 others); Tue, 3 Apr 2018 03:12:34 -0400 Received: from mx137-tc.baidu.com ([61.135.168.137]:34967 "EHLO tc-sys-mailedm01.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752286AbeDCHMd (ORCPT ); Tue, 3 Apr 2018 03:12:33 -0400 Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm01.tc.baidu.com (Postfix) with ESMTP id EEFAF2040051; Tue, 3 Apr 2018 15:12:09 +0800 (CST) From: Li RongQing 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 Message-Id: <1522739529-5602-1-git-send-email-lirongqing@baidu.com> X-Mailer: git-send-email 1.7.10.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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