From patchwork Wed Jan 2 20:05:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10746671 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 55B95746 for ; Wed, 2 Jan 2019 20:06:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 447902785D for ; Wed, 2 Jan 2019 20:06:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3613728390; Wed, 2 Jan 2019 20:06: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=-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 C26462785D for ; Wed, 2 Jan 2019 20:06:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF1DA8E0041; Wed, 2 Jan 2019 15:06:32 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EA2DF8E0002; Wed, 2 Jan 2019 15:06:32 -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 D90C38E0041; Wed, 2 Jan 2019 15:06:32 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 933598E0002 for ; Wed, 2 Jan 2019 15:06:32 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id u20so33418772pfa.1 for ; Wed, 02 Jan 2019 12:06:32 -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=dX8xM/XxlvcrFrpForq4/DrPCdSSxMRRfWDm3qPljyI=; b=fI6Lw7Pb5rCow3X/4nBj29RWPnls6kxNiALXqnW9vSTpjNEH9cd1c2MPiZWXbUXbez o8mo8ft45jjde9NLgc1d9DJ2X5BBUkv+NchOT6BZfdRgfrwbXDYbwu7eIq/Tt5KjOlVt 0ufI9MDLhRSGwFC27hpVzbrIgce98XEZUZ3OLpkwo78FGskbjIj0HFTjykuG+YFrEo21 MKo3A1zPn+1hr3K9kUygXOGL/+jRveW/JNGOhc48dWkKmW1UVU743Dxi9svFDA6uJHvn El3kArDZAa0FAbCVETmHtxTUeJeCBgsb8RQFWQq/GPPTFfXJl8oh42RNd2ouz+AHDrpN oIJw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 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: AJcUukc4so5QTmCS6YV67CsSpA39FmTBzEhC0XMXjWvKML2POKvWf0v/ gQ8M4nhi1zkr1EdT0BV1Gk+WplkR9xVFvuYcCWqQ0HOn163e29ketii/YPgutvndDmuBrxU2D2m X1te3T0f3MBsRO/MJvNv3IKEbLu4zCEEBKGk0PDY3VHI3xPUqRmF6xLfsEvPkmXggPw== X-Received: by 2002:a65:6392:: with SMTP id h18mr14910051pgv.107.1546459592252; Wed, 02 Jan 2019 12:06:32 -0800 (PST) X-Google-Smtp-Source: ALg8bN7qaYcA/WhWVd5tr6qEw66aSSJEiZue9DwZa/v52tiZnmaXMfDEkYt/RF9PQtiRDNoE/ro/ X-Received: by 2002:a65:6392:: with SMTP id h18mr14909989pgv.107.1546459591232; Wed, 02 Jan 2019 12:06:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546459591; cv=none; d=google.com; s=arc-20160816; b=WgDat15Yzg3QA3mN7VqVrJtVvTirYq42u629AF0IhS1TLGjCBNWZnd6L6FsQiUV4vC JZBi+a6X9qQcItuLnzNVuCaD9qYw6p7LAQMP3QNA8izVyy7ULT6/CRZJTzqBl40K16I6 vwbZCG75/yCgA1zo0ejgyuv2um8SZ1e4RmP62akfiuyiQVBMspXVPouWXdYKvNWYjw9p SOP5x4mgPytPYa2cywuTR2z/f6hfNkTjBHEb7Koixuy1zXNC+k9s9hbfhYBsR6aO7dtS i7i2UUSSYB8P6hbAfPIiosy1SEs54k0VghY6TDQ6Fc9bssR2xv4AbuakjD1QSJMgFDfH LtsA== 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=dX8xM/XxlvcrFrpForq4/DrPCdSSxMRRfWDm3qPljyI=; b=DOTotkTdxR+OaKM++wzGHryKSZErVS1I0kjlwJg8kqLGlQv386xpFGuBAuLf5ATT7w xOY5ofwxXqJsN5OqikNHuKfurtjQ4I6QZRTdbNKPzutILkRoBPgKa2S6McONjYfHaP9x 3m0Ai9SususoLayHBoIj/mn01nS5NIbSifyHZbBA36LWJqywAmjvrTTN+/OhPtfcrTI+ uiPUJh7JskjaE+Y/NxN0GhZ3qLRZtgT3mkD6JSxLVaGfxjn6HqA18W8OYZPf8hnhhOCl 6OQO8yXjnIkZJVU8dcR8QqW8gnpEV5tVOWb0G5eCm7D7qhCzDHUHmyvw9LWJDa/Ny/Sd YNow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out4436.biz.mail.alibaba.com (out4436.biz.mail.alibaba.com. [47.88.44.36]) by mx.google.com with ESMTPS id b9si48038295pgt.293.2019.01.02.12.06.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jan 2019 12:06:31 -0800 (PST) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 as permitted sender) client-ip=47.88.44.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.36 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=01201311R661e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07487;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 1/3] doc: memcontrol: fix the obsolete content about force empty Date: Thu, 3 Jan 2019 04:05:31 +0800 Message-Id: <1546459533-36247-2-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 We don't do page cache reparent anymore when offlining memcg, so update force empty related content accordingly. Cc: Michal Hocko Cc: Johannes Weiner Signed-off-by: Yang Shi Reviewed-by: Shakeel Butt Acked-by: Michal Hocko --- Documentation/cgroup-v1/memory.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/cgroup-v1/memory.txt b/Documentation/cgroup-v1/memory.txt index 3682e99..8e2cb1d 100644 --- a/Documentation/cgroup-v1/memory.txt +++ b/Documentation/cgroup-v1/memory.txt @@ -70,7 +70,7 @@ Brief summary of control files. memory.soft_limit_in_bytes # set/show soft limit of memory usage memory.stat # show various statistics memory.use_hierarchy # set/show hierarchical account enabled - memory.force_empty # trigger forced move charge to parent + memory.force_empty # trigger forced page reclaim memory.pressure_level # set memory pressure notifications memory.swappiness # set/show swappiness parameter of vmscan (See sysctl's vm.swappiness) @@ -459,8 +459,9 @@ About use_hierarchy, see Section 6. the cgroup will be reclaimed and as many pages reclaimed as possible. The typical use case for this interface is before calling rmdir(). - Because rmdir() moves all pages to parent, some out-of-use page caches can be - moved to the parent. If you want to avoid that, force_empty will be useful. + Though rmdir() offlines memcg, but the memcg may still stay there due to + charged file caches. Some out-of-use page caches may keep charged until + memory pressure happens. If you want to avoid that, force_empty will be useful. Also, note that when memory.kmem.limit_in_bytes is set the charges due to kernel pages will still be seen. This is not considered a failure and the 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 */