xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: George Dunlap <george.dunlap@citrix.com>, xen-devel@lists.xenproject.org
Cc: Wei Liu <wei.liu2@citrix.com>
Subject: Re: [PATCH for 4.7 1/4] xen: sched: avoid spuriously re-enabling IRQs in csched2_switch_sched()
Date: Wed, 4 May 2016 17:58:23 +0200	[thread overview]
Message-ID: <1462377503.6981.21.camel@citrix.com> (raw)
In-Reply-To: <572A1128.7010609@citrix.com>

On Wed, 2016-05-04 at 16:11 +0100, George Dunlap wrote:
> On 03/05/16 22:46, Dario Faggioli wrote:
> > 
> > In fact, interrupts are already disabled when calling
> > the hook from schedule_cpu_switch(), and hence using
> > anything different than just spin_lock() is wrong (and
> > ASSERT()-s in debug builds) or unnecessary.
> > 
> > Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
> Good catch.  
>
Well, much rather my bad introducing this! :-/

> But would it be better to either 1) add an assert that irqs
> are disabled, or 2) use spin_lock_irqsave(), just to make sure the
> two
> bits of code won't silently go out of sync?
> 
There's an ASSERT() already, in spin_lock_irq() (asking for IRQs to be
enabled), which is in fact the one that triggers.

I introduced the bug because of an oversight when applying the last
review comments to a previous patch series, and did not spot it because
--and this is the true mistake, IMO-- I tested the final result only
with debug=n. This is why I think an ASSERT() is after all not that
useful here... In fact, if this were tested with debug=y, what's
already in place would have been enough.

There are quite a few other similar cases all around scheduling code.
Some of them have comments, none has ASSERT()-s, and I think that is
fine.

I also don't like using spin_lock_irqsave() when it is not necessary,
even if this is not an hot path. In fact, apart from being slower, I
find it more confusing than helpful, especially when looking at the
code and trying to reason about whether we can be called with IRQ
enabled or not.

So, in summary, I'd be fine with adding a comment, and I'm ok
respinning for this. This patch is pretty independent from the rest of
the series anyway, so I can easily respin just this one.

Thoughts?

> Re Jan's comment -- you meant to say that spin_lock_irq() is wrong
> and
> spin_lock_irqsave() is unnecessary?  That's probably a bit more
> inference than we want changeset messages to have, ideally. :-)
> 
Yes, that's what I meant, as I replied myself to Jan.

> I wouldn't require a re-spin just for that, but if you are going to
> respin it, I would suggest just dropping the "and hence...".
> 
Ok, if I have to respin, I'll do this. If not, I'm fine with whoever
commits this has to drop that sentence.

Thanks and Regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-05-04 15:58 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-03 21:46 [PATCH for 4.7 0/4] Assorted scheduling fixes Dario Faggioli
2016-05-03 21:46 ` [PATCH for 4.7 1/4] xen: sched: avoid spuriously re-enabling IRQs in csched2_switch_sched() Dario Faggioli
2016-05-04  8:48   ` Jan Beulich
2016-05-04  9:08     ` Dario Faggioli
2016-05-04 15:11   ` George Dunlap
2016-05-04 15:58     ` Dario Faggioli [this message]
2016-05-04 17:05       ` George Dunlap
2016-05-04 17:21         ` Dario Faggioli
2016-05-04 17:34           ` George Dunlap
2016-05-06 13:21             ` Dario Faggioli
2016-05-06 13:48               ` Wei Liu
2016-05-09 14:42               ` George Dunlap
2016-05-03 21:46 ` [PATCH for 4.7 2/4] xen: sched: fix killing an uninitialized timer in free_pdata Dario Faggioli
2016-05-04 15:25   ` George Dunlap
2016-05-03 21:46 ` [PATCH for 4.7 3/4] xen: credit2: fix 2 (minor) issues in load tracking logic Dario Faggioli
2016-05-04 15:38   ` George Dunlap
2016-05-03 21:46 ` [PATCH for 4.7 4/4] xen: adopt .deinit_pdata and improve timer handling Dario Faggioli
2016-05-04 15:51   ` George Dunlap
2016-05-04 15:53     ` Meng Xu
2016-05-06 23:05       ` Dario Faggioli
2016-05-07 21:19   ` Meng Xu
2016-05-08  3:12     ` Meng Xu
2016-05-09  8:07       ` Juergen Gross
2016-05-09 13:22     ` Dario Faggioli
2016-05-09 14:08       ` Meng Xu
2016-05-09 14:52         ` Dario Faggioli
2016-05-09 14:58           ` Meng Xu
2016-05-09 14:46     ` George Dunlap
2016-05-09 14:58       ` Wei Liu
2016-05-09 15:35         ` George Dunlap
2016-05-04  1:26 ` [PATCH for 4.7 0/4] Assorted scheduling fixes Konrad Rzeszutek Wilk
2016-05-04  9:06   ` Dario Faggioli
2016-05-05 12:00     ` Julien Grall
2016-05-05 12:38       ` Dario Faggioli
2016-05-04 15:53 ` George Dunlap
2016-05-04 16:04 ` Wei Liu
2016-05-07 21:23   ` Meng Xu

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=1462377503.6981.21.camel@citrix.com \
    --to=dario.faggioli@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=wei.liu2@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).