From patchwork Sat Jan 5 00:19:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10749019 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 3F1E41575 for ; Sat, 5 Jan 2019 00:22:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B30F287EF for ; Sat, 5 Jan 2019 00:22:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19BBE287FE; Sat, 5 Jan 2019 00:22:46 +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 6F09F287EF for ; Sat, 5 Jan 2019 00:22:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A00098E0114; Fri, 4 Jan 2019 19:22:44 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9AF238E00F9; Fri, 4 Jan 2019 19:22:44 -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 877B78E0114; Fri, 4 Jan 2019 19:22:44 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 42D6B8E00F9 for ; Fri, 4 Jan 2019 19:22:44 -0500 (EST) Received: by mail-pf1-f200.google.com with SMTP id x67so11810249pfk.16 for ; Fri, 04 Jan 2019 16:22:44 -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=8XCIJfqelyCc8vq4TfoTZne/96LBokAk2miuT+Bctcc=; b=GQfln1JRWsGOTIa3dAVsEQN7XVqEyKws2FFgku/qIQkzxIqzXDKfxuH870cubSsU6C c2bmp4HjbsJkbgKQkUcAj8K+OcT6cvfnOT5MTzxx4vLPd1hEUkX8NOncUPy+ElyGBaSa w93yRsM/Idv/j//9Y8GzpHEpLzwDd2m3NkDebosxprRJGSAYo+ZpR0I26CShNjZFIog1 I7uwgftTzpyTLrk847SRD3eCNvUEK3qUQZDJApAa6qWsMNhmRSHqS3BR7gxoiELe88VA /goPJlEcPpStEoPwXv/5VnL7aGoq//mx8qC67xYYmqDAUB0ws4MimoYU7dChgvyDdZAi u6Fg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 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: AJcUukftGhpcBys6KZIMnQjaLGSZLM8XXH1e9lR7CmJzRcDPFEMpXol5 ll3iUZfK9Y6kfG+Q9WmC7V2IGUusq1a/aFjJlGRpQ3zU7jhdRx1ZEj/jxPNm3FfZsnoe9SuH4Q2 pytrJA+Tn2PnMpX/CiwLT+6nDXfed4KUdbNndWZSH7yHT/Gy8yuXIKLou09SH1oEi8A== X-Received: by 2002:a63:f1f:: with SMTP id e31mr3314450pgl.274.1546647763900; Fri, 04 Jan 2019 16:22:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN5/ZYz+GXwJJUwiPpAV2b398jK0l4EXCCJqKB1jAHV3k8u3diezY0w4YwVcwayhu3KTOd7O X-Received: by 2002:a63:f1f:: with SMTP id e31mr3314423pgl.274.1546647763141; Fri, 04 Jan 2019 16:22:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546647763; cv=none; d=google.com; s=arc-20160816; b=MzXd7fkpowgBulkbzG45G2I/TFQhYqwbJZ77r+0KtgnxR8QGoh2lK5A/O5/M5czOzP 8n0ZMbirZqHO14EQ8ZFt+4RBz7eonPhEYrXUMSn7a91tX0lN10nJKhZQBWdiYn4iHXR/ HNiQb/QcEcUAXL4T1vIXQfxOaLkvC3P5fDrWJnG+WMe01FRnkgdfyryyu0iTmHoCOT7b FPZoj5HNRtVx6uJyJWDAuMelB1Ui+WMtx91fd1mKuRMDlzH9YZPGc+FNfT/0Vsc7RpgD JXLGxO4pmc9T+RL/lAWF9UzT6xqSANFkesmNC6A5VU2xQw6DMVniFMrkRaWtWsZpAn0E Vkjg== 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=8XCIJfqelyCc8vq4TfoTZne/96LBokAk2miuT+Bctcc=; b=l8IXP/XedbaRkZzUSVaRry4Bai/0Lmen6b5jIfApwK3dV1GzXMCc+HRsvTRPgBqpE9 ZC21iq5vxqAd9b+fs4EIchveDQop2SgoeYq8+7RiMA4tJRDjfjgv0wSJwTjlx9w89KKE CK3YDhal0FzZgTGuAM/caT1AsZDgrlthh5OgC4aSI0H4tN5thg50SxAOftQMYX2vPH0H wSV69alEmOOR9dplsjOp1DzzAa1YMxgbdL28LuZvqTciCQCS4GyqpH88OumyX6vv5K5J tHPM9flW9W9tFzFVXClbqy/qz42dzlSfiBXjTmnk84scrGbTKuzWnEW+3/5PLIH4XYdA gnWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 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-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com. [115.124.30.132]) by mx.google.com with ESMTPS id b3si10260947pgc.587.2019.01.04.16.22.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Jan 2019 16:22:43 -0800 (PST) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) client-ip=115.124.30.132; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 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=01201311R191e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04452;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 1/5] doc: memcontrol: fix the obsolete content about force empty Date: Sat, 5 Jan 2019 08:19:16 +0800 Message-Id: <1546647560-40026-2-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 We don't do page cache reparent anymore when offlining memcg, so update force empty related content accordingly. Reviewed-by: Shakeel Butt Acked-by: Michal Hocko Cc: Johannes Weiner Signed-off-by: Yang Shi --- 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 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 */ From patchwork Sat Jan 5 00:19:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10749015 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 460E8746 for ; Sat, 5 Jan 2019 00:21:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 321DC287EF for ; Sat, 5 Jan 2019 00:21:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FFDD287FA; Sat, 5 Jan 2019 00:21:51 +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 90770287EF for ; Sat, 5 Jan 2019 00:21:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C73E28E0112; Fri, 4 Jan 2019 19:21:49 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C36958E0113; Fri, 4 Jan 2019 19:21:49 -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 B10A08E0112; Fri, 4 Jan 2019 19:21:49 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by kanga.kvack.org (Postfix) with ESMTP id 84CA78E00F9 for ; Fri, 4 Jan 2019 19:21:49 -0500 (EST) Received: by mail-io1-f70.google.com with SMTP id q23so42774870ior.6 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=FwONxR7oKW4opQ6uN7J1KnVgGi+k4wMmoWgR7B7DAVA=; b=qxrDL3GnU11t2VeYVXlcNHSuXn//bHhw31CCHMye3nbjgfe3GCYibTWDTWjV2HmYXr f5bVbxnOb5+0EsZ24sjkVU7GoCmS5M/TFVzZFAlaZwK2g5aQwCy9xdwLZCEQUe8WlcXb f9TFoZ/34DmJ9hzrFAoWzFf1ABvYRvm+HvZplq9Y/PQ/lqlybk+xgInbvYShR4paTw1N ysU9bxV3v2dAZ4HVFLNF2/eASSsw9QpIZBIH3brAqculTU926Udd2LLX+4GIiUebSsJ0 KkvmMKi9KZKpP/nt6M8BmqRzuFFe5mKZqiIfUXIafYuxRxiEM5vmTQaFbwEce0oVX1vN IBDg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.131 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: AJcUukcq+ADgdXWWvfg4e4UzO2euBjdI78HUKYXybKY9Z26keMBymGfA +OWBkSqkiirMNAph0QTPIR/Q8/z6e/WOrLPSi+f5lX33Qip4lHHNkD6FklHpim+vHMkkCPyX1fj qUGISSsZi2gfhnN+9zS8E3/n6YGtjYWjYFGXiAFptt52iXX628s3eIhUozNAEkVxEIg== X-Received: by 2002:a6b:3b47:: with SMTP id i68mr37895555ioa.133.1546647709235; Fri, 04 Jan 2019 16:21:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN7gHT2vATyXVqlSqSVz0SWeADq83WwPFh+8CGgRQElD0/NDMSR52cru08/DgKcNWy4rKg23 X-Received: by 2002:a6b:3b47:: with SMTP id i68mr37895535ioa.133.1546647708114; 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=h7xok0VoaYvbyZTuvvrVQvFEQ54OuFIxdmGnekRha0b/b3/KAgKgnwTQyknwGlGuJg yQuWOS7b3Ps18EnYIMgotkSTuWQiCbOtwQkcOT6Gh/xL24fEj+kvGMGVmLgUNdMZWNoa o/EnVUL6YS53ZQnlEEWtg+uGySYaDGeUubQ2GDBrX3gp4C0X5igMoPN/OsMRd8Fc8TWj vUxHd7LZcp7/BMtw2wmCSaKA+Ptmti4jE0jozj8N2Nk16zEQ0bTa7ThkBgFV3w55ElHl 0YykY20o5CsHsABXtssgfL9fp4whFBDQFHyVIL0WEGjU+vGt7RlYiPO+ppnnVJMvRuXR ToHQ== 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=FwONxR7oKW4opQ6uN7J1KnVgGi+k4wMmoWgR7B7DAVA=; b=E5n384E3T04wpo0x0DsuIb/kcwgZYoKxQUkxqkj8lzmJfXQD2BN/EiDIETcVQBp5Am 6pZRNUUD1v43SK1e6GYS4qsZSivboPHeexCAMLncIi/gISQaRWCDmYThX9ntC54TMK+i oV7pivFSea0E6cSo0rPmmSh46d/F7mrOz4YfntjtaDwCdl/RiB4nHQ0+3r6xMuof5sTg Uuwl123mP7qsPOo98FHnZXdx74855kfsE+iwv9WxMlY7pOFOcKjK48gpa80h3iCrL0o2 fbROub+cVpPIgNtl32TqQK+T7tO39xutkWLeGlwkZw8PQuayFHPyBUvuZQYz6Ve0TWHs A52w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.131 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-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com. [115.124.30.131]) by mx.google.com with ESMTPS id m18si610150itb.1.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.131 as permitted sender) client-ip=115.124.30.131; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.131 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=01201311R131e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01451;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:31 +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 3/5] mm: memcontrol: introduce wipe_on_offline interface Date: Sat, 5 Jan 2019 08:19:18 +0800 Message-Id: <1546647560-40026-4-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 We have some usecases which create and remove memcgs very frequently, and the tasks in the memcg may just access the files which are unlikely accessed by anyone else. So, we prefer force_empty the memcg before rmdir'ing it to reclaim the page cache so that they don't get accumulated to incur unnecessary memory pressure. Since the memory pressure may incur direct reclaim to harm some latency sensitive applications. Force empty would help out such usecase, however force empty reclaims memory synchronously when writing to memory.force_empty. It may take some time to return and the afterwards operations are blocked by it. Although this can be done in background, some usecases may need create new memcg with the same name right after the old one is deleted. So, the creation might get blocked by the before reclaim/remove operation. Delaying memory reclaim in cgroup offline for such usecase sounds reasonable. Introduced a new interface, called wipe_on_offline for both default and legacy hierarchy, which does memory reclaim in css offline kworker. Writing to 1 would enable it, writing 0 would disable it. Suggested-by: Michal Hocko Cc: Johannes Weiner Signed-off-by: Yang Shi --- include/linux/memcontrol.h | 3 +++ mm/memcontrol.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 83ae11c..2f1258a 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -311,6 +311,9 @@ struct mem_cgroup { struct list_head event_list; spinlock_t event_list_lock; + /* Reclaim as much as possible memory in offline kworker */ + bool wipe_on_offline; + struct mem_cgroup_per_node *nodeinfo[0]; /* WARNING: nodeinfo must be the last member here */ }; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 75208a2..5a13c6b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2918,6 +2918,35 @@ static ssize_t mem_cgroup_force_empty_write(struct kernfs_open_file *of, return mem_cgroup_force_empty(memcg) ?: nbytes; } +static int wipe_on_offline_show(struct seq_file *m, void *v) +{ + struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m)); + + seq_printf(m, "%lu\n", (unsigned long)memcg->wipe_on_offline); + + return 0; +} + +static int wipe_on_offline_write(struct cgroup_subsys_state *css, + struct cftype *cft, u64 val) +{ + int ret = 0; + + struct mem_cgroup *memcg = mem_cgroup_from_css(css); + + if (mem_cgroup_is_root(memcg)) + return -EINVAL; + + if (val == 0) + memcg->wipe_on_offline = false; + else if (val == 1) + memcg->wipe_on_offline = true; + else + ret = -EINVAL; + + return ret; +} + static u64 mem_cgroup_hierarchy_read(struct cgroup_subsys_state *css, struct cftype *cft) { @@ -4283,6 +4312,11 @@ static ssize_t memcg_write_event_control(struct kernfs_open_file *of, .write = mem_cgroup_reset, .read_u64 = mem_cgroup_read_u64, }, + { + .name = "wipe_on_offline", + .seq_show = wipe_on_offline_show, + .write_u64 = wipe_on_offline_write, + }, { }, /* terminate */ }; @@ -4569,6 +4603,15 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css) page_counter_set_min(&memcg->memory, 0); page_counter_set_low(&memcg->memory, 0); + /* + * Reclaim as much as possible memory when offlining. + * + * Do it after min/low is reset otherwise some memory might + * be protected by min/low. + */ + if (memcg->wipe_on_offline) + mem_cgroup_force_empty(memcg); + memcg_offline_kmem(memcg); wb_memcg_offline(memcg); @@ -5694,6 +5737,12 @@ static ssize_t memory_oom_group_write(struct kernfs_open_file *of, .seq_show = memory_oom_group_show, .write = memory_oom_group_write, }, + { + .name = "wipe_on_offline", + .flags = CFTYPE_NOT_ON_ROOT, + .seq_show = wipe_on_offline_show, + .write_u64 = wipe_on_offline_write, + }, { } /* terminate */ }; From patchwork Sat Jan 5 00:19:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10749013 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 D69EE14E5 for ; Sat, 5 Jan 2019 00:21:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C69F6287EF for ; Sat, 5 Jan 2019 00:21:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAFE0287FD; Sat, 5 Jan 2019 00:21:12 +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 4723C287EF for ; Sat, 5 Jan 2019 00:21:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56D988E0111; Fri, 4 Jan 2019 19:21:11 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4F6188E00F9; Fri, 4 Jan 2019 19:21:11 -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 398698E0111; Fri, 4 Jan 2019 19:21:11 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id E70A68E00F9 for ; Fri, 4 Jan 2019 19:21:10 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id ay11so28095314plb.20 for ; Fri, 04 Jan 2019 16:21:10 -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=dW7lWc9crn2H8wXW3I/dbbtBQcc06wSqi1SfSudgQuY=; b=RlFX03siPBAfROt+qrs8U/odmTGtczIjjqo3zjRCewqfZfClagenbzMrJPGbts/Qmc j5fzBO1k1TmJwtTheHk1iZ28qDiXk7FlJI6ApJnKt2uDMGmhA3K6eED/IO48HoFO/mN4 +6zs/Vi1DafkP+ah5AEIMUsB4Raj/hpRmtsbIq3KnHKyBZWudMyJMzwAUj1ryHe23nAs kYUZMm8SPaDFyMtaoEnhKg3avJ5zL81CCOU3bE5/AZctAguZ6rMrZkk14DTPDag0JzzT uCq+CyvRrCgZdAqmA/q/nCzjzie/zU48Rvi71hl+nok31MYkUSS1N5rOXBYTjchg9Gtu 7mLg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 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: AJcUuke2XBKWB8+J2x+/U1c/NScKv2d5mAYto3SGcwuXjn7SKaV5V28o R++YsAw2qjkVzATOzwOnQGz+mTR9s60gK6qQQB3DYrUdhqCO+UyJqFI1w4RMRmmZ5Ve5nV24lCc 1/ngCmx3FMTwS/kSfeKVftmIu3a93kTXRMb1eEL7VUqaBS0KwoRghQD8ktJC6SXF7/Q== X-Received: by 2002:a63:ac46:: with SMTP id z6mr3357901pgn.162.1546647670583; Fri, 04 Jan 2019 16:21:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN59gXNMYi+9HVxMw3AgoVh9PlXm5JT4Tg0TWeZL11rw11+amko8TQikx1qUGv++AHkoHa6t X-Received: by 2002:a63:ac46:: with SMTP id z6mr3357873pgn.162.1546647669800; Fri, 04 Jan 2019 16:21:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546647669; cv=none; d=google.com; s=arc-20160816; b=wsQOvtBq9GvPGZgnms9zs7VVWnJ67Y8zCwAyH//mjHfcIp5wqT+vQle+rxFTxohvL3 p3jE47YiUM1DzzNfFlRbH1RF7EYZkIvtBr14nJAI7nbR1DpFLjMjHWRlvdb3ujrl+L4D MSYhrqOK1+oJzoQX7/yjl/7UxtkRiRXPoAOZ8Pr25uJuksxphXHNPkEu6+JUhkc92OLW Rtp6X3qLo/6ixj85/IoNmPvYQm7i8d5aBvkPyCCDNqX4CKTNIrdLTaSyHv4QtV8Fiib2 mKiQtgXDROjo5P7d1bg6Xtsj3aI1fhhKKGQvnYAyJ7eag1VfHdED4MI5Fss44NitLr+q sS5g== 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=dW7lWc9crn2H8wXW3I/dbbtBQcc06wSqi1SfSudgQuY=; b=VqmGaVsPYGHXj7sUtXgOQiHlnUGC31s2SpdBGvAHkrufMXHvEJqBLEZQ9mzO3pQcYu 5yqqRhVlXjHqOH0GjB8+AxnKqGk0i5JNUi2DRRSyWGAAmhvDMXf24cr5jYcfA0fu5Nqn rSu/ufjAQJz5hZ7SrFPTVAyM71q5M0ZSXjzokd8PeyImpirm/ixTl4J73s09/qeOC3ql bivWMYkVzcf3NuiELOVD5zBZR0pTZzrfx5EHsVrszUZSj4QAgQWahJ6mda1/b42fgItH ad6Cunvu3FFnz0StQlosl6IzA1ID+b/haP7IPanzT5XsREKAvLIGcmp0hemt9FU5e1V/ xrZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 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-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com. [115.124.30.132]) by mx.google.com with ESMTPS id j132si4261668pfc.84.2019.01.04.16.21.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Jan 2019 16:21:09 -0800 (PST) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) client-ip=115.124.30.132; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 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=01201311R431e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04391;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:31 +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 4/5] mm: memcontrol: bring force_empty into default hierarchy Date: Sat, 5 Jan 2019 08:19:19 +0800 Message-Id: <1546647560-40026-5-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 default hierarchy doesn't support force_empty, but there are some usecases which create and remove memcgs very frequently, and the tasks in the memcg may just access the files which are unlikely accessed by anyone else. So, we prefer force_empty the memcg before rmdir'ing it to reclaim the page cache so that they don't get accumulated to incur unnecessary memory pressure. Since the memory pressure may incur direct reclaim to harm some latency sensitive applications. There is another patch which introduces asynchronous memory reclaim when offlining, but the behavior of force_empty is still needed by some usecases which want to get the memory reclaimed immediately. So, bring force_empty interface in default hierarchy too. Cc: Michal Hocko Cc: Johannes Weiner Signed-off-by: Yang Shi --- Documentation/admin-guide/cgroup-v2.rst | 14 ++++++++++++++ mm/memcontrol.c | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index 7bf3f12..0290c65 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1289,6 +1289,20 @@ PAGE_SIZE multiple when read back. Shows pressure stall information for memory. See Documentation/accounting/psi.txt for details. + memory.force_empty + This interface is provided to make cgroup's memory usage empty. + When writing anything to this + + # echo 0 > memory.force_empty + + the cgroup will be reclaimed and as many pages reclaimed as possible. + + The typical use case for this interface is before calling rmdir(). + 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. + Usage Guidelines ~~~~~~~~~~~~~~~~ diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 5a13c6b..c4a7dc7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5743,6 +5743,10 @@ static ssize_t memory_oom_group_write(struct kernfs_open_file *of, .seq_show = wipe_on_offline_show, .write_u64 = wipe_on_offline_write, }, + { + .name = "force_empty", + .write = mem_cgroup_force_empty_write, + }, { } /* terminate */ }; From patchwork Sat Jan 5 00:19:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10749011 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 7499214E5 for ; Sat, 5 Jan 2019 00:20:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60AD8287F5 for ; Sat, 5 Jan 2019 00:20:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53D06287FA; Sat, 5 Jan 2019 00:20:54 +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 3B649287F5 for ; Sat, 5 Jan 2019 00:20:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D1D18E0110; Fri, 4 Jan 2019 19:20:52 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 433B88E00F9; Fri, 4 Jan 2019 19:20:52 -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 2FB378E0110; Fri, 4 Jan 2019 19:20:52 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it1-f197.google.com (mail-it1-f197.google.com [209.85.166.197]) by kanga.kvack.org (Postfix) with ESMTP id 045EF8E00F9 for ; Fri, 4 Jan 2019 19:20:52 -0500 (EST) Received: by mail-it1-f197.google.com with SMTP id b14so2197750itd.1 for ; Fri, 04 Jan 2019 16:20:52 -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=tpU+aXWfRIFmKejztq32i/zmcUqi50WJVBEvfCwY/bY=; b=jC0ab8buIfGMWJSIz31Ie+hOJssl51rGGbu6Coj2YJaw9M66B300afnKXD3Uhbirus I0/wVxx6/2yDMtgAkzAcmmJV5JLCLxEWGkgajeDjt41fAyTJnDeqWCBbrbS1BwCR3FEj 9E9UcOAM1u3IjpENnWiZvPhcW3wk89WqMCGVnjvOx33vpyuWxU92dI3yuccmyPPV/FBt PsS0oEi2xQ9+K1VLZDNG0YDCGSazG0Rw7JYqZ2DxkZXxtv1fPrkNnuymxHGPQw+hsxJA N+JzGqdaeM5HhT6b6682tGRBD7o+wzb/iCzCcWcKT7my3wHxwuUk29tTGJKSgPlCLaQt JT8Q== 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+aEWZ1tdZYFVRO6U0WVnV5y1U9YfQrC/pghZBIEO2i7RiKN6x/xKEI 2nfLB/ZE5CPBtTPZmYrdS5n/j1kNOCLFJtSGckagn5pLvozw43SA/oKtxh/WTU/nU48Tn1FXdPj 7IirLYIXLlGxGhAy67k7zbFOYgkjDaqhnu/Ir4a1EdQbWlhWnNZWXVl10SCdkzVh4fg== X-Received: by 2002:a02:960e:: with SMTP id c14mr37643885jai.84.1546647651750; Fri, 04 Jan 2019 16:20:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/X5OI/XtaYUTwrkAh1GWgxEmFuDxYO7ITFId45oba+hTnh/t9N9znvp82iswVsFL+ftL4XZ X-Received: by 2002:a02:960e:: with SMTP id c14mr37643871jai.84.1546647650961; Fri, 04 Jan 2019 16:20:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546647650; cv=none; d=google.com; s=arc-20160816; b=qfrnIuCBqmKvpl7tqRRFYDVIUt59VjhgT2VFencffeRC28lQnwqHvmv8lTYTfGGVZb HP02+ZKROBE3zgnHFAMaqCrnJvanteCo7QUMDCP788UiQJs3R8mXOsLFul0PiGRd6lS9 4rVkgGdDLcYrE8H9GAGDau88tODBfaVXiYaWNlM7C21b9RzOcqAVHFjU+7mcSJ/ilC6i NPh71JJvpNX7+ZuxU7ZhBMXcloCMKmmj3lJn27smxRRLgN3d8Mld0P6WQLxz+0bySIu7 SOsxP2irdtmVFnbErJYg++kfXIEoYU4CJ1BopRQvNKhfwkTz+mka1iTom8VjFhSr8pfY 6PDA== 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=tpU+aXWfRIFmKejztq32i/zmcUqi50WJVBEvfCwY/bY=; b=tqsGBtOVeoNS0vmAzgh/Ds3XmH5vmiuT9whebIUuDFHNZ1FMmOuB57qPdnfuo8RUaJ pOQrw9P8jIap7qw/5esqtaPwpeyfp53ubr7qytwUUrmSGWh9cF9J7CBvEQloc+16baPA aa4Hvmo862OblO6gbvbLKa5Q0Le1JpqFJwD55Fsod6zagbzxF3Tl0BaZtcpC4s2+stdk UGkcO1MhUifqESZfXNrGb5IvE5VNhGt8w7HkOAmvbbvvhqm032c/mXOEnP4JISCBpWAq hnvbwqlGiVLZrU0m79dTgWlQaBHEueVEKxBhFeIK+TQa5bBHMrd4ReUCpgT0p9LUR4W5 x5Nw== 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 k8si569153itk.97.2019.01.04.16.20.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Jan 2019 16:20:50 -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=01201311R281e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07486;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:31 +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 5/5] doc: memcontrol: add description for wipe_on_offline Date: Sat, 5 Jan 2019 08:19:20 +0800 Message-Id: <1546647560-40026-6-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 Add desprition of wipe_on_offline interface in cgroup documents. Cc: Michal Hocko Cc: Johannes Weiner Signed-off-by: Yang Shi --- Documentation/admin-guide/cgroup-v2.rst | 9 +++++++++ Documentation/cgroup-v1/memory.txt | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index 0290c65..e4ef08c 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -1303,6 +1303,15 @@ PAGE_SIZE multiple when read back. memory pressure happens. If you want to avoid that, force_empty will be useful. + memory.wipe_on_offline + + This is similar to force_empty, but it just does memory reclaim + asynchronously in css offline kworker. + + Writing into 1 will enable it, disable it by writing into 0. + + It would reclaim as much as possible memory just as what force_empty does. + Usage Guidelines ~~~~~~~~~~~~~~~~ diff --git a/Documentation/cgroup-v1/memory.txt b/Documentation/cgroup-v1/memory.txt index 8e2cb1d..1c6e1ca 100644 --- a/Documentation/cgroup-v1/memory.txt +++ b/Documentation/cgroup-v1/memory.txt @@ -71,6 +71,7 @@ Brief summary of control files. memory.stat # show various statistics memory.use_hierarchy # set/show hierarchical account enabled memory.force_empty # trigger forced page reclaim + memory.wipe_on_offline # trigger forced page reclaim when offlining memory.pressure_level # set memory pressure notifications memory.swappiness # set/show swappiness parameter of vmscan (See sysctl's vm.swappiness) @@ -581,6 +582,15 @@ hierarchical_= N0= N1= ... The "total" count is sum of file + anon + unevictable. +5.7 wipe_on_offline + +This is similar to force_empty, but it just does memory reclaim asynchronously +in css offline kworker. + +Writing into 1 will enable it, disable it by writing into 0. + +It would reclaim as much as possible memory just as what force_empty does. + 6. Hierarchy support The memory controller supports a deep hierarchy and hierarchical accounting.