Received: by 10.213.65.68 with SMTP id h4csp1353253imn; Mon, 19 Mar 2018 01:32:41 -0700 (PDT) X-Google-Smtp-Source: AG47ELuc7mDpd7h18AZPGqg/v0ZhyuodCRCR8cuWp+NnxUctFjYgstmH4gATcZOf6RHDFjfbdELT X-Received: by 10.99.178.6 with SMTP id x6mr8536228pge.98.1521448361112; Mon, 19 Mar 2018 01:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521448361; cv=none; d=google.com; s=arc-20160816; b=YThwaUelMdcDgwVHAa3P7LEuIgdbEw+/IvSx1tu0dBsmSTireeNBMnNlfQNl60fUXr sN89WDLcF9OrzVvEAcyya562AzxmIy/gsrkg+uq5xWxnB/7ebzVFnAo8f7xeEqrUPYRV cH7rW89m8/07ZhKoG9ETXnGXCR+z/Cm7O1LbBANcPN/Yo7yq53SUCcnU8ilGweA0HdbH 4RR1PrAf/SgFcr1iw6e3P/v0adsubGGv4exhTuRrwReGvshNGZ4fBhPVGr7ajHhLT5uM s5Sn9HKV2S7C39ccbpTb33NTsR0QnSQKXCXrQLWwyqN+XxuorPSPCZ7PUxuTf67o1SO3 /asA== 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:cc:to:from :arc-authentication-results; bh=DGOAGpapaPvzcup2TK2OzYjT6XNDbw2viRHlXFkIR+Q=; b=cif+eZisMuH17B/fbO0/EFWDpdlbTE7Cm7iHAyojYIkPl0l2+6GJC8Wo+z1uwueVhY 2exc3xM2NsP9lrvP61xPqPrtlPaIBpqQhcM3VghyYvbwcH3V2VOhRyw+odPlSSWKb2T5 mloewE4SbF+d308j1RBekiaYkHSpKrX/gz9ScgBWYhhcUzmhVEyjA0jjJCTGtekbNu/k rovmyi5gtdKPqdkWiBoBphx5hEqO/JHnw5ts+z9ZkGdJ1WL3T3hftqak3m+YuKfsOP3r WY4LXfx1T32FCyx/A2ChAno+0/PCQinPL7v3aSa+IrGrAwyM6bP+kxDZ7AnC2IfBpDge F2yw== 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 e7si9196779pgc.571.2018.03.19.01.32.26; Mon, 19 Mar 2018 01:32:41 -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 S932750AbeCSI3s (ORCPT + 99 others); Mon, 19 Mar 2018 04:29:48 -0400 Received: from mx133-tc.baidu.com ([61.135.168.133]:10521 "EHLO tc-sys-mailedm06.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932143AbeCSI3n (ORCPT ); Mon, 19 Mar 2018 04:29:43 -0400 Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm06.tc.baidu.com (Postfix) with ESMTP id 44EC8263C004; Mon, 19 Mar 2018 16:29:30 +0800 (CST) From: Li RongQing To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: cgroups@vger.kernel.org, hannes@cmpxchg.org, mhocko@kernel.org Subject: [PATCH] mm/memcontrol.c: speed up to force empty a memory cgroup Date: Mon, 19 Mar 2018 16:29:30 +0800 Message-Id: <1521448170-19482-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 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 --- 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