xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@eu.citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	David Vrabel <david.vrabel@citrix.com>,
	Keir Fraser <keir.xen@gmail.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	Juergen Gross <juergen.gross@ts.fujitsu.com>
Subject: Re: [PATCH] sched: fix race between sched_move_domain() and vcpu_wake()
Date: Fri, 11 Oct 2013 11:36:56 +0100	[thread overview]
Message-ID: <5257D4C8.7050908@eu.citrix.com> (raw)
In-Reply-To: <5257C0FE02000078000FA711@nat28.tlf.novell.com>

On 11/10/13 08:12, Jan Beulich wrote:
>>>> On 10.10.13 at 20:27, Keir Fraser <keir.xen@gmail.com> wrote:
>> On 10/10/2013 19:01, "Andrew Cooper" <andrew.cooper3@citrix.com> wrote:
>>
>>>> Just taking the lock for the old processor seemed sufficient to me as
>>>> anything seeing the new value would lock and unlock using the same new
>>>> value.  But do we need to take the schedule_lock for the new processor
>>>> as well (in the right order of course)?
>>> David and I have been discussing this for a while, involving a
>>> whiteboard, and not come to a firm conclusion either way.
>>>
>>>  From my point of view, holding the appropriate vcpu schedule lock
>>> entitles you to play with vcpu scheduling state, which involves
>>> following v->sched_priv which we update outside the critical region later.
>>>
>>> Only taking the one lock still leaves a race condition where another cpu
>>> can follow the new v->processor and obtain the schedule lock, at which
>>> point we have two threads both working on the internals of a vcpu.  The
>>> change below certainly will fix the current bug of locking one spinlock
>>> and unlocking another.
>>>
>>> My gut feeling is that we do need to take both locks to be safe in terms
>>> of data access, but we would appreciate advice from someone more
>>> familiar with the scheduler locking.
>> If it's that tricky to work out, why not just take the two locks,
>> appropriately ordered? This isn't a hot path.
> Shouldn't we rather fix the locking mechanism itself, making
> vcpu_schedule_lock...() return the lock, such that the unlock
> will unavoidably use the correct lock?

That's an idea; but I half wonder if it wouldn't be better to actually 
keep vcpu_schedule_unlock(), but pass it the old lock. Then for debug 
builds we can ASSERT that the lock hasn't changed.

  -George

  parent reply	other threads:[~2013-10-11 10:37 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-10 17:29 [PATCH] sched: fix race between sched_move_domain() and vcpu_wake() David Vrabel
2013-10-10 18:01 ` Andrew Cooper
2013-10-10 18:27   ` Keir Fraser
2013-10-11  7:12     ` Jan Beulich
2013-10-11  8:07       ` Keir Fraser
2013-10-11  9:02         ` Andrew Cooper
2013-10-11  9:32           ` Jan Beulich
2013-10-11  9:36             ` David Vrabel
2013-10-11  9:37               ` Jan Beulich
2013-10-11 12:20             ` Jan Beulich
2013-10-11 14:39               ` George Dunlap
2013-10-11 14:45               ` George Dunlap
2013-10-11 15:00                 ` Processed: " xen
2013-10-11 10:36       ` George Dunlap [this message]
2013-10-11  6:37 ` Juergen Gross
2013-10-11 10:32 ` George Dunlap
2013-10-11 11:15   ` Dario Faggioli
2013-10-11 11:32     ` George Dunlap
2013-10-11 11:49       ` Dario Faggioli
2013-10-11 12:03         ` Jan Beulich
2013-10-11 11:47 ` Keir Fraser

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=5257D4C8.7050908@eu.citrix.com \
    --to=george.dunlap@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=david.vrabel@citrix.com \
    --cc=juergen.gross@ts.fujitsu.com \
    --cc=keir.xen@gmail.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).