Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754855AbbGJP66 (ORCPT ); Fri, 10 Jul 2015 11:58:58 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:49509 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754421AbbGJP6t (ORCPT ); Fri, 10 Jul 2015 11:58:49 -0400 Message-ID: <559FEBA0.7020500@oracle.com> Date: Fri, 10 Jul 2015 11:58:24 -0400 From: Boris Ostrovsky User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Juergen Gross , linux-kernel@vger.kernel.org, xen-devel@lists.xensource.com, konrad.wilk@oracle.com, david.vrabel@citrix.com Subject: Re: [PATCH] xen: release lock occasionally during ballooning References: <1436539354-27850-1-git-send-email-jgross@suse.com> In-Reply-To: <1436539354-27850-1-git-send-email-jgross@suse.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2081 Lines: 70 On 07/10/2015 10:42 AM, Juergen Gross wrote: > 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. Add a state variable to indicate one balloon_process() > is active to avoid multiple balloon processes fighting for the mutex. > > Instead of open coding it, just use cond_resched(). > > Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky > --- > 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); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/