Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp626122pxb; Tue, 9 Feb 2021 08:36:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJx77Ys7mK5M9Tsgi0CPvcQOPP6CaaI35fyEBahI6aoujzZe4O1pMExT8qJDOP/Cd50u3Llo X-Received: by 2002:a05:6402:5212:: with SMTP id s18mr21845646edd.240.1612888612740; Tue, 09 Feb 2021 08:36:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612888612; cv=none; d=google.com; s=arc-20160816; b=yngle+evdD9hGZ3NuiX4neF+1B8gEob7oqKB3GIlnZUtrUEensdH+p44D/R1uNzB3b qWFNhaOgtqvmLPubMDphQcLJJA+V4jPPJQfcGe+eTP8dnBOLl+458pdKFp7EsdfnGEJS 7iXUp9BZqozDLuKpL6y89Ov1937ZkKKmNquKhNLaIUGxKUCibqUbvfL/oRU53pMWC58N E/HUdGJ3jf1tJzXH0uJOr4yqmVw1a/rrWtMeV3x1ZOUBzji5GpApkXJTJjv7j9ZvEF0T iXsZYJpiD2atbt8KIdKdPnHYke15l3viIrYDp5bUHSPdF+3qw1UxhMtyB8d0dE3LgWzT E9lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t4R65KE0u5JIY01fjm4wgVu+gu5q/lvBl+LPH4oeHXQ=; b=krIv7I0CWzjWlyF6AnucT2KpbMwJZAXzQZa3Rz1uE/Q5T7kaB7+q2uA6KdFQN/foRP HSZHy4NO6C9T2/vzu0fTlSc7ildvNeB727BnbA2VMiY/kp2dIMMI+Xee0rcTqtqtD0sK vW8Q0DEhhF5Nlpt3AXA7HijWrsAxWvXmzA6mre5JwIhIgiLSbOKPLLZQwJbmHI7DGrE/ 94r5DLMCCSrcFjSeByjbRYRJZEsvXnnrSxI0q/iAgUV5/N0A55g9B2JHC7gdpNjgs6Ur NI/tnllOOD8rQ706gEctRInzFlzoM0ZrAbOisscoODcVKX73jAk+tr75+eI18VYYDhz1 NuqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=Qx1hsNIB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h8si16348625ejj.71.2021.02.09.08.36.29; Tue, 09 Feb 2021 08:36:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=Qx1hsNIB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232894AbhBIQer (ORCPT + 99 others); Tue, 9 Feb 2021 11:34:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232814AbhBIQeK (ORCPT ); Tue, 9 Feb 2021 11:34:10 -0500 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDBFAC061788 for ; Tue, 9 Feb 2021 08:33:30 -0800 (PST) Received: by mail-qt1-x836.google.com with SMTP id x3so11461213qti.5 for ; Tue, 09 Feb 2021 08:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t4R65KE0u5JIY01fjm4wgVu+gu5q/lvBl+LPH4oeHXQ=; b=Qx1hsNIBKzPGS5WVp3uPVWOgmopu/NZpQU4ukJDvflvwPNsDFADDbI29Hl7diG7zNW 4zyEsfd1/hFlF2CdIg9JLdL/DDxuPMPk6ezPNlI76GiQs9VLyPa2ncWtGG6Zd2nxMDyn KPDKF6bBe7CKRU9u3u31mSENocHiAwJBbECTFbx2GFt29+pp/oJHT9RR6cf+9vCJvBai PXgDhlJsS30qrNHQ1OIex6lex782vvKQWOmTykOaCpgR1kPOOGVlqBUctNY6yKov3EM7 dOzSEBcvX32urg0+9MAvnFczOMDgHR059MT21DN3AQrz90HikGRPm9RpqBaITUe3Iteg m6iA== 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:mime-version:content-transfer-encoding; bh=t4R65KE0u5JIY01fjm4wgVu+gu5q/lvBl+LPH4oeHXQ=; b=Qx1BbRK9ZT9c/w6bQ5TrTSoVvljqDMyGT+khjAMSaZIhn/RorYUDfVz6VP+2cepUgz CeiJPmhNRnLWNJ8ur4okfGzBexVH0t1wABFqspAm8EjaIj7CUYVHg/54T9nnqAV6SiSd y+h372rBCouCc2kDa0Z6Cn7gbxpdq436zb+zhtbz2fhExnoZRtlFaoszRZNay1hsOqJW pocSlY22OxyzRQFTbrx/pFVYHQysefhqzoRlBdhXJjgdO8thzAZqzBtFZLGjS1UGusDa JiH4tz6ke+zEy5J75chzlEi9R3m9fn0/mfQZus8roKlV6eqGX8+dahTbQHxd5iebDf3R zbjQ== X-Gm-Message-State: AOAM5318dM4RERluqD1wc28rpfqHr9MDi5ZYTZnAy7wOTwlphiCPzSgl +gkm188LJ8SLSodwlrHUyov8eg== X-Received: by 2002:ac8:7501:: with SMTP id u1mr21872039qtq.330.1612888410221; Tue, 09 Feb 2021 08:33:30 -0800 (PST) Received: from localhost (70.44.39.90.res-cmts.bus.ptd.net. [70.44.39.90]) by smtp.gmail.com with ESMTPSA id f26sm7099548qkh.80.2021.02.09.08.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 08:33:29 -0800 (PST) From: Johannes Weiner To: Andrew Morton Cc: Tejun Heo , Michal Hocko , Roman Gushchin , Shakeel Butt , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH v3 2/8] mm: memcontrol: kill mem_cgroup_nodeinfo() Date: Tue, 9 Feb 2021 11:32:58 -0500 Message-Id: <20210209163304.77088-3-hannes@cmpxchg.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210209163304.77088-1-hannes@cmpxchg.org> References: <20210209163304.77088-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No need to encapsulate a simple struct member access. Signed-off-by: Johannes Weiner Reviewed-by: Shakeel Butt Reviewed-by: Roman Gushchin Acked-by: Michal Hocko --- include/linux/memcontrol.h | 8 +------- mm/memcontrol.c | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 7a38a1517a05..c7f387a6233e 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -602,12 +602,6 @@ void mem_cgroup_uncharge_list(struct list_head *page_list); void mem_cgroup_migrate(struct page *oldpage, struct page *newpage); -static struct mem_cgroup_per_node * -mem_cgroup_nodeinfo(struct mem_cgroup *memcg, int nid) -{ - return memcg->nodeinfo[nid]; -} - /** * mem_cgroup_lruvec - get the lru list vector for a memcg & node * @memcg: memcg of the wanted lruvec @@ -631,7 +625,7 @@ static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg, if (!memcg) memcg = root_mem_cgroup; - mz = mem_cgroup_nodeinfo(memcg, pgdat->node_id); + mz = memcg->nodeinfo[pgdat->node_id]; lruvec = &mz->lruvec; out: /* diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 8120d565dd79..7e05a4ebf80f 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -414,13 +414,14 @@ static int memcg_expand_one_shrinker_map(struct mem_cgroup *memcg, int size, int old_size) { struct memcg_shrinker_map *new, *old; + struct mem_cgroup_per_node *pn; int nid; lockdep_assert_held(&memcg_shrinker_map_mutex); for_each_node(nid) { - old = rcu_dereference_protected( - mem_cgroup_nodeinfo(memcg, nid)->shrinker_map, true); + pn = memcg->nodeinfo[nid]; + old = rcu_dereference_protected(pn->shrinker_map, true); /* Not yet online memcg */ if (!old) return 0; @@ -433,7 +434,7 @@ static int memcg_expand_one_shrinker_map(struct mem_cgroup *memcg, memset(new->map, (int)0xff, old_size); memset((void *)new->map + old_size, 0, size - old_size); - rcu_assign_pointer(memcg->nodeinfo[nid]->shrinker_map, new); + rcu_assign_pointer(pn->shrinker_map, new); call_rcu(&old->rcu, memcg_free_shrinker_map_rcu); } @@ -450,7 +451,7 @@ static void memcg_free_shrinker_maps(struct mem_cgroup *memcg) return; for_each_node(nid) { - pn = mem_cgroup_nodeinfo(memcg, nid); + pn = memcg->nodeinfo[nid]; map = rcu_dereference_protected(pn->shrinker_map, true); kvfree(map); rcu_assign_pointer(pn->shrinker_map, NULL); @@ -713,7 +714,7 @@ static void mem_cgroup_remove_from_trees(struct mem_cgroup *memcg) int nid; for_each_node(nid) { - mz = mem_cgroup_nodeinfo(memcg, nid); + mz = memcg->nodeinfo[nid]; mctz = soft_limit_tree_node(nid); if (mctz) mem_cgroup_remove_exceeded(mz, mctz); @@ -796,7 +797,7 @@ parent_nodeinfo(struct mem_cgroup_per_node *pn, int nid) parent = parent_mem_cgroup(pn->memcg); if (!parent) return NULL; - return mem_cgroup_nodeinfo(parent, nid); + return parent->nodeinfo[nid]; } void __mod_memcg_lruvec_state(struct lruvec *lruvec, enum node_stat_item idx, @@ -1163,7 +1164,7 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, if (reclaim) { struct mem_cgroup_per_node *mz; - mz = mem_cgroup_nodeinfo(root, reclaim->pgdat->node_id); + mz = root->nodeinfo[reclaim->pgdat->node_id]; iter = &mz->iter; if (prev && reclaim->generation != iter->generation) @@ -1265,7 +1266,7 @@ static void __invalidate_reclaim_iterators(struct mem_cgroup *from, int nid; for_each_node(nid) { - mz = mem_cgroup_nodeinfo(from, nid); + mz = from->nodeinfo[nid]; iter = &mz->iter; cmpxchg(&iter->position, dead_memcg, NULL); } @@ -2438,7 +2439,7 @@ static int memcg_hotplug_cpu_dead(unsigned int cpu) struct mem_cgroup_per_node *pn; long x; - pn = mem_cgroup_nodeinfo(memcg, nid); + pn = memcg->nodeinfo[nid]; lstatc = per_cpu_ptr(pn->lruvec_stat_cpu, cpu); x = lstatc->count[i]; @@ -4145,7 +4146,7 @@ static int memcg_stat_show(struct seq_file *m, void *v) unsigned long file_cost = 0; for_each_online_pgdat(pgdat) { - mz = mem_cgroup_nodeinfo(memcg, pgdat->node_id); + mz = memcg->nodeinfo[pgdat->node_id]; anon_cost += mz->lruvec.anon_cost; file_cost += mz->lruvec.file_cost; -- 2.30.0