From patchwork Wed Nov 4 14:25:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Su X-Patchwork-Id: 11880805 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 B1A85139F for ; Wed, 4 Nov 2020 14:37:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4C8AE20756 for ; Wed, 4 Nov 2020 14:37:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="fS4axkME" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C8AE20756 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 63C876B0036; Wed, 4 Nov 2020 09:37:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 614416B005D; Wed, 4 Nov 2020 09:37:00 -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 5000F6B0068; Wed, 4 Nov 2020 09:37:00 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id 236B06B0036 for ; Wed, 4 Nov 2020 09:37:00 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9FF7F181AC9CC for ; Wed, 4 Nov 2020 14:36:59 +0000 (UTC) X-FDA: 77446987758.29.star69_07127dc272c2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 0340318014ED0 for ; Wed, 4 Nov 2020 14:27:09 +0000 (UTC) X-Spam-Summary: 1,0,0,19573a42d9c477e9,d41d8cd98f00b204,sh_def@163.com,,RULES_HIT:41:69:355:379:582:800:960:973:988:989:1152:1260:1277:1312:1313:1314:1345:1437:1516:1518:1519:1535:1543:1593:1594:1595:1596:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2890:2901:3138:3139:3140:3141:3142:3355:3865:3866:3867:3868:3870:3871:3872:4042:4250:4321:4605:5007:6261:6653:6737:7875:9010:9592:10004:10400:11026:11334:11658:11914:12043:12048:12114:12296:12297:12438:12555:12683:12895:12986:13439:13895:14096:14097:14110:14181:14394:14721:21080:21433:21450:21451:21627:21966:21990:30001:30054,0,RBL:220.181.12.16:@163.com:.lbl8.mailshell.net-62.50.2.100 66.100.201.100;04yrnn9cnb6y4asxqtf9zwqwoiwidypapfs3kzz1ffr7h6i5bbj5mgcnsimbtut.qy1i4qcxn76sjozb4sd59xzbm4dtstshwz3yaaq63obhumcn4zkiqb864nuecwz.g-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:68,LUA_SUMMARY:none X-HE-Tag: star69_07127dc272c2 X-Filterd-Recvd-Size: 5004 Received: from m12-16.163.com (m12-16.163.com [220.181.12.16]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Wed, 4 Nov 2020 14:27:08 +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=+7b6f oOiP5Z9YBXE2KwaQcndnG3JikUcOzlmE2YTnls=; b=fS4axkMErEOzoG9saGOnX bIQbf3lUfxOnbHkqEOBpybEr7XmzYxwHLvd1l0rxjIT3k9cLPGdX6ZXHoiI51PhV Eri9QeKQopNabCeE6LuhYrJcwSSQcenN46qOnA0THPFKLNcAyMznz/ZTKGkby0m0 GN32nARCTwKsOs2D1oWVn8= Received: from localhost (unknown [101.86.211.214]) by smtp12 (Coremail) with SMTP id EMCowADnFGrMuaJffmFhJw--.17147S2; Wed, 04 Nov 2020 22:25:17 +0800 (CST) Date: Wed, 4 Nov 2020 22:25:16 +0800 From: Hui Su To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org, shakeelb@google.com, guro@fb.com, laoar.shao@gmail.com, chris@chrisdown.name, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org Cc: sh_def@163.com Subject: [PATCH] mm/memcontrol:rewrite mem_cgroup_page_lruvec() Message-ID: <20201104142516.GA106571@rlk> MIME-Version: 1.0 Content-Disposition: inline X-CM-TRANSID: EMCowADnFGrMuaJffmFhJw--.17147S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxWF4UAryrJFyrGry7Kr15Arb_yoW5ur4xpF ZxJ3W3A398JrWYgr1xta1q9a4fZa1xJw43Jr17Jw1SyF13K34Fq3W2kr1rJFWUuF9ayrnr trZ0kr18G3yqvFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U0iiDUUUUU= X-Originating-IP: [101.86.211.214] X-CM-SenderInfo: xvkbvvri6rljoofrz/1tbitw3SX1aEGR9xmQAAsL X-Bogosity: Ham, tests=bogofilter, spamicity=0.130290, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: mem_cgroup_page_lruvec() in memcontrol.c and mem_cgroup_lruvec() in memcontrol.h is very similar except for the param(page and memcg) which also can be convert to each other. So rewrite mem_cgroup_page_lruvec() with mem_cgroup_lruvec(). Signed-off-by: Hui Su Acked-by: Michal Hocko Acked-by: Johannes Weiner Reviewed-by: Shakeel Butt --- include/linux/memcontrol.h | 18 +++++++++++++++-- mm/memcontrol.c | 40 -------------------------------------- 2 files changed, 16 insertions(+), 42 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index e391e3c56de5..a586363fb766 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -457,9 +457,10 @@ mem_cgroup_nodeinfo(struct mem_cgroup *memcg, int nid) /** * mem_cgroup_lruvec - get the lru list vector for a memcg & node * @memcg: memcg of the wanted lruvec + * @pgdat: pglist_data * * Returns the lru list vector holding pages for a given @memcg & - * @node combination. This can be the node lruvec, if the memory + * @pgdat combination. This can be the node lruvec, if the memory * controller is disabled. */ static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg, @@ -489,7 +490,20 @@ static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg, return lruvec; } -struct lruvec *mem_cgroup_page_lruvec(struct page *, struct pglist_data *); +/** + * mem_cgroup_page_lruvec - return lruvec for isolating/putting an LRU page + * @page: the page + * @pgdat: pgdat of the page + * + * This function relies on page->mem_cgroup being stable. + */ +static inline struct lruvec *mem_cgroup_page_lruvec(struct page *page, + struct pglist_data *pgdat) +{ + struct mem_cgroup *memcg = page->mem_cgroup; + + return mem_cgroup_lruvec(memcg, pgdat); +} struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p); diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 3dcbf24d2227..9d4e1150b194 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1330,46 +1330,6 @@ int mem_cgroup_scan_tasks(struct mem_cgroup *memcg, return ret; } -/** - * mem_cgroup_page_lruvec - return lruvec for isolating/putting an LRU page - * @page: the page - * @pgdat: pgdat of the page - * - * This function relies on page->mem_cgroup being stable - see the - * access rules in commit_charge(). - */ -struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct pglist_data *pgdat) -{ - struct mem_cgroup_per_node *mz; - struct mem_cgroup *memcg; - struct lruvec *lruvec; - - if (mem_cgroup_disabled()) { - lruvec = &pgdat->__lruvec; - goto out; - } - - memcg = page->mem_cgroup; - /* - * Swapcache readahead pages are added to the LRU - and - * possibly migrated - before they are charged. - */ - if (!memcg) - memcg = root_mem_cgroup; - - mz = mem_cgroup_page_nodeinfo(memcg, page); - lruvec = &mz->lruvec; -out: - /* - * Since a node can be onlined after the mem_cgroup was created, - * we have to be prepared to initialize lruvec->zone here; - * and if offlined then reonlined, we need to reinitialize it. - */ - if (unlikely(lruvec->pgdat != pgdat)) - lruvec->pgdat = pgdat; - return lruvec; -} - /** * mem_cgroup_update_lru_size - account for adding or removing an lru page * @lruvec: mem_cgroup per zone lru vector