The patch titled Subject: mm: access zone->node via zone_to_nid() and zone_set_nid() has been added to the -mm tree. Its filename is mm-access-zone-node-via-zone_to_nid-and-zone_set_nid.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-access-zone-node-via-zone_to_nid-and-zone_set_nid.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-access-zone-node-via-zone_to_nid-and-zone_set_nid.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx> Subject: 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. Link: http://lkml.kernel.org/r/20180730101757.28058-3-osalvador@xxxxxxxxxxxxxxxxxx Signed-off-by: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx> Signed-off-by: Oscar Salvador <osalvador@xxxxxxx> Reviewed-by: Oscar Salvador <osalvador@xxxxxxx> Acked-by: Michal Hocko <mhocko@xxxxxxxx> Cc: Aaron Lu <aaron.lu@xxxxxxxxx> Cc: Dan Williams <dan.j.williams@xxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx> Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- diff -puN include/linux/mm.h~mm-access-zone-node-via-zone_to_nid-and-zone_set_nid include/linux/mm.h --- a/include/linux/mm.h~mm-access-zone-node-via-zone_to_nid-and-zone_set_nid +++ a/include/linux/mm.h @@ -957,15 +957,6 @@ static inline int page_zone_id(struct pa 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 -puN include/linux/mmzone.h~mm-access-zone-node-via-zone_to_nid-and-zone_set_nid include/linux/mmzone.h --- a/include/linux/mmzone.h~mm-access-zone-node-via-zone_to_nid-and-zone_set_nid +++ a/include/linux/mmzone.h @@ -834,6 +834,25 @@ static inline bool populated_zone(struct 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 @@ -949,12 +968,7 @@ static inline int zonelist_zone_idx(stru 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 -puN mm/mempolicy.c~mm-access-zone-node-via-zone_to_nid-and-zone_set_nid mm/mempolicy.c --- a/mm/mempolicy.c~mm-access-zone-node-via-zone_to_nid-and-zone_set_nid +++ a/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, st 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 -puN mm/mm_init.c~mm-access-zone-node-via-zone_to_nid-and-zone_set_nid mm/mm_init.c --- a/mm/mm_init.c~mm-access-zone-node-via-zone_to_nid-and-zone_set_nid +++ a/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 -puN mm/page_alloc.c~mm-access-zone-node-via-zone_to_nid-and-zone_set_nid mm/page_alloc.c --- a/mm/page_alloc.c~mm-access-zone-node-via-zone_to_nid-and-zone_set_nid +++ a/mm/page_alloc.c @@ -2915,10 +2915,10 @@ static inline void zone_statistics(struc 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_ * 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); _ Patches currently in -mm which might be from pasha.tatashin@xxxxxxxxxx are mm-skip-invalid-pages-block-at-a-time-in-zero_resv_unresv.patch mm-sparse-abstract-sparse-buffer-allocations.patch mm-sparse-use-the-new-sparse-buffer-functions-in-non-vmemmap.patch mm-sparse-move-buffer-init-fini-to-the-common-place.patch mm-sparse-add-new-sparse_init_nid-and-sparse_init.patch mm-sparse-delete-old-sprase_init-and-enable-new-one.patch mm-sparse-delete-old-sparse_init-and-enable-new-one-v6.patch mm-make-memmap_init-a-proper-function.patch mm-calculate-deferred-pages-after-skipping-mirrored-memory.patch mm-calculate-deferred-pages-after-skipping-mirrored-memory-v2.patch mm-move-mirrored-memory-specific-code-outside-of-memmap_init_zone.patch mm-move-mirrored-memory-specific-code-outside-of-memmap_init_zone-v2.patch mm-access-zone-node-via-zone_to_nid-and-zone_set_nid.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html