From patchwork Wed Aug 1 12:23:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10552227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7FEFB13BB for ; Wed, 1 Aug 2018 12:24:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F16B2AB77 for ; Wed, 1 Aug 2018 12:24:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62FB72ABE6; Wed, 1 Aug 2018 12:24:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C78BE2AB77 for ; Wed, 1 Aug 2018 12:24:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 801B56B0007; Wed, 1 Aug 2018 08:24:00 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 744F36B026B; Wed, 1 Aug 2018 08:24:00 -0400 (EDT) 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 40E056B0006; Wed, 1 Aug 2018 08:24:00 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by kanga.kvack.org (Postfix) with ESMTP id BE71C6B0008 for ; Wed, 1 Aug 2018 08:23:59 -0400 (EDT) Received: by mail-wm0-f70.google.com with SMTP id q24-v6so3590601wmq.9 for ; Wed, 01 Aug 2018 05:23:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=ornNtZGLjdDbInVqSj+nx7qc7v1pmCahLcgawCtYU7A=; b=TNhIDlwFjtLmNS3rwQCoHl1u2i7yqpOFL4R5CPslssrKDIFxuQ7sqwH52c8UfdhmDk sQmHaRg2xlxODm8C5LPyopHlPEViH5M1Pf5AYR/TCWVntPquBMbG1ixBdpzihsd0uD5G hvkZs9q/yfnh4JTKabap1prkJjHVZWKnObrUfeOVe+FBuDFnL5H3rStT65EMVDHzc++7 /qJgb7xz5JIrBcEJW1fprGTeYnaQhmweK2jbsHOWMkWMfG0MBmhnRiQQu5vHhR82OoMO rPlfp3FiWm5UyX9prYTj4qTqyEUZoU4cPo+8wIsAdIwvhd9CO7kHuDTMUotbpXD49ZKq edkw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: AOUpUlGCfXb6BIk1c5YV2Zdzhy/K+5lyeGLF5R8hcW+yq66kkKg+1L7B 2JuF2LplNQFgd7vyMzA5lNqHLI7Cz5y048oY+H8vb+eCWkZW6esSB8qxBdKOrWB3xsNERqpLNp7 0jd235ArlTIVRozif9uHZF+5OrDil6gMTbrXFnIf+VyFq9b7Jt85UudNh7z7xJSjQqQx+j+6cBr fwFvGVG2H0u/ZlV2oP8RJ/VrlGndPBgP9JB8irN6M66vYSOjkDnB8FGfDdcSKJK9wZabfGekaXb zjweilrUiROgVNpNXeNGrzA4mfDMMgh7pNKxRqSd4GEV+SnnmZs+hERj2wg3fvMc49JSCeQq0OY fTQBxrxOB+mZJV1wpcjNZsPtsdQZgeGOfYrTDYRzpMbbq1VCu22BU1n77TOBZAEfRKo81aDs4Q= = X-Received: by 2002:adf:ffc7:: with SMTP id x7-v6mr24745870wrs.137.1533126239263; Wed, 01 Aug 2018 05:23:59 -0700 (PDT) X-Received: by 2002:adf:ffc7:: with SMTP id x7-v6mr24745818wrs.137.1533126238048; Wed, 01 Aug 2018 05:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533126238; cv=none; d=google.com; s=arc-20160816; b=U5YAx7RCtmPAqSSCWSRZOzqrWv7jixqt5e/vz69UXrRrWdaaFWgP7P2YLHos3DmQA9 pPOu0m6ZnTFap4oKCTo8jKcx01eO0ZYdrW0ikmt3NTR00mPLc73kiHDh1MNQiX7LtnTs qh95+B9ySrB2rycZkeBooGJ2WAvMavd+gxS0GTgXXeEpCkgRNpakOH8vnRwlIy7ykqRE RgX5BtHlIKFrTUPqn79YNANUVo73MYOucNkP/HweWJYvIyTiVzXMeY6y0HJl9dZ3UpLF mPFo41wTdVdX/QSK/ePf1cC6k0hhYDVzp6WWV5w2kN1nVqrhcTSAekqiYyrXVI200he4 eOuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ornNtZGLjdDbInVqSj+nx7qc7v1pmCahLcgawCtYU7A=; b=R/RjjXa+9eQQ3CZQCG0IfoSzpMIWXdI15iz+Xe6VTgD/HKKnJwmLBOVs+rmVv5OOl5 112vbfhkwC2XNry9lqE/m9uiNZdiE5adZgGipbimwHLYwxm+jPqq2Ii2f0/ewFinChrC YTnaDKCHAY0SuFSTCGZmfW5e551uzLOxc2Sm5SHUMY86OkyYb964KkUYM3RUEB9pufVk nkcXEEHA8hAsSy6wYHssMdHjMv0tt54cy8C9UU0iaYBpKwo769R50y8KiN8MkfOLGuPt ITBlZHRoPa2/hoUXUuFEZvrY6q+8UUBie/n9WtAHsHU3YhJyTGlZ228vZnou9On6XKMW +IfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 203-v6sor1461572wme.25.2018.08.01.05.23.57 for (Google Transport Security); Wed, 01 Aug 2018 05:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: AAOMgpdADN54w3AEgylfn2uo+tjdYllrnKQ3Ko8nlYwAujih9Xn79Ffrw5H1PySEQPrATJl0SRFBpg== X-Received: by 2002:a1c:8313:: with SMTP id f19-v6mr2493425wmd.144.1533126237749; Wed, 01 Aug 2018 05:23:57 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id a14-v6sm4891640wmb.44.2018.08.01.05.23.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Aug 2018 05:23:56 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id EFDAD124540; Wed, 1 Aug 2018 14:23:54 +0200 (CEST) From: osalvador@techadventures.net To: akpm@linux-foundation.org Cc: mhocko@suse.com, vbabka@suse.cz, pasha.tatashin@oracle.com, mgorman@techsingularity.net, aaron.lu@intel.com, iamjoonsoo.kim@lge.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dan.j.williams@intel.com, david@redhat.com, Oscar Salvador Subject: [PATCH v6 2/5] mm: access zone->node via zone_to_nid() and zone_set_nid() Date: Wed, 1 Aug 2018 14:23:45 +0200 Message-Id: <20180801122348.21588-3-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180801122348.21588-1-osalvador@techadventures.net> References: <20180801122348.21588-1-osalvador@techadventures.net> 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Pavel Tatashin zone->node is configured only when CONFIG_NUMA=y, so it is a good idea to have inline functions to access this field in order to avoid ifdef's in c files. Signed-off-by: Pavel Tatashin Signed-off-by: Oscar Salvador Reviewed-by: Oscar Salvador Acked-by: Michal Hocko Acked-by: Vlastimil Babka --- include/linux/mm.h | 9 --------- include/linux/mmzone.h | 26 ++++++++++++++++++++------ mm/mempolicy.c | 4 ++-- mm/mm_init.c | 9 ++------- mm/page_alloc.c | 10 ++++------ 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 644c6329336b..70edbc3f21a8 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -957,15 +957,6 @@ static inline int page_zone_id(struct page *page) return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK; } -static inline int zone_to_nid(struct zone *zone) -{ -#ifdef CONFIG_NUMA - return zone->node; -#else - return 0; -#endif -} - #ifdef NODE_NOT_IN_PAGE_FLAGS extern int page_to_nid(const struct page *page); #else diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 83b1d11e90eb..805b990b27ab 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -841,6 +841,25 @@ static inline bool populated_zone(struct zone *zone) return zone->present_pages; } +#ifdef CONFIG_NUMA +static inline int zone_to_nid(struct zone *zone) +{ + return zone->node; +} + +static inline void zone_set_nid(struct zone *zone, int nid) +{ + zone->node = nid; +} +#else +static inline int zone_to_nid(struct zone *zone) +{ + return 0; +} + +static inline void zone_set_nid(struct zone *zone, int nid) {} +#endif + extern int movable_zone; #ifdef CONFIG_HIGHMEM @@ -956,12 +975,7 @@ static inline int zonelist_zone_idx(struct zoneref *zoneref) static inline int zonelist_node_idx(struct zoneref *zoneref) { -#ifdef CONFIG_NUMA - /* zone_to_nid not available in this context */ - return zoneref->zone->node; -#else - return 0; -#endif /* CONFIG_NUMA */ + return zone_to_nid(zoneref->zone); } struct zoneref *__next_zones_zonelist(struct zoneref *z, diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 4861ba738d6f..da858f794eb6 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -1784,7 +1784,7 @@ unsigned int mempolicy_slab_node(void) zonelist = &NODE_DATA(node)->node_zonelists[ZONELIST_FALLBACK]; z = first_zones_zonelist(zonelist, highest_zoneidx, &policy->v.nodes); - return z->zone ? z->zone->node : node; + return z->zone ? zone_to_nid(z->zone) : node; } default: @@ -2326,7 +2326,7 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long node_zonelist(numa_node_id(), GFP_HIGHUSER), gfp_zone(GFP_HIGHUSER), &pol->v.nodes); - polnid = z->zone->node; + polnid = zone_to_nid(z->zone); break; default: diff --git a/mm/mm_init.c b/mm/mm_init.c index 5b72266b4b03..6838a530789b 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -53,13 +53,8 @@ void __init mminit_verify_zonelist(void) zone->name); /* Iterate the zonelist */ - for_each_zone_zonelist(zone, z, zonelist, zoneid) { -#ifdef CONFIG_NUMA - pr_cont("%d:%s ", zone->node, zone->name); -#else - pr_cont("0:%s ", zone->name); -#endif /* CONFIG_NUMA */ - } + for_each_zone_zonelist(zone, z, zonelist, zoneid) + pr_cont("%d:%s ", zone_to_nid(zone), zone->name); pr_cont("\n"); } } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index f5e36713c5d4..295977c6acae 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2915,10 +2915,10 @@ static inline void zone_statistics(struct zone *preferred_zone, struct zone *z) if (!static_branch_likely(&vm_numa_stat_key)) return; - if (z->node != numa_node_id()) + if (zone_to_nid(z) != numa_node_id()) local_stat = NUMA_OTHER; - if (z->node == preferred_zone->node) + if (zone_to_nid(z) == zone_to_nid(preferred_zone)) __inc_numa_state(z, NUMA_HIT); else { __inc_numa_state(z, NUMA_MISS); @@ -5284,7 +5284,7 @@ int local_memory_node(int node) z = first_zones_zonelist(node_zonelist(node, GFP_KERNEL), gfp_zone(GFP_KERNEL), NULL); - return z->zone->node; + return zone_to_nid(z->zone); } #endif @@ -6301,9 +6301,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat) * And all highmem pages will be managed by the buddy system. */ zone->managed_pages = freesize; -#ifdef CONFIG_NUMA - zone->node = nid; -#endif + zone_set_nid(zone, nid); zone->name = zone_names[j]; zone->zone_pgdat = pgdat; spin_lock_init(&zone->lock);