From patchwork Mon Nov 25 10:14:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11260091 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E640109A for ; Mon, 25 Nov 2019 10:15:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6B780207FD for ; Mon, 25 Nov 2019 10:15:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="on53JnwM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B780207FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8EAE66B05D0; Mon, 25 Nov 2019 05:15:14 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 876216B05D1; Mon, 25 Nov 2019 05:15:14 -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 73DD46B05D2; Mon, 25 Nov 2019 05:15:14 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0248.hostedemail.com [216.40.44.248]) by kanga.kvack.org (Postfix) with ESMTP id 5A9426B05D0 for ; Mon, 25 Nov 2019 05:15:14 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id C07762DFD for ; Mon, 25 Nov 2019 10:15:13 +0000 (UTC) X-FDA: 76194392106.03.range52_84eb65d73414f X-Spam-Summary: 2,0,0,9ee7c829869513cb,d41d8cd98f00b204,laoar.shao@gmail.com,:mhocko@kernel.org:hannes@cmpxchg.org:vdavydov.dev@gmail.com:akpm@linux-foundation.org::laoar.shao@gmail.com,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1345:1437:1534:1542:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2897:3138:3139:3140:3141:3142:3353:3865:3867:3870:3872:4250:4321:4385:4605:5007:6261:6653:7514:9413:9592:10004:11026:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12895:12986:13095:14096:14181:14394:14687:14721:21080:21433:21444:21451:21627:21666:21972:30054,0,RBL:209.85.216.68:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: range52_84eb65d73414f X-Filterd-Recvd-Size: 4910 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Mon, 25 Nov 2019 10:15:13 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id gc1so6379165pjb.8 for ; Mon, 25 Nov 2019 02:15:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LQLmU56stwLbyRk0aXcKLloXCxBHmw2Zmj/mVwgaqB8=; b=on53JnwMW6Iz6d6Rijycj4uC7i6OtlHyaVsWCBSpkMmL6YW18j9mavmtVgM6+LixG7 bw/m8YOgg6Mjm8pplenHrVwjJGMAKM34dlqRyPKwT/5NUaRkuaYBjCDqmSagAKHwX7K8 NtNkPb/zTFr0JTnc2DocoHIaNM/Tnf1mZAq8+cXfoAtJv3xC4R9kJ8A8X7KKSNd/4Lyn e/byGIJ4yQ90tuPlb6vKma/n1B6xCkEvSyIhGMPTXiwqWFjeaOgWXnrJPuC4+6ns2h6N FPNkCetb0JcINnwQqzbOEiLUVsF2yXx1AaZcJqGLRqFcB4Krvl4mb9KUMmhqA1yN62Hk V9vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LQLmU56stwLbyRk0aXcKLloXCxBHmw2Zmj/mVwgaqB8=; b=PmDlIECEzi8D9IP4mffD6WQMqUudsl2boEFsEWhlRRE29Cpt2b49DsqaSZy+jTUp/K +Uc88syiPK3FB2Pao6+vtY/ATmc8n3U2bSLYUEPBptp/dkm2Uh15fm0XSUkdYargQOaO ISQmRHnzE+B0cvmD8mQktfJXVzTq3R94ds/PNKk6c7U9jr07kcf+WGPc+qPJd1Q0IP0X pmYjUEeHp4w48YdDaBTB4Lfcm3lJaBryXiz9y7V4rP/yL6gCn88L1xvbsQqvc3wvVqqr 7a+w6tmE2UcJ5FNZs+fovJcqGHBRgPPpkNyTV1/E/2pqVNFzLhaXxbt6ET8T2yTADpAh xbtQ== X-Gm-Message-State: APjAAAWvzGlzKVLwC90ffHpSZVfVvXaTWUgXV5bVv3Rs/MoiBn63ln7B lmSsDb6y964Nz460jqnHFBc= X-Google-Smtp-Source: APXvYqz1y3zG4sExjuk4YZWsf+ZZBIiwtfxq2sh4xNi3Lci/v0cWlfuYNl/XT3lwXNH7IuB6QTJxfQ== X-Received: by 2002:a17:90a:7784:: with SMTP id v4mr38539715pjk.74.1574676912437; Mon, 25 Nov 2019 02:15:12 -0800 (PST) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id 203sm7510894pfy.185.2019.11.25.02.15.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Nov 2019 02:15:11 -0800 (PST) From: Yafang Shao To: mhocko@kernel.org, hannes@cmpxchg.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Yafang Shao Subject: [PATCH] mm, memcg: clear page protection when memcg oom group happens Date: Mon, 25 Nov 2019 05:14:53 -0500 Message-Id: <1574676893-1571-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 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: We set memory.oom.group to make all processes in this memcg are killed by OOM killer to free more pages. In this case, it doesn't make sense to protect the pages with memroy.{min, low} again if they are set. Signed-off-by: Yafang Shao --- include/linux/memcontrol.h | 11 +++++++++++ mm/memcontrol.c | 4 +--- mm/oom_kill.c | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 0c762e8..f68a1a5 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -369,6 +369,13 @@ static inline unsigned long mem_cgroup_protection(struct mem_cgroup *memcg, READ_ONCE(memcg->memory.elow)); } +static inline void mem_cgroup_clear_protection(struct mem_cgroup *memcg) +{ + + page_counter_set_min(&memcg->memory, 0); + page_counter_set_low(&memcg->memory, 0); +} + enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root, struct mem_cgroup *memcg); @@ -850,6 +857,10 @@ static inline unsigned long mem_cgroup_protection(struct mem_cgroup *memcg, return 0; } +static inline void mem_cgroup_clear_protection(struct mem_cgroup *memcg) +{ +} + static inline enum mem_cgroup_protection mem_cgroup_protected( struct mem_cgroup *root, struct mem_cgroup *memcg) { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1c4c08b..e5ab119 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5190,9 +5190,7 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css) } spin_unlock(&memcg->event_list_lock); - page_counter_set_min(&memcg->memory, 0); - page_counter_set_low(&memcg->memory, 0); - + mem_cgroup_clear_protection(memcg); memcg_offline_kmem(memcg); wb_memcg_offline(memcg); diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 93eae76..550f830 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -988,6 +988,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message) mem_cgroup_print_oom_group(oom_group); mem_cgroup_scan_tasks(oom_group, oom_kill_memcg_member, (void*)message); + mem_cgroup_clear_protection(oom_group); mem_cgroup_put(oom_group); } }