From patchwork Sat Jan 5 00:19:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10749017 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 EEF5414E5 for ; Sat, 5 Jan 2019 00:21:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFE3B287EF for ; Sat, 5 Jan 2019 00:21:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4343287FA; Sat, 5 Jan 2019 00:21:52 +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 65A15287EF for ; Sat, 5 Jan 2019 00:21:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 285CF8E0113; Fri, 4 Jan 2019 19:21:50 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 210248E00F9; Fri, 4 Jan 2019 19:21:50 -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 0B0088E0113; Fri, 4 Jan 2019 19:21:50 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id BA58E8E00F9 for ; Fri, 4 Jan 2019 19:21:49 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id 143so31388638pgc.3 for ; Fri, 04 Jan 2019 16:21:49 -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=GeQLYXyk4Icub2NWAR8B3v3eHEK+3lt4HaIMbOv3Eho=; b=nI0nx9B1J3q0dmCG9YoYqyOCoUhIUtOCcro+1s7CUFt87tXNh7BrUfgGWa+ktj5if5 sZhYYLVXI5zYqOhKoOtHpvWnXmINGNpHunrdQ6oz1X3hPBacwJnQEwtWaBQqe7Fwotw/ lJKZVUcN1671QIIqSeDXe1FVYwtM4mpjUGf/mV711O77wvzDa4xy7lrSdvY731T8oI2i IpLg/1+uR15td+nMQ1EIZXQlRsq/NuzaBLoReNg2JxpMOOM4JM7xGesV0hsAEQnnkrq9 FBoMRYaLJB5JGnfjxRONFUVuLRW+y6XRvm293L08v9dnIk9aagUDErQ1ERufvfnpozsE RKrQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.130 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: AJcUukcCwGFV/RRXB3FGq5Q8MIpfkQSMmj4RuyoRkn4X9DNCVP/Eukol wZMY2LcsBas8kidLvi7q8b1UzweL3aTP0oVPHV4rPSf5JKlywKfyW8KgD5Hr9h9Bmej327ifA6D 9bLp7zFnmQ6RSbVwDUmrux1jOWH3VYEZp7NqzT5vIzbHlFmbEKFbrhAJcXiQj1evO/Q== X-Received: by 2002:a17:902:4:: with SMTP id 4mr53090612pla.20.1546647709349; Fri, 04 Jan 2019 16:21:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN4X0fetnSF0YEQZkH+bryevLX6InRSzQvxUfiqlNUXCzds/plgjaVxzTKC6ei/cO/Siw5XD X-Received: by 2002:a17:902:4:: with SMTP id 4mr53090586pla.20.1546647708575; Fri, 04 Jan 2019 16:21:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546647708; cv=none; d=google.com; s=arc-20160816; b=G8xySFpH4+nzgulS7q+WOK4/nJsVaj9w7gLtZJRm5pWQbTtCOI5sC2VlYw+14MLw+K iJVHg29nFy2jd1z7Gd1yYH3/bAyDrpyiHoqyNrSoA3zs88R0Kp9y75LYQw7ymcOxrMEC U4BkBahV7sPRvZbOxLAAYsJPIO3xbQdUL/plpc8LJQg00cTkAjKsiKj5h62rqcaicI5f d1AchIAQ0kvwijlg5tjQhmRpMU+//aADt3dclcJ5VqcPStGHIA7LW4eyFu7e8pN0iA7p Cfm+QQGLNpQNHbyupj2nRMIGXx1g9cNPeeOiP5MlR1qsD+lxoxuL85HIE0rKdwAwgMK2 /DKA== 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=GeQLYXyk4Icub2NWAR8B3v3eHEK+3lt4HaIMbOv3Eho=; b=ta3TeAJl1Qgxe/pOir33iRPy/Yrhg61bHzoOQFbZQhJxgOrIJTw/8Ftoi0sABV8YcZ 5CSjucwElJzWu9qZApIAnQ0rl11ZJyeGf4cBUi9MnXEe6AIM2qrMoMEIhUEZjQpkwKIB FwzqI4NJjekvR0rOZbbw7UTXP8uqjf4rEUqfV24y9oDVh99l4dHr3X0+vySSjxr8OvdK c8X4Exkr0f5CuNgF5/iCE/3e8SvoGgUMpB46Fl0P0f0A3dy2Sb9e42Alb8UOMO089Z2H lrLN2ECYpfYMCAKIhGnUdD0g9BXDBbOsaVhdlRnlqw72PmFzrsHI3WytyEiN63kjFGUo BOLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.130 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-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com. [115.124.30.130]) by mx.google.com with ESMTPS id 128si11536625pgh.261.2019.01.04.16.21.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Jan 2019 16:21:48 -0800 (PST) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.130 as permitted sender) client-ip=115.124.30.130; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.130 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=01201311R141e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01406;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0THYi1he_1546647563; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0THYi1he_1546647563) by smtp.aliyun-inc.com(127.0.0.1); Sat, 05 Jan 2019 08:19:30 +0800 From: Yang Shi To: mhocko@suse.com, hannes@cmpxchg.org, shakeelb@google.com, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [v2 PATCH 2/5] mm: memcontrol: do not try to do swap when force empty Date: Sat, 5 Jan 2019 08:19:17 +0800 Message-Id: <1546647560-40026-3-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1546647560-40026-1-git-send-email-yang.shi@linux.alibaba.com> References: <1546647560-40026-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 af7f18b..75208a2 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2895,7 +2895,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 */