From patchwork Tue Jun 22 12:15:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12337155 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7EA5C2B9F4 for ; Tue, 22 Jun 2021 12:26:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 567CE61001 for ; Tue, 22 Jun 2021 12:26:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 567CE61001 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E3E336B007B; Tue, 22 Jun 2021 08:26:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E15276B0082; Tue, 22 Jun 2021 08:26:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDCE76B0083; Tue, 22 Jun 2021 08:26:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0059.hostedemail.com [216.40.44.59]) by kanga.kvack.org (Postfix) with ESMTP id 997936B007B for ; Tue, 22 Jun 2021 08:26:50 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 43E8C824999B for ; Tue, 22 Jun 2021 12:26:50 +0000 (UTC) X-FDA: 78281283780.20.A9342E3 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf10.hostedemail.com (Postfix) with ESMTP id D76484006F2D for ; Tue, 22 Jun 2021 12:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Fnblz5Exlm2MS7V9ban3wbSDxZOMhSnBAHMw8i0wBj8=; b=dBnYlYDT1IQHX8+Ztc9RJdrODX YUqO/6ESh0Ntk1DYahyKY/CMIAi+g6EkoS5EAvK51j7IJDqbLhRhptO2Txxa4m5+WIscEkFSmc4HS p3yCu+p4ML+DrvbsMnYOxsqfn9K6Th/7Kv6d4n4TpwZV7U990mElrOwjTdpbsWxI+JVsUiuY9ZQyM oYzsw0ilyYpohoXZO94+bYtbqzSAEI253LbHmfI10x8h6fV0hH39aF9Mh1l8GcdIvXpxi2a9Yhkrj qf0WKUigJEGG9KHIMfOT8DNWgbIVm/egRGdoQszTD9djNoaCMS0tjgxhDNYz4q2zw6doqUnxl/ttf Ksx9LBKg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvfSw-00EGr2-3z; Tue, 22 Jun 2021 12:25:24 +0000 From: "Matthew Wilcox (Oracle)" To: akpm@linux-foundation.org Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 12/46] mm/memcg: Use the node id in mem_cgroup_update_tree() Date: Tue, 22 Jun 2021 13:15:17 +0100 Message-Id: <20210622121551.3398730-13-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210622121551.3398730-1-willy@infradead.org> References: <20210622121551.3398730-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D76484006F2D Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=dBnYlYDT; spf=none (imf10.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Stat-Signature: qdqjybf577rhifh6q8jdhp8t615nywcz X-HE-Tag: 1624364809-368113 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: Hoist the page_to_nid() call from mem_cgroup_page_nodeinfo() into mem_cgroup_update_tree(). That lets us call soft_limit_tree_node() and delete soft_limit_tree_from_page() altogether. Saves 42 bytes of kernel text on my config. Signed-off-by: Matthew Wilcox (Oracle) --- mm/memcontrol.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1204c6a0c671..7423cb11eb88 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -453,10 +453,8 @@ ino_t page_cgroup_ino(struct page *page) } static struct mem_cgroup_per_node * -mem_cgroup_page_nodeinfo(struct mem_cgroup *memcg, struct page *page) +mem_cgroup_nodeinfo(struct mem_cgroup *memcg, int nid) { - int nid = page_to_nid(page); - return memcg->nodeinfo[nid]; } @@ -466,14 +464,6 @@ soft_limit_tree_node(int nid) return soft_limit_tree.rb_tree_per_node[nid]; } -static struct mem_cgroup_tree_per_node * -soft_limit_tree_from_page(struct page *page) -{ - int nid = page_to_nid(page); - - return soft_limit_tree.rb_tree_per_node[nid]; -} - static void __mem_cgroup_insert_exceeded(struct mem_cgroup_per_node *mz, struct mem_cgroup_tree_per_node *mctz, unsigned long new_usage_in_excess) @@ -549,8 +539,9 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page) unsigned long excess; struct mem_cgroup_per_node *mz; struct mem_cgroup_tree_per_node *mctz; + int nid = page_to_nid(page); - mctz = soft_limit_tree_from_page(page); + mctz = soft_limit_tree_node(nid); if (!mctz) return; /* @@ -558,7 +549,7 @@ static void mem_cgroup_update_tree(struct mem_cgroup *memcg, struct page *page) * because their event counter is not touched. */ for (; memcg; memcg = parent_mem_cgroup(memcg)) { - mz = mem_cgroup_page_nodeinfo(memcg, page); + mz = mem_cgroup_nodeinfo(memcg, nid); excess = soft_limit_excess(memcg); /* * We have to update the tree if mz is on RB-tree or