diff options
author | Pavel Tatashin <pasha.tatashin@oracle.com> | 2018-08-22 00:53:32 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-22 13:52:45 -0400 |
commit | c1093b746c0576ed81c4d568d1e39cab651d37e6 (patch) | |
tree | 2ca164c09a94f73e7770f2ca59432cc12d1a6c3e | |
parent | ace1db39768cdc58f6b157d99ae5958ad34ffff8 (diff) |
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@techadventures.net
Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
Signed-off-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Aaron Lu <aaron.lu@intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Pasha Tatashin <Pavel.Tatashin@microsoft.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/mm.h | 9 | ||||
-rw-r--r-- | include/linux/mmzone.h | 26 | ||||
-rw-r--r-- | mm/mempolicy.c | 4 | ||||
-rw-r--r-- | mm/mm_init.c | 9 | ||||
-rw-r--r-- | 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 3a4b87d1a59a..a55f5389c491 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -960,15 +960,6 @@ static inline int page_zone_id(struct page *page) | |||
960 | return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK; | 960 | return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK; |
961 | } | 961 | } |
962 | 962 | ||
963 | static inline int zone_to_nid(struct zone *zone) | ||
964 | { | ||
965 | #ifdef CONFIG_NUMA | ||
966 | return zone->node; | ||
967 | #else | ||
968 | return 0; | ||
969 | #endif | ||
970 | } | ||
971 | |||
972 | #ifdef NODE_NOT_IN_PAGE_FLAGS | 963 | #ifdef NODE_NOT_IN_PAGE_FLAGS |
973 | extern int page_to_nid(const struct page *page); | 964 | extern int page_to_nid(const struct page *page); |
974 | #else | 965 | #else |
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 3d4577a3ae7e..1e22d96734e0 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h | |||
@@ -834,6 +834,25 @@ static inline bool populated_zone(struct zone *zone) | |||
834 | return zone->present_pages; | 834 | return zone->present_pages; |
835 | } | 835 | } |
836 | 836 | ||
837 | #ifdef CONFIG_NUMA | ||
838 | static inline int zone_to_nid(struct zone *zone) | ||
839 | { | ||
840 | return zone->node; | ||
841 | } | ||
842 | |||
843 | static inline void zone_set_nid(struct zone *zone, int nid) | ||
844 | { | ||
845 | zone->node = nid; | ||
846 | } | ||
847 | #else | ||
848 | static inline int zone_to_nid(struct zone *zone) | ||
849 | { | ||
850 | return 0; | ||
851 | } | ||
852 | |||
853 | static inline void zone_set_nid(struct zone *zone, int nid) {} | ||
854 | #endif | ||
855 | |||
837 | extern int movable_zone; | 856 | extern int movable_zone; |
838 | 857 | ||
839 | #ifdef CONFIG_HIGHMEM | 858 | #ifdef CONFIG_HIGHMEM |
@@ -949,12 +968,7 @@ static inline int zonelist_zone_idx(struct zoneref *zoneref) | |||
949 | 968 | ||
950 | static inline int zonelist_node_idx(struct zoneref *zoneref) | 969 | static inline int zonelist_node_idx(struct zoneref *zoneref) |
951 | { | 970 | { |
952 | #ifdef CONFIG_NUMA | 971 | return zone_to_nid(zoneref->zone); |
953 | /* zone_to_nid not available in this context */ | ||
954 | return zoneref->zone->node; | ||
955 | #else | ||
956 | return 0; | ||
957 | #endif /* CONFIG_NUMA */ | ||
958 | } | 972 | } |
959 | 973 | ||
960 | struct zoneref *__next_zones_zonelist(struct zoneref *z, | 974 | 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) | |||
1784 | zonelist = &NODE_DATA(node)->node_zonelists[ZONELIST_FALLBACK]; | 1784 | zonelist = &NODE_DATA(node)->node_zonelists[ZONELIST_FALLBACK]; |
1785 | z = first_zones_zonelist(zonelist, highest_zoneidx, | 1785 | z = first_zones_zonelist(zonelist, highest_zoneidx, |
1786 | &policy->v.nodes); | 1786 | &policy->v.nodes); |
1787 | return z->zone ? z->zone->node : node; | 1787 | return z->zone ? zone_to_nid(z->zone) : node; |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | default: | 1790 | default: |
@@ -2326,7 +2326,7 @@ int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long | |||
2326 | node_zonelist(numa_node_id(), GFP_HIGHUSER), | 2326 | node_zonelist(numa_node_id(), GFP_HIGHUSER), |
2327 | gfp_zone(GFP_HIGHUSER), | 2327 | gfp_zone(GFP_HIGHUSER), |
2328 | &pol->v.nodes); | 2328 | &pol->v.nodes); |
2329 | polnid = z->zone->node; | 2329 | polnid = zone_to_nid(z->zone); |
2330 | break; | 2330 | break; |
2331 | 2331 | ||
2332 | default: | 2332 | 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) | |||
53 | zone->name); | 53 | zone->name); |
54 | 54 | ||
55 | /* Iterate the zonelist */ | 55 | /* Iterate the zonelist */ |
56 | for_each_zone_zonelist(zone, z, zonelist, zoneid) { | 56 | for_each_zone_zonelist(zone, z, zonelist, zoneid) |
57 | #ifdef CONFIG_NUMA | 57 | pr_cont("%d:%s ", zone_to_nid(zone), zone->name); |
58 | pr_cont("%d:%s ", zone->node, zone->name); | ||
59 | #else | ||
60 | pr_cont("0:%s ", zone->name); | ||
61 | #endif /* CONFIG_NUMA */ | ||
62 | } | ||
63 | pr_cont("\n"); | 58 | pr_cont("\n"); |
64 | } | 59 | } |
65 | } | 60 | } |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 455cc3bfae99..6b2324bc61db 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) | |||
2909 | if (!static_branch_likely(&vm_numa_stat_key)) | 2909 | if (!static_branch_likely(&vm_numa_stat_key)) |
2910 | return; | 2910 | return; |
2911 | 2911 | ||
2912 | if (z->node != numa_node_id()) | 2912 | if (zone_to_nid(z) != numa_node_id()) |
2913 | local_stat = NUMA_OTHER; | 2913 | local_stat = NUMA_OTHER; |
2914 | 2914 | ||
2915 | if (z->node == preferred_zone->node) | 2915 | if (zone_to_nid(z) == zone_to_nid(preferred_zone)) |
2916 | __inc_numa_state(z, NUMA_HIT); | 2916 | __inc_numa_state(z, NUMA_HIT); |
2917 | else { | 2917 | else { |
2918 | __inc_numa_state(z, NUMA_MISS); | 2918 | __inc_numa_state(z, NUMA_MISS); |
@@ -5278,7 +5278,7 @@ int local_memory_node(int node) | |||
5278 | z = first_zones_zonelist(node_zonelist(node, GFP_KERNEL), | 5278 | z = first_zones_zonelist(node_zonelist(node, GFP_KERNEL), |
5279 | gfp_zone(GFP_KERNEL), | 5279 | gfp_zone(GFP_KERNEL), |
5280 | NULL); | 5280 | NULL); |
5281 | return z->zone->node; | 5281 | return zone_to_nid(z->zone); |
5282 | } | 5282 | } |
5283 | #endif | 5283 | #endif |
5284 | 5284 | ||
@@ -6299,9 +6299,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat) | |||
6299 | * And all highmem pages will be managed by the buddy system. | 6299 | * And all highmem pages will be managed by the buddy system. |
6300 | */ | 6300 | */ |
6301 | zone->managed_pages = freesize; | 6301 | zone->managed_pages = freesize; |
6302 | #ifdef CONFIG_NUMA | 6302 | zone_set_nid(zone, nid); |
6303 | zone->node = nid; | ||
6304 | #endif | ||
6305 | zone->name = zone_names[j]; | 6303 | zone->name = zone_names[j]; |
6306 | zone->zone_pgdat = pgdat; | 6304 | zone->zone_pgdat = pgdat; |
6307 | spin_lock_init(&zone->lock); | 6305 | spin_lock_init(&zone->lock); |