Skip to content

Commit

Permalink
memory-hotplug: use zone_can_shift() for sysfs valid_zones attribute
Browse files Browse the repository at this point in the history
Since zone_can_shift() is being used to validate the target zone during
onlining, it should also be used to determine the content of
valid_zones.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Reza Arbab <[email protected]>
Reviewd-by: Yasuaki Ishimatsu <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Daniel Kiper <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Tang Chen <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: David Vrabel <[email protected]>
Cc: Vitaly Kuznetsov <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Andrew Banman <[email protected]>
Cc: Chen Yucong <[email protected]>
Cc: Yasunori Goto <[email protected]>
Cc: Zhang Zhen <[email protected]>
Cc: Shaohua Li <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rarbab authored and torvalds committed Jul 26, 2016
1 parent df429ac commit a371d9f
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions drivers/base/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ static ssize_t show_valid_zones(struct device *dev,
unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block;
struct page *first_page;
struct zone *zone;
int zone_shift = 0;

start_pfn = section_nr_to_pfn(mem->start_section_nr);
end_pfn = start_pfn + nr_pages;
Expand All @@ -402,21 +403,26 @@ static ssize_t show_valid_zones(struct device *dev,

zone = page_zone(first_page);

if (zone_idx(zone) == ZONE_MOVABLE - 1) {
/*The mem block is the last memoryblock of this zone.*/
if (end_pfn == zone_end_pfn(zone))
return sprintf(buf, "%s %s\n",
zone->name, (zone + 1)->name);
/* MMOP_ONLINE_KEEP */
sprintf(buf, "%s", zone->name);

/* MMOP_ONLINE_KERNEL */
zone_shift = zone_can_shift(start_pfn, nr_pages, ZONE_NORMAL);
if (zone_shift) {
strcat(buf, " ");
strcat(buf, (zone + zone_shift)->name);
}

if (zone_idx(zone) == ZONE_MOVABLE) {
/*The mem block is the first memoryblock of ZONE_MOVABLE.*/
if (start_pfn == zone->zone_start_pfn)
return sprintf(buf, "%s %s\n",
zone->name, (zone - 1)->name);
/* MMOP_ONLINE_MOVABLE */
zone_shift = zone_can_shift(start_pfn, nr_pages, ZONE_MOVABLE);
if (zone_shift) {
strcat(buf, " ");
strcat(buf, (zone + zone_shift)->name);
}

return sprintf(buf, "%s\n", zone->name);
strcat(buf, "\n");

return strlen(buf);
}
static DEVICE_ATTR(valid_zones, 0444, show_valid_zones, NULL);
#endif
Expand Down

0 comments on commit a371d9f

Please sign in to comment.