From patchwork Mon Jul 30 10:17:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10548857 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 57072A754 for ; Mon, 30 Jul 2018 10:18:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4560929703 for ; Mon, 30 Jul 2018 10:18:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39DE329706; Mon, 30 Jul 2018 10:18:13 +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 9F88529703 for ; Mon, 30 Jul 2018 10:18:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E8386B0006; Mon, 30 Jul 2018 06:18:07 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 147966B0008; Mon, 30 Jul 2018 06:18:07 -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 F013A6B000C; Mon, 30 Jul 2018 06:18:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 960DB6B0008 for ; Mon, 30 Jul 2018 06:18:06 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id u21-v6so7641684wmc.8 for ; Mon, 30 Jul 2018 03:18:06 -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=r3FUumIztPDwO6lIdEH4/NlXhd3R05jzu97rMbjyVnY=; b=TbsVUYlg7pN50FEQbRyPuEtpuonpiy96hBZ4qmIDAWEDh2dQTYIKtEmKqLTCsdyEIQ 9z4KP3bJPgyfZl5oMnIoQxexfPufHYF6ATTZlMc7PunY+OTrhflQ+AOx+hqV6HwcyP6k Pl5IZ1tfk5Ootka+o6g3xjs8anLRlh//92pDDJCZgGgxugNsgPu1Q2C6juQ27DEwLrNS CZYemYJHqxcPPNpjkEkPXAtYJInvtTA9gI0ParWUpBIFAZGyA6j3/at+F13EsZPMSm1D tNBqKB4qGuVquuAAoFmDhAn0W1S86snEMoAIuJo3Q5HT07NVk3Z95/6wPzkBeKu7PPMP u8bQ== 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: AOUpUlFcwGkMCzUfiyZMkMtAc/s3CJ65klixCPuJXmNO164nvd9S7ijp 0vPtEdF2XKGS5PYAyZST0fxJRtiwknfFdYgIxbhYI1EkJ824cP3nLpe0V/UXCd9MxG3VKkrl9vW Dfr8TUbsiByeg8laU/nnxviCpeTyWwM2vk/Alle1Y5x9c6QrWFF2XCNlPhb0bngzlq7qVHgoLif uyZ/kD2fCc2VJezl3eGPX1++4Keu+k3mLbRuHDy7171RGPBEMpLNYqvafWVoeFGS1H0PIUAAz4/ h1LDaAZZYf57gpd9z7egDR529UVcOpU2/vSmktpxbJQ61t9IYz1vnae6Ot0wfZOpJwMY8ovAmdV V/aU0jLcERS5Aar3wT0fxYkCNv99XVgNATGnIWos0O8Azl/f9sAbUllcFM7t8UlxSAnLn201kg= = X-Received: by 2002:a1c:6a0b:: with SMTP id f11-v6mr14566412wmc.107.1532945886158; Mon, 30 Jul 2018 03:18:06 -0700 (PDT) X-Received: by 2002:a1c:6a0b:: with SMTP id f11-v6mr14566334wmc.107.1532945885120; Mon, 30 Jul 2018 03:18:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532945885; cv=none; d=google.com; s=arc-20160816; b=znlRM5KyIG2QUw0QvVAYbbq71oItKzWzCYPCb9/FUQWLpePs/WfLixY9No7ZRX0Lex jd9ki4e0lykYcCJyAy5F6nJAqBlb24eF0KFE6gF47uGot0GTg6U67fbgald/fbDQV/Iw nanz7gEO/uC/AXVyJPZorphdgJmULaAnjzCLFMxHY4MXmTOYhtbc6xxNTDdI21oN2N92 m2+5fG+oh4XvBgcJQy9AbbLuYVXSFHvtq0MPAaQQQ9kefbuIycLb0OsmEI87Dr7BwaU3 6YtMW/4t6XdC/msSyyh0SxUjwGU4G2RNAD21oYbaxjq9Wq5GpZILMtX183/JoBK2fpXI Q5Nw== 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=r3FUumIztPDwO6lIdEH4/NlXhd3R05jzu97rMbjyVnY=; b=cQAWooD28ycZluC0yIJsnUGm1Y3L15AxvrroKY0mNYvBP0lAZ3R9q1HejUNG99Kj9v 20u9Y2BK52E7NwZtsnv0AQv4Qknhx3XUTtK4mTMZA01rYq0vzhcTrNK3x8sQ3PpKxaeb yc23wuNF3AHvZE1bpjLuY0hSe7hX+ERzFhvS7GWzNr8Pz4GFaYd3KQ0tAGaD4N9E09Le GobkSAH+cV+V9le64IPYS2eY9XipfXId4IpPREhLi1zbcqSc9aBN2Ukj70LVFCgq/iih nspCCPmMxa+JnyAS6GwmJ+l/BWd4cG1PIrlO6v0xhBmHqFRZeTbbM2sYSSeeqM+IGA2N QRFQ== 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 w8-v6sor4657719wrn.16.2018.07.30.03.18.04 for (Google Transport Security); Mon, 30 Jul 2018 03:18:05 -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: AAOMgpeb/ufzCmRAGJBr8drTHWXEcEBSU0Cmhe26IKPgkTdbW/5tDU5cQh9YjkkJjep00KeupCYLaQ== X-Received: by 2002:a5d:514d:: with SMTP id u13-v6mr17321645wrt.162.1532945884826; Mon, 30 Jul 2018 03:18:04 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id h7-v6sm11009845wmb.48.2018.07.30.03.18.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 03:18:03 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 0004F124447; Mon, 30 Jul 2018 12:18:02 +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 v5 2/4] mm: access zone->node via zone_to_nid() and zone_set_nid() Date: Mon, 30 Jul 2018 12:17:55 +0200 Message-Id: <20180730101757.28058-3-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180730101757.28058-1-osalvador@techadventures.net> References: <20180730101757.28058-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 --- 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 726e71475144..6954ad183159 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -940,15 +940,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 ae1a034c3e2c..17fdff3bfb41 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -842,6 +842,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 @@ -957,12 +976,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 f0fcf70bcec7..8c1c09b3852a 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 8a73305f7c55..10b754fba5fa 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2909,10 +2909,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); @@ -5287,7 +5287,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 @@ -6311,9 +6311,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);