From: David Vrabel <david.vrabel@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] evtchn/fifo: don't corrupt queues if an old tail is linked
Date: Mon, 9 Dec 2013 14:43:11 +0000 [thread overview]
Message-ID: <52A5D6FF.5060509@citrix.com> (raw)
In-Reply-To: <52A5CF49020000780010B6C1@nat28.tlf.novell.com>
On 09/12/13 13:10, Jan Beulich wrote:
>>>> On 09.12.13 at 13:56, David Vrabel <david.vrabel@citrix.com> wrote:
>> On 09/12/13 12:21, Jan Beulich wrote:
>>>>>> On 09.12.13 at 12:49, David Vrabel <david.vrabel@citrix.com> wrote:
>>>> On 09/12/13 09:32, Jan Beulich wrote:
>>>>>>>> On 06.12.13 at 18:38, David Vrabel <david.vrabel@citrix.com> wrote:
>>>>>> --- a/xen/include/xen/sched.h
>>>>>> +++ b/xen/include/xen/sched.h
>>>>>> @@ -98,6 +98,8 @@ struct evtchn
>>>>>> } u;
>>>>>> u8 priority;
>>>>>> u8 pending:1;
>>>>>> + u16 last_vcpu_id;
>>>>>> + u8 last_priority;
>>>>>
>>>>> Is it really correct for these two new fields to remain uninitialized
>>>>> until evtchn_fifo_set_pending() would get run the first time (and
>>>>> hence thinking there was a move this first time through)?
>>>>
>>>> They're initialized to zero and I think this is fine. The code as-is is
>>>> simpler than having to special case events that have never been on a queue.
>>>
>>> I'm not asking to add a special case, I'm only asking to initialize all
>>> fields correctly. Just like you ought to set up ->priority, you
>>> likely ought to set up the two new fields.
>>
>> It's not clear how you think they're not initialized. They're
>> initialized to zero when the evtchn is allocated and then they must only
>> be set in evtchn_fifo_set_pending() when they move to a new queue.
>
> My primary concern is with them being zero (and hence out of sync
> with the real values that things start out with), there may be subtle
> corruption later on. Secondary is that - as said - this would at least
> trigger one unnecessary move in evtchn_fifo_set_pending().
(0, 0) is still a valid queue and it is always safe to do:
if ( old_q->tail == port )
old_q->tail = 0
so I'm not seeing any risk of subtle corruption anywhere.
An unnecessary move once per port is hardly expensive so not something I
would introduce complexity in the common case to avoid.
>> Do you think they should be initialized when an event is (re)bound?
>> Because this would be broken as an unbound event might be an old tail.
>
> But if you don't do this, then you _require_ a set-priority operation,
> yet that one's necessarily non-atomic with the bind. Newly created
> event channels should start out at the default priority irrespective
> of what the underlying tracking structure in the hypervisor was
> used for before.
Xen can only move an event between queues if that event isn't on a
queue. It is also not notified when an event is removed from a queue.
The guest can ensure a predictable state by only unbinding events that
are not currently on a queue. e.g.,
/* prevent it becoming LINKED. */
set_bit(word, MASKED)
/* wait for interrupt handlers to drain event from its queue. */
while (test_bit(word, LINKED))
;
/* Unlinked and masked, safe to unbind. If this port is bound again
it will becoming pending on the correct new queue. */
unbind()
There doesn't need to be anything added to Xen to support this.
The guest may need to defer to wait and unbind to a work queue or similar.
David
next prev parent reply other threads:[~2013-12-09 14:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-06 17:38 [PATCHv6 0/1] Xen: FIFO-based event channel fix David Vrabel
2013-12-06 17:38 ` [PATCH] evtchn/fifo: don't corrupt queues if an old tail is linked David Vrabel
2013-12-09 9:32 ` Jan Beulich
2013-12-09 11:49 ` David Vrabel
2013-12-09 12:21 ` Jan Beulich
2013-12-09 12:56 ` David Vrabel
2013-12-09 13:10 ` Jan Beulich
2013-12-09 14:43 ` David Vrabel [this message]
2013-12-09 15:29 ` Jan Beulich
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=52A5D6FF.5060509@citrix.com \
--to=david.vrabel@citrix.com \
--cc=JBeulich@suse.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).