From patchwork Wed Nov 4 15:14:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Su X-Patchwork-Id: 11880953 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 4265E921 for ; Wed, 4 Nov 2020 15:15:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BF70020759 for ; Wed, 4 Nov 2020 15:15:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="gYO0gQUM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF70020759 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CB42F6B0073; Wed, 4 Nov 2020 10:15:30 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C3FB86B007D; Wed, 4 Nov 2020 10:15:30 -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 B05A46B007E; Wed, 4 Nov 2020 10:15:30 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 7EA336B0073 for ; Wed, 4 Nov 2020 10:15:30 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2012F8249980 for ; Wed, 4 Nov 2020 15:15:30 +0000 (UTC) X-FDA: 77447084820.13.nerve24_5d07bbf272c2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id F21CF18140B67 for ; Wed, 4 Nov 2020 15:15:29 +0000 (UTC) X-Spam-Summary: 1,0,0,c0c89c5f3d062751,d41d8cd98f00b204,sh_def@163.com,,RULES_HIT:41:355:379:582:800:960:973:988:989:1152:1260:1277:1312:1313:1314:1345:1437:1516:1518:1519:1534:1543:1593:1594:1595:1596:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2895:3138:3139:3140:3141:3142:3354:3865:3866:3871:3872:4605:5007:6261:6653:10004:10400:11026:11232:11334:11473:11658:11914:12043:12048:12296:12297:12438:12555:12895:13439:13895:14096:14097:14181:14394:14721:21080:21627:21990:30054:30070:30090,0,RBL:220.181.12.15:@163.com:.lbl8.mailshell.net-62.50.2.100 66.100.201.100;04yg97cpb4acyoq3anm448thfqb3kopbesezqh9yawhpjoff8ndxjst81msmx6x.7kdhug3farifgugfudo3n9n5wqkpywfzo789j3esnnzgqt777xa5wsdtucf8jo4.n-lbl8.mailshell.net-223.238.255.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:67,LUA_SUMMARY:none X-HE-Tag: nerve24_5d07bbf272c2 X-Filterd-Recvd-Size: 4856 Received: from m12-15.163.com (m12-15.163.com [220.181.12.15]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Wed, 4 Nov 2020 15:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=VSar2 wdEREwQtbNXW3U+mTBkXhxZPJuA5rzAVzEzkCs=; b=gYO0gQUMv+jpq36YMD8Fi UfjghN2SHyz1DTDEjGMQdEL1wXxcaOdGzTKDvu4Ir06UOO/JvNOY7AxzOcGx7xiP DYi0QxthHpC4FUhM15wKo4rdIwx3i9DsJj0U0gCi2thsbWXcSU9bok3BZ/Qqt+4N URBSnA7boydsgxPSTus6G4= Received: from localhost (unknown [101.86.211.214]) by smtp11 (Coremail) with SMTP id D8CowACXoytxxaJfODSOGQ--.63470S2; Wed, 04 Nov 2020 23:14:58 +0800 (CST) Date: Wed, 4 Nov 2020 23:14:57 +0800 From: Hui Su To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: sh_def@163.com Subject: [PATCH] mm/memcontrol: replace '== root_mem_cgroup' with mem_cgroup_is_root Message-ID: <20201104151457.GA108301@rlk> MIME-Version: 1.0 Content-Disposition: inline X-CM-TRANSID: D8CowACXoytxxaJfODSOGQ--.63470S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxCFWUArWkJr17uw4UJrW3Awb_yoW5ZFWDpF sIy3W3Ww4rArW5Xr1fKayq9a4rAa18Xa15JryxJw1xZw13Jw15tF17Ar1UJFyUCF9xGry7 JFs0yw18Gw4jvFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U5rcfUUUUU= X-Originating-IP: [101.86.211.214] X-CM-SenderInfo: xvkbvvri6rljoofrz/xtbBDhfSX1rbK7KxjQAAsw X-Bogosity: Ham, tests=bogofilter, spamicity=0.334937, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: We have supplied the inline func: mem_cgroup_is_root(). So we may use mem_cgroup_is_root() instead of using 'memcg == root_mem_cgroup' or 'memcg != root_mem_cgroup' directly, which is more readable. Signed-off-by: Hui Su --- mm/memcontrol.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3dcbf24d2227..ac7af04ef88f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -868,7 +868,7 @@ void __mod_lruvec_slab_state(void *p, enum node_stat_item idx, int val) memcg = mem_cgroup_from_obj(p); /* Untracked pages have no memcg, no lruvec. Update only the node */ - if (!memcg || memcg == root_mem_cgroup) { + if (!memcg || mem_cgroup_is_root(memcg)) { __mod_node_page_state(pgdat, idx, val); } else { lruvec = mem_cgroup_lruvec(memcg, pgdat); @@ -1312,7 +1312,7 @@ int mem_cgroup_scan_tasks(struct mem_cgroup *memcg, struct mem_cgroup *iter; int ret = 0; - BUG_ON(memcg == root_mem_cgroup); + BUG_ON(mem_cgroup_is_root(memcg)); for_each_mem_cgroup_tree(iter, memcg) { struct css_task_iter it; @@ -2069,7 +2069,7 @@ struct mem_cgroup *mem_cgroup_get_oom_group(struct task_struct *victim, rcu_read_lock(); memcg = mem_cgroup_from_task(victim); - if (memcg == root_mem_cgroup) + if (mem_cgroup_is_root(memcg)) goto out; /* @@ -2978,7 +2978,7 @@ __always_inline struct obj_cgroup *get_obj_cgroup_from_current(void) else memcg = mem_cgroup_from_task(current); - for (; memcg != root_mem_cgroup; memcg = parent_mem_cgroup(memcg)) { + for (; !mem_cgroup_is_root(memcg); memcg = parent_mem_cgroup(memcg)) { objcg = rcu_dereference(memcg->objcg); if (objcg && obj_cgroup_tryget(objcg)) break; @@ -7027,7 +7027,7 @@ void mem_cgroup_sk_alloc(struct sock *sk) rcu_read_lock(); memcg = mem_cgroup_from_task(current); - if (memcg == root_mem_cgroup) + if (mem_cgroup_is_root(memcg)) goto out; if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !memcg->tcpmem_active) goto out; @@ -7156,7 +7156,7 @@ static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg) * The root cgroup cannot be destroyed, so it's refcount must * always be >= 1. */ - if (WARN_ON_ONCE(memcg == root_mem_cgroup)) { + if (WARN_ON_ONCE(mem_cgroup_is_root(memcg))) { VM_BUG_ON(1); break; } @@ -7313,7 +7313,7 @@ long mem_cgroup_get_nr_swap_pages(struct mem_cgroup *memcg) if (cgroup_memory_noswap || !cgroup_subsys_on_dfl(memory_cgrp_subsys)) return nr_swap_pages; - for (; memcg != root_mem_cgroup; memcg = parent_mem_cgroup(memcg)) + for (; !mem_cgroup_is_root(memcg); memcg = parent_mem_cgroup(memcg)) nr_swap_pages = min_t(long, nr_swap_pages, READ_ONCE(memcg->swap.max) - page_counter_read(&memcg->swap)); @@ -7335,7 +7335,7 @@ bool mem_cgroup_swap_full(struct page *page) if (!memcg) return false; - for (; memcg != root_mem_cgroup; memcg = parent_mem_cgroup(memcg)) { + for (; !mem_cgroup_is_root(memcg); memcg = parent_mem_cgroup(memcg)) { unsigned long usage = page_counter_read(&memcg->swap); if (usage * 2 >= READ_ONCE(memcg->swap.high) ||