All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: george.dunlap@eu.citrix.com, dario.faggioli@citrix.com,
	xen-devel@lists.xen.org
Subject: Re: [PATCH] xen: recalculate per-cpupool credits when updating timeslice
Date: Fri, 29 Jan 2016 11:59:10 +0100	[thread overview]
Message-ID: <56AB45FE.5010500@suse.com> (raw)
In-Reply-To: <56AB511402000078000CC59C@suse.com>

On 29/01/16 11:46, Jan Beulich wrote:
>>>> On 29.01.16 at 11:21, <JGross@suse.com> wrote:
>> --- a/xen/common/sched_credit.c
>> +++ b/xen/common/sched_credit.c
>> @@ -1086,12 +1086,19 @@ csched_dom_cntl(
>>  static inline void
>>  __csched_set_tslice(struct csched_private *prv, unsigned timeslice)
>>  {
>> +    unsigned long flags;
>> +
>> +    spin_lock_irqsave(&prv->lock, flags);
>> +
>>      prv->tslice_ms = timeslice;
>>      prv->ticks_per_tslice = CSCHED_TICKS_PER_TSLICE;
>>      if ( prv->tslice_ms < prv->ticks_per_tslice )
>>          prv->ticks_per_tslice = 1;
>>      prv->tick_period_us = prv->tslice_ms * 1000 / prv->ticks_per_tslice;
>>      prv->credits_per_tslice = CSCHED_CREDITS_PER_MSEC * prv->tslice_ms;
>> +    prv->credit = prv->credits_per_tslice * prv->ncpus;
>> +
>> +    spin_unlock_irqrestore(&prv->lock, flags);
>>  }
> 
> The added locking, which has no reason give for in the description
> at all, puzzles me: I can see it being needed (and having been
> missing) when called from csched_sys_cntl(), but it's not clear to
> me why it would be needed when called from csched_init(). Yet
> csched_sys_cntl() subsequently als updates prv->ratelimit_us,
> and hence the lock would perhaps better be taken there?

The locking is needed to protect against csched_alloc_pdata() and
csched_free_pdata(). prv->credit could be permananently wrong
without the lock, while prv->ratelimit_us can't be modified
concurrently in a wrong way (it could be modified by two concurrent
calls of csched_sys_cntl(), but even with locking one of both
calls would be the winner, same applies to the case with no lock).

OTOH I don't mind moving the lock to csched_sys_cntl(). Dario,
George, any preferences?


Juergen

  parent reply	other threads:[~2016-01-29 10:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-29 10:21 [PATCH] xen: recalculate per-cpupool credits when updating timeslice Juergen Gross
2016-01-29 10:46 ` Jan Beulich
     [not found] ` <56AB511402000078000CC59C@suse.com>
2016-01-29 10:59   ` Juergen Gross [this message]
2016-02-02  9:53     ` Dario Faggioli
2016-02-02 10:35       ` Juergen Gross
2016-02-02 11:33         ` Dario Faggioli
2016-02-02  7:55 ` Alan Robinson

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=56AB45FE.5010500@suse.com \
    --to=jgross@suse.com \
    --cc=JBeulich@suse.com \
    --cc=dario.faggioli@citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=xen-devel@lists.xen.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.