From patchwork Wed Jan 2 20:05:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10746669 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEFB2746 for ; Wed, 2 Jan 2019 20:06:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE63327FA9 for ; Wed, 2 Jan 2019 20:06:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D155828415; Wed, 2 Jan 2019 20:06:14 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F21F27FA9 for ; Wed, 2 Jan 2019 20:06:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A7EA8E0040; Wed, 2 Jan 2019 15:06:07 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3572C8E0002; Wed, 2 Jan 2019 15:06:07 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26E198E0040; Wed, 2 Jan 2019 15:06:07 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it1-f198.google.com (mail-it1-f198.google.com [209.85.166.198]) by kanga.kvack.org (Postfix) with ESMTP id F17018E0002 for ; Wed, 2 Jan 2019 15:06:06 -0500 (EST) Received: by mail-it1-f198.google.com with SMTP id j3so33942199itf.5 for ; Wed, 02 Jan 2019 12:06:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=JdAWqiDAvY8Cc/wEwjmqPos9s7bue0flAgOxWhLn+sk=; b=WRQGVIYNTOEYVOTYeb11VVi88W73A4rdoTJu918NCA9QqImHQoVNTSLtpWAWYQnSwg PCv6N0MX2DtvP6ELFUdmb/D3lN33f6J8McaJGDbsyy6k1egAVztdUvbGP9npMu+Gdytp RuLTUctVobFOpeB9fY5JrqA/ESYbH5CC9YJWEBbpdqYOIglf6PFhj3FTkPY7D1kDJNr2 Q8htL4MnfKeF9qDBtFFD8iA6KqQ02uCJ/cPyi4idWOcOP/d8OnvbGRSWSDRgdAr9dr+/ 6D0VW9/P8XPBhsPggtY4kW2rKE2pmv+QFIn6dJwYtLudETBnH7+v88UCbKrGU6Qi3cz3 40Zw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: AA+aEWYDjK8dROo91A7XPXkXE6P0KzchqNoamanviribfAmL0/2y2cdD xw8Ivang0Pw0L9lia7SF8NC2rEH+d4oassHUX6HcMrGapOVFJL2c+UA0oDDYTBUuloCDfmdm39B dXiAUCAM3EH6ST9HNqPurfPkrFcQy9AonvL15kIzAYe26vBv+vDXML/1vWFZtMs1anA== X-Received: by 2002:a02:b697:: with SMTP id i23mr29527617jam.119.1546459566770; Wed, 02 Jan 2019 12:06:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/X9js+MoazpZ3edmc60wGcLglaR3S/SHYG6LyJO2uhpkcRYPXxCcFQSiZGRE8K+jXKkkz/U X-Received: by 2002:a02:b697:: with SMTP id i23mr29527591jam.119.1546459566029; Wed, 02 Jan 2019 12:06:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546459565; cv=none; d=google.com; s=arc-20160816; b=Suu38JwNX0W/hlzUYGHgIrskgLQAHOgAjzTIoJ/nyEzjiajHHF+zbODnbBJlEpbuBd LrVKLkWKiBcANGhuVp7elvACYq/Q0Te4BhioyvLkqZ60cveo4DP/5AsuNibsPDc6m8z2 m3lGruoRhvEFMiLiSAbM7HH6MjSgqaflW59+V/0ln+080vXRVBj2pz5Lc7PVFnbnk0V/ RlvckxwbTbf96QGyw3W8km0FAVGZogeWuj2tG04EsZJiML/BxhA0+HhHJ7YQyAWtbP6u a+gofnvS1rOVCNMbJJ/lQqG0BYzN7WafUDwcDzfE5djW3lcPjLKysBhisMkCu+BCWHLw sMZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=JdAWqiDAvY8Cc/wEwjmqPos9s7bue0flAgOxWhLn+sk=; b=aL0I1QYYnktc2/5jne99/03I+coqwMszC9LZlusa/uzz8qiZB31J2xim/z3YTrjt0+ G8cqfz2y9yTI6IArkHoiJ3haa1MPtrpmF6VzUJust50bysfrVZa0q1In0i0bXUK0OH0E GqGmVR9txjKNuSflkBvjKGF9Fhd4hTJE9YClPF4gdIi97nWciwvChWHVR+MSjVo0Fhn7 3l3+gQIJG6iUmitPrBwaQan1LpaOdrs1WPJT6X/NSnVRVktgUAuaQ0JD3BS2DtSQVv2n dIjiAMx/us5LmDjvoEYCap9o6wSKSWdqbm3i6OQan304+CdgL21hUDuU/FRv0an+t7jv znTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com. [115.124.30.133]) by mx.google.com with ESMTPS id x17si76662itj.18.2019.01.02.12.06.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jan 2019 12:06:05 -0800 (PST) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) client-ip=115.124.30.133; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.133 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01353;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0THOz2-._1546459534; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0THOz2-._1546459534) by smtp.aliyun-inc.com(127.0.0.1); Thu, 03 Jan 2019 04:05:41 +0800 From: Yang Shi To: mhocko@suse.com, hannes@cmpxchg.org, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] mm: memcontrol: do not try to do swap when force empty Date: Thu, 3 Jan 2019 04:05:32 +0800 Message-Id: <1546459533-36247-3-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1546459533-36247-1-git-send-email-yang.shi@linux.alibaba.com> References: <1546459533-36247-1-git-send-email-yang.shi@linux.alibaba.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP The typical usecase of force empty is to try to reclaim as much as possible memory before offlining a memcg. Since there should be no attached tasks to offlining memcg, the tasks anonymous pages would have already been freed or uncharged. Even though anonymous pages get swapped out, but they still get charged to swap space. So, it sounds pointless to do swap for force empty. I tried to dig into the history of this, it was introduced by commit 8c7c6e34a125 ("memcg: mem+swap controller core"), but there is not any clue about why it was done so at the first place. The below simple test script shows slight file cache reclaim improvement when swap is on. echo 3 > /proc/sys/vm/drop_caches mkdir /sys/fs/cgroup/memory/test echo 30 > /sys/fs/cgroup/memory/test/memory.swappiness echo $$ >/sys/fs/cgroup/memory/test/cgroup.procs cat /proc/meminfo | grep ^Cached|awk -F" " '{print $2}' dd if=/dev/zero of=/mnt/test bs=1M count=1024 ping localhost > /dev/null & echo 1 > /sys/fs/cgroup/memory/test/memory.force_empty killall ping echo $$ >/sys/fs/cgroup/memory/cgroup.procs cat /proc/meminfo | grep ^Cached|awk -F" " '{print $2}' rmdir /sys/fs/cgroup/memory/test cat /proc/meminfo | grep ^Cached|awk -F" " '{print $2}' The number of page cache is: w/o w/ before force empty 1088792 1088784 after force empty 41492 39428 reclaimed 1047300 1049356 Without doing swap, force empty can reclaim 2MB more memory in 1GB page cache. Cc: Michal Hocko Cc: Johannes Weiner Signed-off-by: Yang Shi --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 6e1469b..bbf39b5 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2872,7 +2872,7 @@ static int mem_cgroup_force_empty(struct mem_cgroup *memcg) return -EINTR; progress = try_to_free_mem_cgroup_pages(memcg, 1, - GFP_KERNEL, true); + GFP_KERNEL, false); if (!progress) { nr_retries--; /* maybe some writeback is necessary */