mm, memory_hotplug: display allowed zones in the preferred ordering
Subsystems (3)
[email protected]
maintainerPATCH 19/119 mm, memory_hotplug: display allowed zones in the preferred ordering
From: Michal Hocko <[email protected]>
Subject: mm, memory_hotplug: display allowed zones in the preferred ordering
Prior to "mm, memory_hotplug: do not associate hotadded memory to zones until online" we used to allow to change the valid zone types of a memory block if it is adjacent to a different zone type. This fact was reflected in memoryNN/valid_zones by the ordering of printed zones. The first one was default (echo online > memoryNN/state) and the other one could be onlined explicitly by online_{movable,kernel}. This behavior was removed by the said patch and as such the ordering was not all that important. In most cases a kernel zone would be default anyway. The only exception is movable_node handled by "mm, memory_hotplug: support movable_node for hotpluggable nodes".
Let's reintroduce this behavior again because later patch will remove the zone overlap restriction and so user will be allowed to online kernel resp. movable block regardless of its placement. Original behavior will then become significant again because it would be non-trivial for users to see what is the default zone to online into.
Implementation is really simple. Pull out zone selection out of move_pfn_range into zone_for_pfn_range helper and use it in show_valid_zones to display the zone for default onlining and then both kernel and movable if they are allowed. Default online zone is not duplicated.
---
drivers/base/memory.c | 33 +++++++++----- include/linux/memory_hotplug.h | 2 mm/memory_hotplug.c | 73 +++++++++++++++++-------------- 3 files changed, 65 insertions(+), 43 deletions(-)
drivers/base/memory.c renamed from drivers/base/memory.c~mm-memory_hotplug-display-allowed-zones-in-the-preferred-ordering +23 -10
@@ -388,6 +388,22 @@ static ssize_t show_phys_device(struct d }#ifdef CONFIG_MEMORY_HOTREMOVE +static void print_allowed_zone (char *buf,int nid,unsigned long start_pfn, +unsigned long nr_pages,int online_type, +struct zone *default_zone) +{ +struct zone *zone; + +if (!allow_online_pfn_range (nid, start_pfn, nr_pages, online_type)) +return ; + + zone =zone_for_pfn_range (online_type, nid, start_pfn, nr_pages); +if (zone != default_zone) { +strcat (buf," " ); +strcat (buf, zone->name); + } +} +static ssize_t show_valid_zones (struct device *dev,struct device_attribute *attr,char *buf) {
@@ -395,7 +411,7 @@ static ssize_t show_valid_zones(struct dunsigned long start_pfn =section_nr_to_pfn (mem->start_section_nr);unsigned long nr_pages =PAGES_PER_SECTION * sections_per_block;unsigned long valid_start_pfn, valid_end_pfn; -bool append = false; +struct zone *default_zone;int nid;/*
@@ -418,16 +434,13 @@ static ssize_t show_valid_zones(struct d } nid =pfn_to_nid (start_pfn); -if (allow_online_pfn_range (nid, start_pfn, nr_pages,MMOP_ONLINE_KERNEL )) { -strcat (buf,default_zone_for_pfn (nid, start_pfn, nr_pages)->name); - append = true; - } + default_zone =zone_for_pfn_range (MMOP_ONLINE_KEEP , nid, start_pfn, nr_pages); +strcat (buf, default_zone->name); -if (allow_online_pfn_range (nid, start_pfn, nr_pages,MMOP_ONLINE_MOVABLE )) { -if (append) -strcat (buf," " ); -strcat (buf,NODE_DATA (nid)->node_zones[ZONE_MOVABLE ].name); - } +print_allowed_zone (buf, nid, start_pfn, nr_pages,MMOP_ONLINE_KERNEL , + default_zone); +print_allowed_zone (buf, nid, start_pfn, nr_pages,MMOP_ONLINE_MOVABLE , + default_zone); out:strcat (buf,"\n" );
include/linux/memory_hotplug.h renamed from include/linux/memory_hotplug.h~mm-memory_hotplug-display-allowed-zones-in-the-preferred-ordering +1 -1
@@ -319,6 +319,6 @@ extern struct page *sparse_decode_mem_ma unsigned long pnum);extern bool allow_online_pfn_range (int nid,unsigned long pfn,unsigned long nr_pages,int online_type); -extern struct zone *default_zone_for_pfn (int nid,unsigned long pfn, +extern struct zone *zone_for_pfn_range (int online_type,int nid,unsigned start_pfn,unsigned long nr_pages);#endif /* __LINUX_MEMORY_HOTPLUG_H */
mm/memory_hotplug.c renamed from mm/memory_hotplug.c~mm-memory_hotplug-display-allowed-zones-in-the-preferred-ordering +41 -32
103 lines not on this page · raw message
_