summaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorReza Arbab <arbab@linux.vnet.ibm.com>2016-07-26 18:22:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-26 19:19:19 -0400
commita371d9f1cc49f58c8be3d28c88aceaef86cb59d0 (patch)
treec34eecfd777c811999982c442cb63cd2372426a7 /drivers/base
parentdf429ac039360005299d56247647ca77098d660e (diff)
memory-hotplug: use zone_can_shift() for sysfs valid_zones attribute
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/1462816419-4479-4-git-send-email-arbab@linux.vnet.ibm.com Signed-off-by: Reza Arbab <arbab@linux.vnet.ibm.com> Reviewd-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Daniel Kiper <daniel.kiper@oracle.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Tang Chen <tangchen@cn.fujitsu.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: David Vrabel <david.vrabel@citrix.com> Cc: Vitaly Kuznetsov <vkuznets@redhat.com> Cc: David Rientjes <rientjes@google.com> Cc: Andrew Banman <abanman@sgi.com> Cc: Chen Yucong <slaoub@gmail.com> Cc: Yasunori Goto <y-goto@jp.fujitsu.com> Cc: Zhang Zhen <zhenzhang.zhang@huawei.com> Cc: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/memory.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index f46dba8b7092..dc75de9059cd 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -391,6 +391,7 @@ static ssize_t show_valid_zones(struct device *dev,
391 unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block; 391 unsigned long nr_pages = PAGES_PER_SECTION * sections_per_block;
392 struct page *first_page; 392 struct page *first_page;
393 struct zone *zone; 393 struct zone *zone;
394 int zone_shift = 0;
394 395
395 start_pfn = section_nr_to_pfn(mem->start_section_nr); 396 start_pfn = section_nr_to_pfn(mem->start_section_nr);
396 end_pfn = start_pfn + nr_pages; 397 end_pfn = start_pfn + nr_pages;
@@ -402,21 +403,26 @@ static ssize_t show_valid_zones(struct device *dev,
402 403
403 zone = page_zone(first_page); 404 zone = page_zone(first_page);
404 405
405 if (zone_idx(zone) == ZONE_MOVABLE - 1) { 406 /* MMOP_ONLINE_KEEP */
406 /*The mem block is the last memoryblock of this zone.*/ 407 sprintf(buf, "%s", zone->name);
407 if (end_pfn == zone_end_pfn(zone)) 408
408 return sprintf(buf, "%s %s\n", 409 /* MMOP_ONLINE_KERNEL */
409 zone->name, (zone + 1)->name); 410 zone_shift = zone_can_shift(start_pfn, nr_pages, ZONE_NORMAL);
411 if (zone_shift) {
412 strcat(buf, " ");
413 strcat(buf, (zone + zone_shift)->name);
410 } 414 }
411 415
412 if (zone_idx(zone) == ZONE_MOVABLE) { 416 /* MMOP_ONLINE_MOVABLE */
413 /*The mem block is the first memoryblock of ZONE_MOVABLE.*/ 417 zone_shift = zone_can_shift(start_pfn, nr_pages, ZONE_MOVABLE);
414 if (start_pfn == zone->zone_start_pfn) 418 if (zone_shift) {
415 return sprintf(buf, "%s %s\n", 419 strcat(buf, " ");
416 zone->name, (zone - 1)->name); 420 strcat(buf, (zone + zone_shift)->name);
417 } 421 }
418 422
419 return sprintf(buf, "%s\n", zone->name); 423 strcat(buf, "\n");
424
425 return strlen(buf);
420} 426}
421static DEVICE_ATTR(valid_zones, 0444, show_valid_zones, NULL); 427static DEVICE_ATTR(valid_zones, 0444, show_valid_zones, NULL);
422#endif 428#endif