xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: Juergen Gross <jgross@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Oleksandr Andrushchenko <andr2000@gmail.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Dave P Martin <Dave.Martin@arm.com>
Subject: Re: xen/evtchn and forced threaded irq
Date: Wed, 27 Feb 2019 11:09:32 +0000	[thread overview]
Message-ID: <44f13194-6e18-5a05-bfb1-9c5c7af255e0__15604.1130352364$1551267419$gmane$org@arm.com> (raw)
In-Reply-To: <20190226110231.46luhevhlmefdldo@Air-de-Roger>

Hi,

On 2/26/19 11:02 AM, Roger Pau Monné wrote:
> On Tue, Feb 26, 2019 at 10:26:21AM +0000, Julien Grall wrote:
>> On 26/02/2019 10:17, Roger Pau Monné wrote:
>>> On Tue, Feb 26, 2019 at 10:03:38AM +0000, Julien Grall wrote:
>>>> Hi Roger,
>>>>
>>>> On 26/02/2019 09:44, Roger Pau Monné wrote:
>>>>> On Tue, Feb 26, 2019 at 09:30:07AM +0000, Andrew Cooper wrote:
>>>>>> On 26/02/2019 09:14, Roger Pau Monné wrote:
>>>>>>> On Mon, Feb 25, 2019 at 01:55:42PM +0000, Julien Grall wrote:
>>>>>>>> Hi Oleksandr,
>>>>>>>>
>>>>>>>> On 25/02/2019 13:24, Oleksandr Andrushchenko wrote:
>>>>>>>>> On 2/22/19 3:33 PM, Julien Grall wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> On 22/02/2019 12:38, Oleksandr Andrushchenko wrote:
>>>>>>>>>>> On 2/20/19 10:46 PM, Julien Grall wrote:
>>>>>>>>>>>> Discussing with my team, a solution that came up would be to
>>>>>>>>>>>> introduce one atomic field per event to record the number of
>>>>>>>>>>>> event received. I will explore that solution tomorrow.
>>>>>>>>>>> How will this help if events have some payload?
>>>>>>>>>> What payload? The event channel does not carry any payload. It only
>>>>>>>>>> notify you that something happen. Then this is up to the user to
>>>>>>>>>> decide what to you with it.
>>>>>>>>> Sorry, I was probably not precise enough. I mean that an event might have
>>>>>>>>> associated payload in the ring buffer, for example [1]. So, counting events
>>>>>>>>> may help somehow, but the ring's data may still be lost
>>>>>>>>    From my understanding of event channels are edge interrupts. By definition,
>>>>>>> IMO event channels are active high level interrupts.
>>>>>>>
>>>>>>> Let's take into account the following situation: you have an event
>>>>>>> channel masked and the event channel pending bit (akin to the line on
>>>>>>> bare metal) goes from low to high (0 -> 1), then you unmask the
>>>>>>> interrupt and you get an event injected. If it was an edge interrupt
>>>>>>> you wont get an event injected after unmasking, because you would
>>>>>>> have lost the edge. I think the problem here is that Linux treats
>>>>>>> event channels as edge interrupts, when they are actually level.
>>>>>>
>>>>>> Event channels are edge interrupts.  There are several very subtle bugs
>>>>>> to be had by software which treats them as line interrupts.
>>>>>>
>>>>>> Most critically, if you fail to ack them, rebind them to a new vcpu, and
>>>>>> reenable interrupts, you don't get a new interrupt notification.  This
>>>>>> was the source of a 4 month bug when XenServer was moving from
>>>>>> classic-xen to PVOps where using irqbalance would cause dom0 to
>>>>>> occasionally lose interrupts.
>>>>>
>>>>> I would argue that you need to mask them first, rebind to a new vcpu
>>>>> and unmask, and then you will get an interrupt notification, or this
>>>>> should be fixed in Xen to work as you expect: trigger an interrupt
>>>>> notification when moving an asserted event channel between CPUs.
>>>>>
>>>>> Is there any document that describes how such non trivial things (like
>>>>> moving between CPUs) work for event/level interrupts?
>>>>>
>>>>> Maybe I'm being obtuse, but from the example I gave above it's quite
>>>>> clear to me event channels don't get triggered based on edge changes,
>>>>> but rather on the line level.
>>>>
>>>> Your example above is not enough to give the semantics of level. You would
>>>> only use the MASK bit if your interrupt handler is threaded to avoid the
>>>> interrupt coming up again.
>>>>
>>>> So if you remove the mask from the equation, then the interrupt flow should be:
>>>>
>>>> 1) handle interrupt
>>>> 2) EOI
>>>
>>> This is bogus if you don't mask the interrupt source. You should
>>> instead do
>>>
>>> 1) EOI
>>> 2) Handle interrupt
>>>
>>> And loop over this.
>> So that's not a level semantics. It is a edge one :). In the level case, you
>> would clear the state once you are done with the interrupt.
>>
>> Also, it would be ACK and not EOI.
> 
> For level triggered interrupts you have to somehow signal the device
> to stop asserting the line, which doesn't happen for Xen devices
> because they just signal interrupts to Xen, but don't have a way to
> keep event channels asserted, so I agree that this is different from
> traditional level interrupts because devices using event channels
> don't have a way to keep lines asserted.
> 
> I guess the most similar native interrupt is MSI with masking
> support?

I don't know enough about MSI with masking support to be able to draw a 
comparison :).

The flow I have been suggested to re-use in Linux is 
handle_fasteoi_ack_irq. I haven't yet had time to have a try at it.

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-02-27 11:09 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5e256d9a-572c-e01e-7706-407f99245b00@arm.com>
2019-02-20  0:02 ` xen/evtchn and forced threaded irq Boris Ostrovsky
     [not found] ` <20190220000209.GA4091@localhost.localdomain>
2019-02-20 14:15   ` Julien Grall
     [not found]   ` <a872d480-9f1b-6cd7-e507-ac4fcdf705af@arm.com>
2019-02-20 17:07     ` Boris Ostrovsky
     [not found]     ` <21214d47-9c68-e6bf-007a-4047cc2b02f9@oracle.com>
2019-02-20 18:05       ` Julien Grall
     [not found]       ` <8f7445d7-fa50-f3e9-44f5-cc2aebd020f4@arm.com>
2019-02-20 20:04         ` Boris Ostrovsky
     [not found]         ` <15bc52cb-82d8-4d2c-e5a8-c6ae8de90276@oracle.com>
2019-02-20 20:46           ` Julien Grall
     [not found]           ` <5df8888a-4a29-fccd-bac2-a9c170244029@arm.com>
2019-02-20 21:46             ` Boris Ostrovsky
     [not found]             ` <1574a7fe-a5ac-4bc2-d3f0-967d8d01e5f1@oracle.com>
2019-02-20 22:03               ` Julien Grall
     [not found]               ` <1100e6b1-6fa8-06f0-8ecc-b0699a2ce5f4@arm.com>
2019-02-21  8:07                 ` Roger Pau Monné
     [not found]                 ` <20190221080752.zy2qlzb4vi7tbu3p@Air-de-Roger>
2019-02-21  8:38                   ` Julien Grall
2019-02-21  8:52                     ` Juergen Gross
2019-02-21  9:14                     ` Roger Pau Monné
     [not found]                     ` <20190221091431.vqi53op37mvhi25z@Air-de-Roger>
2019-02-21 20:46                       ` Julien Grall
2020-04-27 23:20                     ` [Xen-devel] " Stefano Stabellini
2019-02-22 11:44                 ` Jan Beulich
2019-02-22 12:38             ` Oleksandr Andrushchenko
     [not found]             ` <f7e78bf6-6e65-6d6c-c1ad-dca7f1e66b17@gmail.com>
2019-02-22 13:33               ` Julien Grall
     [not found]               ` <fe44917f-bbe9-3e0e-fdda-2eb4db9f25c2@arm.com>
2019-02-25 13:24                 ` Oleksandr Andrushchenko
     [not found]                 ` <13a9616c-2d9a-f90b-3358-f2dcadbbb64d@gmail.com>
2019-02-25 13:55                   ` Julien Grall
     [not found]                   ` <dbfd87e9-48fc-f641-9e24-ddb6c4f61135@arm.com>
2019-02-25 14:08                     ` Oleksandr Andrushchenko
     [not found]                     ` <1aeda04d-3420-fa50-ad33-a0b3e981f5e4@gmail.com>
2019-02-25 15:26                       ` Julien Grall
2019-02-26  9:14                     ` Roger Pau Monné
     [not found]                     ` <20190226091420.klgldhotiecezw6h@Air-de-Roger>
2019-02-26  9:30                       ` Andrew Cooper
     [not found]                       ` <038b837c-63c0-afb7-ca7b-75f61af7518e@citrix.com>
2019-02-26  9:44                         ` Roger Pau Monné
2019-02-26  9:45                         ` Paul Durrant
     [not found]                         ` <20190226094459.33y2ygrjei3sf3gk@Air-de-Roger>
2019-02-26 10:03                           ` Julien Grall
     [not found]                           ` <21c331d5-0cfa-6f7e-3db4-40b7ece45bc8@arm.com>
2019-02-26 10:17                             ` Roger Pau Monné
     [not found]                             ` <20190226101721.kh5vbrqdlnrtvhwh@Air-de-Roger>
2019-02-26 10:26                               ` Julien Grall
     [not found]                               ` <cdd5781c-3a60-b9f7-205f-fadeee88206e@arm.com>
2019-02-26 11:02                                 ` Roger Pau Monné
     [not found]                                 ` <20190226110231.46luhevhlmefdldo@Air-de-Roger>
2019-02-27 11:09                                   ` Julien Grall [this message]
2019-02-21  8:17 ` Juergen Gross
2019-02-19 17:31 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='44f13194-6e18-5a05-bfb1-9c5c7af255e0__15604.1130352364$1551267419$gmane$org@arm.com' \
    --to=julien.grall@arm.com \
    --cc=Dave.Martin@arm.com \
    --cc=JBeulich@suse.com \
    --cc=andr2000@gmail.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.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).