Commit e51e6c8f authored by Reza Arbab's avatar Reza Arbab Committed by Linus Torvalds

memory-hotplug: add move_pfn_range()

Add move_pfn_range(), a wrapper to call move_pfn_range_left() or
move_pfn_range_right().

No functional change. This will be utilized by a later patch.

Link: http://lkml.kernel.org/r/1462816419-4479-2-git-send-email-arbab@linux.vnet.ibm.comSigned-off-by: default avatarReza Arbab <arbab@linux.vnet.ibm.com>
Reviewed-by: default avatarYasuaki 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 90cae1fe
...@@ -449,6 +449,25 @@ static int __meminit move_pfn_range_right(struct zone *z1, struct zone *z2, ...@@ -449,6 +449,25 @@ static int __meminit move_pfn_range_right(struct zone *z1, struct zone *z2,
return -1; return -1;
} }
static struct zone * __meminit move_pfn_range(int zone_shift,
unsigned long start_pfn, unsigned long end_pfn)
{
struct zone *zone = page_zone(pfn_to_page(start_pfn));
int ret = 0;
if (zone_shift < 0)
ret = move_pfn_range_left(zone + zone_shift, zone,
start_pfn, end_pfn);
else if (zone_shift)
ret = move_pfn_range_right(zone, zone + zone_shift,
start_pfn, end_pfn);
if (ret)
return NULL;
return zone + zone_shift;
}
static void __meminit grow_pgdat_span(struct pglist_data *pgdat, unsigned long start_pfn, static void __meminit grow_pgdat_span(struct pglist_data *pgdat, unsigned long start_pfn,
unsigned long end_pfn) unsigned long end_pfn)
{ {
...@@ -1039,6 +1058,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ ...@@ -1039,6 +1058,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
int nid; int nid;
int ret; int ret;
struct memory_notify arg; struct memory_notify arg;
int zone_shift = 0;
/* /*
* This doesn't need a lock to do pfn_to_page(). * This doesn't need a lock to do pfn_to_page().
...@@ -1053,18 +1073,16 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ ...@@ -1053,18 +1073,16 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
return -EINVAL; return -EINVAL;
if (online_type == MMOP_ONLINE_KERNEL && if (online_type == MMOP_ONLINE_KERNEL &&
zone_idx(zone) == ZONE_MOVABLE) { zone_idx(zone) == ZONE_MOVABLE)
if (move_pfn_range_left(zone - 1, zone, pfn, pfn + nr_pages)) zone_shift = -1;
return -EINVAL;
}
if (online_type == MMOP_ONLINE_MOVABLE && if (online_type == MMOP_ONLINE_MOVABLE &&
zone_idx(zone) == ZONE_MOVABLE - 1) { zone_idx(zone) == ZONE_MOVABLE - 1)
if (move_pfn_range_right(zone, zone + 1, pfn, pfn + nr_pages)) zone_shift = 1;
return -EINVAL;
}
/* Previous code may changed the zone of the pfn range */ zone = move_pfn_range(zone_shift, pfn, pfn + nr_pages);
zone = page_zone(pfn_to_page(pfn)); if (!zone)
return -EINVAL;
arg.start_pfn = pfn; arg.start_pfn = pfn;
arg.nr_pages = nr_pages; arg.nr_pages = nr_pages;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment