diff options
author | Mark Brown <broonie@kernel.org> | 2017-08-30 23:15:31 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-08-30 23:15:31 +0200 |
commit | b388dc1f62a9bdd9c4758a0664e61d0f9a9da519 (patch) | |
tree | 696fd3c245700ee59ebcf3a65b90f8773b904624 /drivers/xen/xen-balloon.c | |
parent | ASoC: remove duplicate definition of dapm_routes/num_dapm_routes (diff) | |
parent | Linux 4.13-rc7 (diff) | |
download | linux-b388dc1f62a9bdd9c4758a0664e61d0f9a9da519.tar.xz linux-b388dc1f62a9bdd9c4758a0664e61d0f9a9da519.zip |
Merge tag 'v4.13-rc7' into asoc-component
Linux 4.13-rc7
Diffstat (limited to 'drivers/xen/xen-balloon.c')
-rw-r--r-- | drivers/xen/xen-balloon.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c index e7715cb62eef..e89136ab851e 100644 --- a/drivers/xen/xen-balloon.c +++ b/drivers/xen/xen-balloon.c @@ -59,6 +59,8 @@ static void watch_target(struct xenbus_watch *watch, { unsigned long long new_target; int err; + static bool watch_fired; + static long target_diff; err = xenbus_scanf(XBT_NIL, "memory", "target", "%llu", &new_target); if (err != 1) { @@ -69,7 +71,14 @@ static void watch_target(struct xenbus_watch *watch, /* The given memory/target value is in KiB, so it needs converting to * pages. PAGE_SHIFT converts bytes to pages, hence PAGE_SHIFT - 10. */ - balloon_set_new_target(new_target >> (PAGE_SHIFT - 10)); + new_target >>= PAGE_SHIFT - 10; + if (watch_fired) { + balloon_set_new_target(new_target - target_diff); + return; + } + + watch_fired = true; + target_diff = new_target - balloon_stats.target_pages; } static struct xenbus_watch target_watch = { .node = "memory/target", @@ -94,22 +103,15 @@ static struct notifier_block xenstore_notifier = { .notifier_call = balloon_init_watcher, }; -static int __init balloon_init(void) +void xen_balloon_init(void) { - if (!xen_domain()) - return -ENODEV; - - pr_info("Initialising balloon driver\n"); - register_balloon(&balloon_dev); register_xen_selfballooning(&balloon_dev); register_xenstore_notifier(&xenstore_notifier); - - return 0; } -subsys_initcall(balloon_init); +EXPORT_SYMBOL_GPL(xen_balloon_init); #define BALLOON_SHOW(name, format, args...) \ static ssize_t show_##name(struct device *dev, \ |