Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp167516imm; Thu, 26 Jul 2018 01:06:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfdjPvry4VzSDXzHlziCCFGpUOMno7pFqkoatFbg4LT3X+X0z5gPxryI57KdNnfXudYquD8 X-Received: by 2002:a62:df82:: with SMTP id d2-v6mr1033383pfl.189.1532592395408; Thu, 26 Jul 2018 01:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532592395; cv=none; d=google.com; s=arc-20160816; b=yCt1q/DvMSSUVQ4qSjFa+LFczReYBfC8PLnUYwxbGeziqcipfS5C60M2SR88b+wi+K HfAWSbNc4aXfPW4Tb+cvjHb8nbYi4ziN+hOjqYPOnaGZlOvNmlWzZKM0kGHDDkPcF5HC CtahIYMDYZdXdMDqe7XZK5sTE1XPOCpuNcKPt0CT59whxRFeMdK9V28ZFwyJEBnTdf77 MLoo1wuyGuR7sVRpSSgDDn7ZdY7Z9NxnKDRiSP2bl8gzjrrhVwIyLd/E587zakZz3mzT GsD5Gc1NJk6VIYXii+sCluE1etJouJmGGVy74CnBAdiI/XKao1/ch0lhQQ2VnxnHZz6I zvSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=bpk/+R95SqfnPIXNVwhvySPJwiMKvmqrP3eDM7HqvYs=; b=UVFRBds3EDphgs3FuSRIYQyzlusgIzHrKdFGLyXB/ifQGiTomhMItRtlVjCKmKvBDO BQ9VuiK0qCGfYjWY+wRAG34g9F4cVdgRRGztRHel50omZvR2UMGKvCRV0nxTo/LIF/5h EqUP/rYFnPyBLu+su35B+QgCJL3tCcyb5Irzw8lS15A7xSLaKuftnsf9vIcmY7jmmzZ6 md5bk+f93Sw+AQOx/6Hig9vrSf4lm39wiaTNPyy91/pRMqkTo01/sr6nn/y0aWerqaCB m5MPWrNi62IBDQna1lEcc/ihy3iPkas/volV1uKZ/a0z2q4SPWnVS1mG4EB5SFX4SHXM tvKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j124-v6si811256pfg.157.2018.07.26.01.06.19; Thu, 26 Jul 2018 01:06:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728871AbeGZJVK (ORCPT + 99 others); Thu, 26 Jul 2018 05:21:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:52374 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728675AbeGZJVK (ORCPT ); Thu, 26 Jul 2018 05:21:10 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2DE1AAB99; Thu, 26 Jul 2018 08:05:29 +0000 (UTC) Date: Thu, 26 Jul 2018 10:05:00 +0200 From: Michal Hocko To: osalvador@techadventures.net Cc: akpm@linux-foundation.org, 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, Oscar Salvador Subject: Re: [PATCH v3 2/5] mm: access zone->node via zone_to_nid() and zone_set_nid() Message-ID: <20180726080500.GX28386@dhcp22.suse.cz> References: <20180725220144.11531-1-osalvador@techadventures.net> <20180725220144.11531-3-osalvador@techadventures.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180725220144.11531-3-osalvador@techadventures.net> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 26-07-18 00:01:41, osalvador@techadventures.net wrote: > 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 My previous [1] question is not addressed in the changelog but I will not insist. If there is any reason to resubmit this then please consider. Acked-by: Michal Hocko [1] http://lkml.kernel.org/r/20180719134018.GB7193@dhcp22.suse.cz > --- > 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); > -- > 2.13.6 > -- Michal Hocko SUSE Labs