Skip to content
Snippets Groups Projects
Commit 2abb4077 authored by Juergen Gross's avatar Juergen Gross Committed by Greg Kroah-Hartman
Browse files

xen/balloon: fix cancelled balloon action


commit 319933a8 upstream.

In case a ballooning action is cancelled the new kernel thread handling
the ballooning might end up in a busy loop.

Fix that by handling the cancelled action gracefully.

While at it introduce a short wait for the BP_WAIT case.

Cc: stable@vger.kernel.org
Fixes: 8480ed9c ("xen/balloon: use a kernel thread instead a workqueue")
Reported-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Tested-by: default avatarJason Andryuk <jandryuk@gmail.com>
Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
Link: https://lore.kernel.org/r/20211005133433.32008-1-jgross@suse.com


Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 42fbcbaa
No related branches found
No related tags found
No related merge requests found
...@@ -508,12 +508,12 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) ...@@ -508,12 +508,12 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
} }
/* /*
* Stop waiting if either state is not BP_EAGAIN and ballooning action is * Stop waiting if either state is BP_DONE and ballooning action is
* needed, or if the credit has changed while state is BP_EAGAIN. * needed, or if the credit has changed while state is not BP_DONE.
*/ */
static bool balloon_thread_cond(enum bp_state state, long credit) static bool balloon_thread_cond(enum bp_state state, long credit)
{ {
if (state != BP_EAGAIN) if (state == BP_DONE)
credit = 0; credit = 0;
return current_credit() != credit || kthread_should_stop(); return current_credit() != credit || kthread_should_stop();
...@@ -533,10 +533,19 @@ static int balloon_thread(void *unused) ...@@ -533,10 +533,19 @@ static int balloon_thread(void *unused)
set_freezable(); set_freezable();
for (;;) { for (;;) {
if (state == BP_EAGAIN) switch (state) {
timeout = balloon_stats.schedule_delay * HZ; case BP_DONE:
else case BP_ECANCELED:
timeout = 3600 * HZ; timeout = 3600 * HZ;
break;
case BP_EAGAIN:
timeout = balloon_stats.schedule_delay * HZ;
break;
case BP_WAIT:
timeout = HZ;
break;
}
credit = current_credit(); credit = current_credit();
wait_event_freezable_timeout(balloon_thread_wq, wait_event_freezable_timeout(balloon_thread_wq,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment