xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jürgen Groß" <jgross@suse.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: xen-devel@lists.xenproject.org,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Ian Jackson" <iwj@xenproject.org>,
	"Julien Grall" <julien@xen.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>
Subject: Re: [PATCH v3 2/2] xen/evtchn: rework per event channel lock
Date: Mon, 2 Nov 2020 14:59:18 +0100	[thread overview]
Message-ID: <07cc4218-7aa6-2276-32af-559c0db841b5@suse.com> (raw)
In-Reply-To: <c77add99-f92e-126a-5a5e-81a2b5983aa0@suse.com>

On 02.11.20 14:52, Jan Beulich wrote:
> On 02.11.2020 14:41, Jürgen Groß wrote:
>> On 20.10.20 11:28, Jan Beulich wrote:
>>> On 16.10.2020 12:58, Juergen Gross wrote:
>>>> --- a/xen/arch/x86/pv/shim.c
>>>> +++ b/xen/arch/x86/pv/shim.c
>>>> @@ -660,11 +660,12 @@ void pv_shim_inject_evtchn(unsigned int port)
>>>>        if ( port_is_valid(guest, port) )
>>>>        {
>>>>            struct evtchn *chn = evtchn_from_port(guest, port);
>>>> -        unsigned long flags;
>>>>    
>>>> -        spin_lock_irqsave(&chn->lock, flags);
>>>> -        evtchn_port_set_pending(guest, chn->notify_vcpu_id, chn);
>>>> -        spin_unlock_irqrestore(&chn->lock, flags);
>>>> +        if ( evtchn_read_trylock(chn) )
>>>> +        {
>>>> +            evtchn_port_set_pending(guest, chn->notify_vcpu_id, chn);
>>>> +            evtchn_read_unlock(chn);
>>>> +        }
>>>
>>> Does this want some form of else, e.g. at least a printk_once()?
>>
>> No, I don't think so.
>>
>> This is just a race with the port_is_valid() test above where the
>> port is just being switched to invalid.
> 
> This may be such a race yes, but why do you think it _will_ be?

According to the outlined lock discipline there is no other
possibility (assuming that the lock discipline is honored).

I'll have a look whether I can add some ASSERT()s to catch any
lock discipline violation.

> 
>>>> @@ -360,7 +352,7 @@ static long evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind)
>>>>        if ( rc )
>>>>            goto out;
>>>>    
>>>> -    flags = double_evtchn_lock(lchn, rchn);
>>>> +    double_evtchn_lock(lchn, rchn);
>>>
>>> This introduces an unfortunate conflict with my conversion of
>>> the per-domain event lock to an rw one: It acquires rd's lock
>>> in read mode only, while the requirements here would not allow
>>> doing so. (Same in evtchn_close() then.)
>>
>> Is it a problem to use write mode for those cases?
> 
> "Problem" can have a wide range of meanings - it's not going to
> be the end of the world, but I view any use of a write lock as
> a problem when a read lock would suffice. This can still harm
> parallelism.

Both cases are very rare ones in the life time of an event channel. I
don't think you'll ever be able to measure any performance impact from
switching these case to a write lock for any well behaved guest.


Juergen


  reply	other threads:[~2020-11-02 13:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16 10:58 [PATCH v3 0/2] XSA-343 followup patches Juergen Gross
2020-10-16 10:58 ` [PATCH v3 1/2] xen/events: access last_priority and last_vcpu_id together Juergen Gross
2020-11-04  9:42   ` Julien Grall
2020-10-16 10:58 ` [PATCH v3 2/2] xen/evtchn: rework per event channel lock Juergen Gross
2020-10-20  9:28   ` Jan Beulich
2020-11-02 13:41     ` Jürgen Groß
2020-11-02 13:52       ` Jan Beulich
2020-11-02 13:59         ` Jürgen Groß [this message]
2020-11-02 15:18           ` Jan Beulich
2020-11-02 15:26             ` Jürgen Groß
2020-11-04  9:50               ` Julien Grall
2020-11-04  9:56                 ` Jürgen Groß
2020-11-04 10:02                   ` Julien Grall

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=07cc4218-7aa6-2276-32af-559c0db841b5@suse.com \
    --to=jgross@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=george.dunlap@citrix.com \
    --cc=iwj@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --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).