From patchwork Sat Nov 23 05:56:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11258739 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 D38596C1 for ; Sat, 23 Nov 2019 05:56:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 89C362071C for ; Sat, 23 Nov 2019 05:56:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R9c7xu8l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89C362071C 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 B3B416B0546; Sat, 23 Nov 2019 00:56:58 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AEBE76B0547; Sat, 23 Nov 2019 00:56:58 -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 A02376B0548; Sat, 23 Nov 2019 00:56:58 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id 8947E6B0546 for ; Sat, 23 Nov 2019 00:56:58 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 0D4F58249980 for ; Sat, 23 Nov 2019 05:56:58 +0000 (UTC) X-FDA: 76186483716.08.knife04_59e1063b17560 X-Spam-Summary: 2,0,0,768093e0206e0fb3,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:973:988:989:1260:1345:1437:1534:1540:1711:1714:1730:1747:1777:1792:2393:2553:2559:2562:2897:3138:3139:3140:3141:3142:3351:3868:3870:3874:4321:5007:6261:6653:7514:9413:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12895:12986:13069:13311:13357:14096:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:30054:30090,0,RBL:209.85.215.194:@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:23,LUA_SUMMARY:none X-HE-Tag: knife04_59e1063b17560 X-Filterd-Recvd-Size: 3476 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Sat, 23 Nov 2019 05:56:57 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id t3so4024306pgl.5 for ; Fri, 22 Nov 2019 21:56:57 -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=WixBN79f4TORux41m27WcVkKJzMnEXvPPkV5G2DXboo=; b=R9c7xu8lOUOVUapj6NnNnnfu00G3r62Xzri9xYnA3lTJHG0XjH691MKZ/JTA9mWmDF /FXDEo5VCCpAhYYuUGsrf1gCGhVkA1ozPml20YLz/48LUTacNPtnylPj1zFg0fmH5+t2 ogFf2a/2ynZlGOqou+Z47okXzGcwIqxFVfQZ468/8Ob0T9SifZ9ALX74DFMIyC0NuAo3 PEpQjq0cyl7A5vEJUrilorVRzd07NN6umd4ydsFstRdQpmClV2NFVHuWiUmlyLv66KvA 6Ij5WlMaDWqsVxt1yZGtB+mhFybMUZAIm/ICInAQhmhaaQIlRwWBVOQokG60HWNuJiLe MoPQ== 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=WixBN79f4TORux41m27WcVkKJzMnEXvPPkV5G2DXboo=; b=qAXDQPaA1cSXz8pA1hI4uJ8SnKJrXDpmeGrFeBerBU0c0770jyVDtGAJL0wixek6oH W2RN+rbBex2FPHBYscGAKfc/UsUIEjoBJ6zJNzr/i+ZqGq9ceyn4sj9JVGLZOpxQ0Rx4 p2eZgiz6R+m1UCFpS73l1BsMpLpSsO/KJgZXcvaq/60dY+R7YrG27EC0IRXimTM9wSM0 FfNkKR25jJufXrUCRKTcqxG13wVJru+RX+yNialEifnpAg9GyWwIs9XvRGZDg7hwF9CN XQOjU3qd6tgplPz0gc07S+ugFxoIAViv9o4OKX+eLKhK2xBVptdXPtDUFb7jKF/eVzHF kEHQ== X-Gm-Message-State: APjAAAUxSlW34OkT3LG1Pcvd5fV/pa8J6Ucj/IZAkK2zpgE6dPZpmtEp 0iv8U5Ek3IzBOrVrbbZ1GAY= X-Google-Smtp-Source: APXvYqyLePBfsC6liKoPp3TO5zSiJ7eOArBJB6lXqZb3/eEtmmm3rivoBqKapek78xwxx0GgZmjBjw== X-Received: by 2002:a63:f30c:: with SMTP id l12mr20056274pgh.354.1574488616490; Fri, 22 Nov 2019 21:56:56 -0800 (PST) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id y16sm9680737pfo.62.2019.11.22.21.56.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Nov 2019 21:56:55 -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: don't protect pages if memcg is not populated Date: Sat, 23 Nov 2019 00:56:42 -0500 Message-Id: <1574488602-11773-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: memory.{min, low} keeps protecting pages in a memcg even if there're no process running in this memcg. That makes nonsense, because if there're no processes running in this memcg there may be something wrong happens and these protected pages are not useful now. Signed-off-by: Yafang Shao --- mm/memcontrol.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1c4c08b..c96c282 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6376,6 +6376,9 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root, if (memcg == root) return MEMCG_PROT_NONE; + if (!cgroup_is_populated(memcg->css.cgroup)) + return MEMCG_PROT_NONE; + usage = page_counter_read(&memcg->memory); if (!usage) return MEMCG_PROT_NONE;