From patchwork Tue Dec 17 11:29:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11297351 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 C334414E3 for ; Tue, 17 Dec 2019 11:31:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8FC5B207FF for ; Tue, 17 Dec 2019 11:31:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ay5w39y6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FC5B207FF 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 A7C778E0057; Tue, 17 Dec 2019 06:31:25 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A53A28E0040; Tue, 17 Dec 2019 06:31:25 -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 968418E0057; Tue, 17 Dec 2019 06:31:25 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id 8317C8E0040 for ; Tue, 17 Dec 2019 06:31:25 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4636E8249980 for ; Tue, 17 Dec 2019 11:31:25 +0000 (UTC) X-FDA: 76274417730.01.seed05_2971351b76f02 X-Spam-Summary: 2,0,0,5cb5c331b8241ec4,d41d8cd98f00b204,laoar.shao@gmail.com,:hannes@cmpxchg.org:mhocko@kernel.org:vdavydov.dev@gmail.com:akpm@linux-foundation.org:viro@zeniv.linux.org.uk::linux-fsdevel@vger.kernel.org:laoar.shao@gmail.com:guro@fb.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2898:3138:3139:3140:3141:3142:3352:3865:3866:3867:3871:3872:3874:4321:4605:5007:6261:6653:7514:9413:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12895:13069:13311:13357:14096:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:21740:21990:30054:30064:30070,0,RBL:209.85.214.194:@gmail.com:.lbl8.mailshell.net-62.50.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:25,LUA_SUMMARY:none X-HE-Tag: seed05_2971351b76f02 X-Filterd-Recvd-Size: 4522 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Dec 2019 11:31:24 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id p9so1730665plk.9 for ; Tue, 17 Dec 2019 03:31:24 -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:in-reply-to:references; bh=fFfoleXjv3JSEmvkK0O9oMZGbyG7YMfuDochkkrQvOQ=; b=Ay5w39y6OP8b3+PSyWbNiB80MxHJVJSkjW+k+erc0+AmU1eBRpUnMfmFdSpTt3lBiL WXKb1e+X82cm+QC6jSydUQ6aqBNsbSp40uxC77iTvEE/hBw1nGeZiGyQrZek3edQH7Gl ifi8kZqgJUVhbSMYNppmKS5VPIFpQoxn8FW8OZfVzMArfXENhsNhFjv7OoOs906svNnk UyazUX4Lne2F3b0VB4++90jelJF4NorPxOROqwdwtNfnKoAq9gzFSoiF/IYMstPeSHeg 3O7TOCPm2IasOAdlxc7HFvCLj70+9f37uu7qlYmhyeS8aHA9bjFxLAUttL9nUe8+YMnG okPg== 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:in-reply-to :references; bh=fFfoleXjv3JSEmvkK0O9oMZGbyG7YMfuDochkkrQvOQ=; b=KZqLC7P/3gT62vdijrMNlyi/bodSjSdA05rLMnWnmHdYwni/v0o76wVFJUy1xEXBH/ Si1/pDM0yFtIYMnrfO+mEiyHYTxlXYellC9HlBqqC3tp45CzUAYVv7u1w/CYfWaZAgiz Jda6IPPZiCEfOlSipZho4kfbge5EjE9WYRgZ5Bb2N9z1mkugODQp8PbRNO3Sm/c2k8V4 kDyI1xqGz1x7MwyEsSUoJYkj6CxZ6jfMhuALBUVbfmAWxbtDkqVr3M27N6qNGTdrdWF2 pvbResltxghXJFOM1t7XG9OVSZMzG8eOvPRo7rdmneTUobwHhbJXeQPbs4FFA7uteREK AyXg== X-Gm-Message-State: APjAAAU0Qf5VlHeqNNtrGkgVIYuyaPsQlN0Vy0m+wf/quSskWg2pAkWY Wl2/jSia0CRVCuExLrWKrOo= X-Google-Smtp-Source: APXvYqwgOIO9DkR9d5dmrB5DvMfBD6fXB5FS6maFa7bVNVo9BDd0ix+SDlXBo+0I1chqAKdB25eFeg== X-Received: by 2002:a17:902:9b86:: with SMTP id y6mr20608166plp.253.1576582283572; Tue, 17 Dec 2019 03:31:23 -0800 (PST) Received: from dev.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id q21sm26246460pff.105.2019.12.17.03.31.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 03:31:23 -0800 (PST) From: Yafang Shao To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, viro@zeniv.linux.org.uk Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Yafang Shao , Roman Gushchin Subject: [PATCH 2/4] mm, memcg: introduce MEMCG_PROT_SKIP for memcg zero usage case Date: Tue, 17 Dec 2019 06:29:17 -0500 Message-Id: <1576582159-5198-3-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1576582159-5198-1-git-send-email-laoar.shao@gmail.com> References: <1576582159-5198-1-git-send-email-laoar.shao@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: If the usage of a memcg is zero, we don't need to do useless work to scan it. That is a minor optimization. Cc: Roman Gushchin Signed-off-by: Yafang Shao --- include/linux/memcontrol.h | 1 + mm/memcontrol.c | 2 +- mm/vmscan.c | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 612a457..1a315c7 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -54,6 +54,7 @@ enum mem_cgroup_protection { MEMCG_PROT_NONE, MEMCG_PROT_LOW, MEMCG_PROT_MIN, + MEMCG_PROT_SKIP, /* For zero usage case */ }; struct mem_cgroup_reclaim_cookie { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index c5b5f74..f35fcca 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -6292,7 +6292,7 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root, usage = page_counter_read(&memcg->memory); if (!usage) - return MEMCG_PROT_NONE; + return MEMCG_PROT_SKIP; emin = memcg->memory.min; elow = memcg->memory.low; diff --git a/mm/vmscan.c b/mm/vmscan.c index 5a6445e..3c4c2da 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2677,6 +2677,12 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc) * thresholds (see get_scan_count). */ break; + case MEMCG_PROT_SKIP: + /* + * Skip scanning this memcg if the usage of it is + * zero. + */ + continue; } reclaimed = sc->nr_reclaimed;