All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@citrix.com>
To: Dario Faggioli <dario.faggioli@citrix.com>,
	xen-devel@lists.xenproject.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH v4 1/6] xen: sched: fix locking of remove_vcpu() in credit1
Date: Wed, 4 Nov 2015 17:22:11 +0000	[thread overview]
Message-ID: <563A3EC3.1090304@citrix.com> (raw)
In-Reply-To: <20151104171733.20002.86229.stgit@Solace.station>

On 04/11/15 17:17, Dario Faggioli wrote:
> In fact, csched_vcpu_remove() (i.e., the credit1
> implementation of remove_vcpu()) manipulates runqueues,
> so holding the runqueue lock is necessary.
> 
> However, the vCPU just can't be on the runqueue, when
> the function is called. We can therefore ASSERT() that,
> and avoid doing any runqueue manipulations (rather than
> adding the runqueue locking around it).
> 
> Also, while there, *_lock_irq() (for the private lock) is
> enough, there is no need to *_lock_irqsave().
> 
> Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>

Reviewed-by: George Dunlap <george.dunlap@citrix.com>

> ---
> Cc: George Dunlap <george.dunlap@eu.citrix.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: Jan Beulich <JBeulich@suse.com>
> ---
> Changes from v3:
>  * instead of adding locking, get rid of __runq_remove(),
>    and add an ASSERT() about vCPU not being in runq already,
>    as suggested during review.
> 
> Changes from the other series:
>  * split the patch (wrt the original patch, in the original
>    series), and take care, in this one, only of remove_vcpu();
>  * removed pointless parentheses.
> ---
> The fact that vCPU can't be in runqueue when calling remove_vcpu() is true for
> other schedulers as well. In them, though, there isn't any race condition to
> fix. Therefore, taking care of the other schedulers will happen in a followup
> series.
> ---
>  xen/common/sched_credit.c |   11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c
> index 1b30e67..6dfcff6 100644
> --- a/xen/common/sched_credit.c
> +++ b/xen/common/sched_credit.c
> @@ -934,28 +934,25 @@ csched_vcpu_remove(const struct scheduler *ops, struct vcpu *vc)
>      struct csched_private *prv = CSCHED_PRIV(ops);
>      struct csched_vcpu * const svc = CSCHED_VCPU(vc);
>      struct csched_dom * const sdom = svc->sdom;
> -    unsigned long flags;
>  
>      SCHED_STAT_CRANK(vcpu_remove);
>  
> +    ASSERT(!__vcpu_on_runq(svc));
> +
>      if ( test_and_clear_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags) )
>      {
>          SCHED_STAT_CRANK(vcpu_unpark);
>          vcpu_unpause(svc->vcpu);
>      }
>  
> -    if ( __vcpu_on_runq(svc) )
> -        __runq_remove(svc);
> -
> -    spin_lock_irqsave(&(prv->lock), flags);
> +    spin_lock_irq(&prv->lock);
>  
>      if ( !list_empty(&svc->active_vcpu_elem) )
>          __csched_vcpu_acct_stop_locked(prv, svc);
>  
> -    spin_unlock_irqrestore(&(prv->lock), flags);
> +    spin_unlock_irq(&prv->lock);
>  
>      BUG_ON( sdom == NULL );
> -    BUG_ON( !list_empty(&svc->runq_elem) );
>  }
>  
>  static void
> 

  reply	other threads:[~2015-11-04 17:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 17:17 [PATCH v4 0/6] xen: sched: fix locking of {insert, remove}_vcpu() Dario Faggioli
2015-11-04 17:17 ` [PATCH v4 1/6] xen: sched: fix locking of remove_vcpu() in credit1 Dario Faggioli
2015-11-04 17:22   ` George Dunlap [this message]
2015-11-04 17:17 ` [PATCH v4 2/6] xen: sched: fix locking for insert_vcpu() in credit1 and RTDS Dario Faggioli
2015-11-24 11:34   ` George Dunlap
2015-11-04 17:17 ` [PATCH v4 3/6] xen: sched: clarify use cases of schedule_cpu_switch() Dario Faggioli
2015-11-04 17:17 ` [PATCH v4 4/6] xen: sched: better handle (not) inserting idle vCPUs in runqueues Dario Faggioli
2015-11-04 17:18 ` [PATCH v4 5/6] xen: sched: get rid of the per domain vCPU list in RTDS Dario Faggioli
2015-11-04 17:18 ` [PATCH v4 6/6] xen: sched: get rid of the per domain vCPU list in Credit2 Dario Faggioli
2015-11-23 14:03 ` [PATCH v4 0/6] xen: sched: fix locking of {insert, remove}_vcpu() George Dunlap
2015-11-23 14:40   ` Jan Beulich
2015-11-23 14:50     ` George Dunlap
2015-11-23 15:00       ` Jan Beulich
2015-11-24  3:27         ` Meng Xu
2015-11-24  8:05           ` Jan Beulich
2015-11-24 11:03 ` George Dunlap
2015-11-24 11:49   ` Dario Faggioli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=563A3EC3.1090304@citrix.com \
    --to=george.dunlap@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dario.faggioli@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.