提交 929423fa 编写于 作者: J Juergen Gross 提交者: David Vrabel

xen: release lock occasionally during ballooning

When dom0 is being ballooned balloon_process() will hold the balloon
mutex until it is finished. This will block e.g. creation of new
domains as the device backends for the new domain need some
autoballooned pages for the ring buffers.

Avoid this by releasing the balloon mutex from time to time during
ballooning. Adjust the comment above balloon_process() regarding
multiple instances of balloon_process().

Instead of open coding it, just use cond_resched().
Signed-off-by: NJuergen Gross <jgross@suse.com>
Signed-off-by: NDavid Vrabel <david.vrabel@citrix.com>
上级 30b03d05
...@@ -472,7 +472,7 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) ...@@ -472,7 +472,7 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
} }
/* /*
* We avoid multiple worker processes conflicting via the balloon mutex. * As this is a work item it is guaranteed to run as a single instance only.
* We may of course race updates of the target counts (which are protected * We may of course race updates of the target counts (which are protected
* by the balloon lock), or with changes to the Xen hard limit, but we will * by the balloon lock), or with changes to the Xen hard limit, but we will
* recover from these in time. * recover from these in time.
...@@ -482,9 +482,10 @@ static void balloon_process(struct work_struct *work) ...@@ -482,9 +482,10 @@ static void balloon_process(struct work_struct *work)
enum bp_state state = BP_DONE; enum bp_state state = BP_DONE;
long credit; long credit;
mutex_lock(&balloon_mutex);
do { do {
mutex_lock(&balloon_mutex);
credit = current_credit(); credit = current_credit();
if (credit > 0) { if (credit > 0) {
...@@ -499,17 +500,15 @@ static void balloon_process(struct work_struct *work) ...@@ -499,17 +500,15 @@ static void balloon_process(struct work_struct *work)
state = update_schedule(state); state = update_schedule(state);
#ifndef CONFIG_PREEMPT mutex_unlock(&balloon_mutex);
if (need_resched())
schedule(); cond_resched();
#endif
} while (credit && state == BP_DONE); } while (credit && state == BP_DONE);
/* Schedule more work if there is some still to be done. */ /* Schedule more work if there is some still to be done. */
if (state == BP_EAGAIN) if (state == BP_EAGAIN)
schedule_delayed_work(&balloon_worker, balloon_stats.schedule_delay * HZ); schedule_delayed_work(&balloon_worker, balloon_stats.schedule_delay * HZ);
mutex_unlock(&balloon_mutex);
} }
/* Resets the Xen limit, sets new target, and kicks off processing. */ /* Resets the Xen limit, sets new target, and kicks off processing. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册