summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Kuznetsov <vkuznets@redhat.com>2016-03-15 17:56:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-15 19:55:16 -0400
commit703fc13a3f6615e29ce3eb862275d7b58a5d03ba (patch)
tree6bda3ae632b9add282e148865df976dadf107e97
parent31bc3858ea3ebcc3157b3f5f0e624c5962f5a7a6 (diff)
xen_balloon: support memory auto onlining policy
Add support for the newly added kernel memory auto onlining policy to Xen ballon driver. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Suggested-by: Daniel Kiper <daniel.kiper@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Acked-by: David Vrabel <david.vrabel@citrix.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Daniel Kiper <daniel.kiper@oracle.com> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Tang Chen <tangchen@cn.fujitsu.com> Cc: David Rientjes <rientjes@google.com> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Cc: Xishi Qiu <qiuxishi@huawei.com> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: "K. Y. Srinivasan" <kys@microsoft.com> Cc: Igor Mammedov <imammedo@redhat.com> Cc: Kay Sievers <kay@vrfy.org> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/xen/Kconfig23
-rw-r--r--drivers/xen/balloon.c11
2 files changed, 25 insertions, 9 deletions
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index 73708acce3ca..979a8317204f 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -37,23 +37,30 @@ config XEN_BALLOON_MEMORY_HOTPLUG
37 37
38 Memory could be hotplugged in following steps: 38 Memory could be hotplugged in following steps:
39 39
40 1) dom0: xl mem-max <domU> <maxmem> 40 1) target domain: ensure that memory auto online policy is in
41 effect by checking /sys/devices/system/memory/auto_online_blocks
42 file (should be 'online').
43
44 2) control domain: xl mem-max <target-domain> <maxmem>
41 where <maxmem> is >= requested memory size, 45 where <maxmem> is >= requested memory size,
42 46
43 2) dom0: xl mem-set <domU> <memory> 47 3) control domain: xl mem-set <target-domain> <memory>
44 where <memory> is requested memory size; alternatively memory 48 where <memory> is requested memory size; alternatively memory
45 could be added by writing proper value to 49 could be added by writing proper value to
46 /sys/devices/system/xen_memory/xen_memory0/target or 50 /sys/devices/system/xen_memory/xen_memory0/target or
47 /sys/devices/system/xen_memory/xen_memory0/target_kb on dumU, 51 /sys/devices/system/xen_memory/xen_memory0/target_kb on the
52 target domain.
48 53
49 3) domU: for i in /sys/devices/system/memory/memory*/state; do \ 54 Alternatively, if memory auto onlining was not requested at step 1
50 [ "`cat "$i"`" = offline ] && echo online > "$i"; done 55 the newly added memory can be manually onlined in the target domain
56 by doing the following:
51 57
52 Memory could be onlined automatically on domU by adding following line to udev rules: 58 for i in /sys/devices/system/memory/memory*/state; do \
59 [ "`cat "$i"`" = offline ] && echo online > "$i"; done
53 60
54 SUBSYSTEM=="memory", ACTION=="add", RUN+="/bin/sh -c '[ -f /sys$devpath/state ] && echo online > /sys$devpath/state'" 61 or by adding the following line to udev rules:
55 62
56 In that case step 3 should be omitted. 63 SUBSYSTEM=="memory", ACTION=="add", RUN+="/bin/sh -c '[ -f /sys$devpath/state ] && echo online > /sys$devpath/state'"
57 64
58config XEN_BALLOON_MEMORY_HOTPLUG_LIMIT 65config XEN_BALLOON_MEMORY_HOTPLUG_LIMIT
59 int "Hotplugged memory limit (in GiB) for a PV guest" 66 int "Hotplugged memory limit (in GiB) for a PV guest"
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index e6058debd01b..7c8a2cf16f58 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -338,7 +338,16 @@ static enum bp_state reserve_additional_memory(void)
338 } 338 }
339#endif 339#endif
340 340
341 rc = add_memory_resource(nid, resource, false); 341 /*
342 * add_memory_resource() will call online_pages() which in its turn
343 * will call xen_online_page() callback causing deadlock if we don't
344 * release balloon_mutex here. Unlocking here is safe because the
345 * callers drop the mutex before trying again.
346 */
347 mutex_unlock(&balloon_mutex);
348 rc = add_memory_resource(nid, resource, memhp_auto_online);
349 mutex_lock(&balloon_mutex);
350
342 if (rc) { 351 if (rc) {
343 pr_warn("Cannot add additional memory (%i)\n", rc); 352 pr_warn("Cannot add additional memory (%i)\n", rc);
344 goto err; 353 goto err;