From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752423AbbGTLql (ORCPT ); Mon, 20 Jul 2015 07:46:41 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45806 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752058AbbGTLqi (ORCPT ); Mon, 20 Jul 2015 07:46:38 -0400 From: Juergen Gross To: linux-kernel@vger.kernel.org, xen-devel@lists.xensource.com, konrad.wilk@oracle.com, david.vrabel@citrix.com, boris.ostrovsky@oracle.com Cc: Juergen Gross Subject: [Patch V2] xen: release lock occasionally during ballooning Date: Mon, 20 Jul 2015 13:46:34 +0200 Message-Id: <1437392794-6372-1-git-send-email-jgross@suse.com> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: Juergen Gross --- drivers/xen/balloon.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index fd93369..e6d9eee 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c @@ -481,9 +481,16 @@ static void balloon_process(struct work_struct *work) { enum bp_state state = BP_DONE; long credit; + static bool active; mutex_lock(&balloon_mutex); + if (active) { + mutex_unlock(&balloon_mutex); + return; + } + active = true; + do { credit = current_credit(); @@ -499,12 +506,16 @@ static void balloon_process(struct work_struct *work) state = update_schedule(state); -#ifndef CONFIG_PREEMPT - if (need_resched()) - schedule(); -#endif + mutex_unlock(&balloon_mutex); + + cond_resched(); + + mutex_lock(&balloon_mutex); + } while (credit && state == BP_DONE); + active = false; + /* Schedule more work if there is some still to be done. */ if (state == BP_EAGAIN) schedule_delayed_work(&balloon_worker, balloon_stats.schedule_delay * HZ); -- 2.1.4