From patchwork Wed Jul 18 14:11:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Tatashin X-Patchwork-Id: 10532581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C9E146020A for ; Wed, 18 Jul 2018 14:12:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8D7D29634 for ; Wed, 18 Jul 2018 14:12:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACC9A29642; Wed, 18 Jul 2018 14:12:04 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY 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 6414F29687 for ; Wed, 18 Jul 2018 14:12:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 377116B0006; Wed, 18 Jul 2018 10:12:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 327136B0007; Wed, 18 Jul 2018 10:12:02 -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 215646B0008; Wed, 18 Jul 2018 10:12:02 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it0-f71.google.com (mail-it0-f71.google.com [209.85.214.71]) by kanga.kvack.org (Postfix) with ESMTP id E99996B0006 for ; Wed, 18 Jul 2018 10:12:01 -0400 (EDT) Received: by mail-it0-f71.google.com with SMTP id g6-v6so2586506iti.7 for ; Wed, 18 Jul 2018 07:12:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:references:mime-version:content-disposition:in-reply-to :user-agent; bh=E10dlyzN3c8L62uGT39zhpeX3tJHBqrfWmR5zomHnWU=; b=AvFCy5LB7e7Iq4N2tMuySU5CojCg0FAxyFiJvv1DgYr5ufzqdT9cas6O/IYyUnOu/s oT3rJl7n9QYrylXgiRW6eKRF3wGi4GsM2tknVA69vwrpSliZM7sM6jvqvhUnMUp8Twfr r6fD4fMqxPfmNivielZZZLoFUWYkHqadMtjQDB+xv1N4AMRWYxayyvYyGwTrFDPZ3Mgp ubthrQAG1divoMQ3leAGpdiBUOoTAR5atmfGp/XCeCfY9fi/84xF6QXB3MUvZ1YaOBzA q9QaG3S8fffeL552o72jl9Ypn9L4F8DHxRNnFLnfpVWaXVehVDHz7eo5ofIjXZEXDSiM Y1wA== X-Gm-Message-State: AOUpUlHi4+9ytpNSq11z3CHsARb1OmT3pUijfbbniMzHXS4PokPBemT5 jTKyela/AOOUE34JRvSbvD0ObJGm7BtfUlS8oQJumcsBdxvTdMWHcvccftl0APfoTBeKTmnrOt0 OjJlizyecFi/majZq09a1AdqWKVkfOCGqf9htwXdnSTNUymms7w7g0eRscGgNZuNmeQ== X-Received: by 2002:a24:7510:: with SMTP id y16-v6mr2112875itc.32.1531923121696; Wed, 18 Jul 2018 07:12:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfVUKIMe5zciySTw0hwpkYcRXxKfaCWnIF+itXgYUYQl9aE2sOHRPnc+N0O8W4uzYz+1Mtw X-Received: by 2002:a24:7510:: with SMTP id y16-v6mr2112810itc.32.1531923120624; Wed, 18 Jul 2018 07:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531923120; cv=none; d=google.com; s=arc-20160816; b=xJoCqgS4EiLt9RjsoTfnaZRF174U4pF8oufiWF/M2kUkBEj4QmQGLm5LrJTwG+b3ua PlMEqstNAFI9fepkUnkDnlqtuHvEJ6FeKl8997DaYvd7SKjtotu45p+8l+AQW5y7YkWU 0UJYMidH1nkx/5UsES/iofXpSHVrfssP6BuzucyWZuIH3VEpAvH009PCkFRGaaN1I4j+ 8xeqClse//K1luQdIxvC2V3YvLvigWP/rvU3/yRbgdF20IKm0X5zKqW3bRrJigAFpbLb I9ubWkCYqi/2zFWYSoqQeXY+Qxg8SuVZEfJcU5t15HdaAs/AvNZVImWciCVxSykVir+7 y1Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=E10dlyzN3c8L62uGT39zhpeX3tJHBqrfWmR5zomHnWU=; b=rlJQXr5asEAM5B9gQcYz2cKDhnUMTGMYK4N9py/oINf6VEtP9LpU7vm2WnuAkpQ931 qSVWRavgiDAqlQLTA3VeNjMNOxQxWoh3x2hPJ0MltxxXEGi82K706ZhC6SqCdyZBJryp zJoulh2+Wtk2W7OuEbsIO6n2iqHaa5mPGmrY4cP7rDFDRybE00f/K6TXxHwiFhm6BGsE jjqwQf8yIPIPJGWyIvDyEAvnBFR3fN+YfVkSGgDLI28u3kJpvFhpCAwxBkibs3Q48oIj IHBhDSr6yfHZ8B5CtkoDI88SAFb9n9U1qjyhQegLBC9i5CB1I3Dmu/JtUe3EJ/G/rijD fAPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=14Ec3yYA; spf=pass (google.com: domain of pasha.tatashin@oracle.com designates 141.146.126.79 as permitted sender) smtp.mailfrom=pasha.tatashin@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from aserp2130.oracle.com (aserp2130.oracle.com. [141.146.126.79]) by mx.google.com with ESMTPS id 199-v6si1621976ity.8.2018.07.18.07.12.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 07:12:00 -0700 (PDT) Received-SPF: pass (google.com: domain of pasha.tatashin@oracle.com designates 141.146.126.79 as permitted sender) client-ip=141.146.126.79; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=14Ec3yYA; spf=pass (google.com: domain of pasha.tatashin@oracle.com designates 141.146.126.79 as permitted sender) smtp.mailfrom=pasha.tatashin@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w6IEAj7R118604; Wed, 18 Jul 2018 14:11:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=E10dlyzN3c8L62uGT39zhpeX3tJHBqrfWmR5zomHnWU=; b=14Ec3yYAG+rsPnqff6RzunI4ewuip5rdzffXgp4CgJyTa4tAJxvyFKclrEfKQ/pdOs/l GvBkHCsXa8aOD6esOH4S9uebTJjtdvq/v/vJwazl4sjfNZjA813PTQaDiOGjBQrkNPJ9 KLaebBDSBlB9MM3e3+9a+MQnqbB3GMIJYYd5mGP/1SKCSf+4BKOIIcIEz62LGX0MPnWn TVkS1k9lM3bXsSifxmkQnZDAZO7WPXlwv/793Ppd5MS4MiQ/96qpdBoxiDvExVqJhjsG 335CrN+oPYPHDt6KD4DyxQopv18/hHaW85ffMPrVFBCmw6rJXIlWTvG0NrGwNzVPwCQj lg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2k7a3t59b3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jul 2018 14:11:58 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w6IEBvmt009285 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Jul 2018 14:11:57 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w6IEBtqP014128; Wed, 18 Jul 2018 14:11:55 GMT Received: from xakep.localdomain (/73.69.118.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 18 Jul 2018 07:11:52 -0700 Date: Wed, 18 Jul 2018 10:11:50 -0400 From: Pavel Tatashin To: osalvador@techadventures.net Cc: akpm@linux-foundation.org, mhocko@suse.com, vbabka@suse.cz, iamjoonsoo.kim@lge.com, aaron.lu@intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Oscar Salvador Subject: Re: [PATCH 1/3] mm/page_alloc: Move ifdefery out of free_area_init_core Message-ID: <20180718141150.imiyuust5txfmfvw@xakep.localdomain> References: <20180718124722.9872-1-osalvador@techadventures.net> <20180718124722.9872-2-osalvador@techadventures.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180718124722.9872-2-osalvador@techadventures.net> User-Agent: NeoMutt/20180716 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8958 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807180159 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 On 18-07-18 14:47:20, osalvador@techadventures.net wrote: > From: Oscar Salvador > > Moving the #ifdefs out of the function makes it easier to follow. > > Signed-off-by: Oscar Salvador Hi Oscar, Reviewed-by: Pavel Tatashin Please include the following patch in your series, to get rid of the last ifdef in this function. From f841184e141b21e79c4d017d3b7678c697016d2a Mon Sep 17 00:00:00 2001 From: Pavel Tatashin Date: Wed, 18 Jul 2018 09:56:52 -0400 Subject: [PATCH] mm: access zone->node via zone_to_nid() and zone_set_nid() 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 --- 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 3982c83fdcbf..8634eeafad0b 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 32699b2dc52a..aeb6c1499da5 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 9ac49ef17b4e..9cfccb54d207 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 790722afa7cf..dbce6c0ced74 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2908,10 +2908,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); @@ -5280,7 +5280,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 @@ -6302,9 +6302,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(nid); zone->name = zone_names[j]; zone->zone_pgdat = pgdat; spin_lock_init(&zone->lock);