[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86/xen: remove unneeded preempt_disable() from xen_irq_enable()


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 21 Sep 2021 10:11:16 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=q4DEfjy8i3majxxWRX69gfYnq7AfsHgE+0qIFCaUyk8=; b=C1BJ6PquMPSCR9wReG3akAIduEsN4m2GWuzOXyXy9xdMpRxytGOisxsD+eytzYKUs3Bk6R45aU4m3mmjxkTVaNX6WTKW4mq1H7lztdbK/9HzNTV9HnNGiGaVNe7nKBX1JI0mwhPTv8nyz5BK3JYnemb7UenNGXJoxny1FadhNNe/7n2meULrwoNangnw8ebRyBRSI/bB83JYepsuL4BqPFQaEidIm43NOugdks1yFeQOoMU19bqxnTVbcIupSU084/V3IuTQayYQ9RJapVMtvDiZIi3ZowIz8qomPf45BrnhviCA3udrrBdcn6s4Zfe166tUSlH63bLPsm2ByXpFDg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H3eWvomNzQPz7UInTvPpt3TV8/uUKAvkBiQ7CINIEAiaQ9zHM7pDU7NViFRwFrxR/8P1bzUngGTM7HIQnjH3IYbkXhx8gBhBGkCgP2N9//cC5hrYYKGBztho66FP3Nw4N7thMUReCK379HCxgWxiJJn4HhMOd9cE50Qh9OckS7PsG5RGYEL5UMDrcBc848K7fNcjUTruKoMp760wEQmK8JeeRErBUlyaA82Xy/gNKskfYVkkxbMQqcRdEHmC6ONzKPztIXkU5nsHZ+tHEEKjgzrH7xWbRvMNEn6Z1JB+FV8yR/wXgYOh7UPc9EVaPafiV6nqwgaolwwiGXG0FIclFQ==
  • Authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=suse.com;
  • Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, x86@xxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
  • Delivery-date: Tue, 21 Sep 2021 08:11:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 21.09.2021 09:58, Juergen Gross wrote:
> On 21.09.21 09:53, Jan Beulich wrote:
>> On 21.09.2021 09:02, Juergen Gross wrote:
>>> --- a/arch/x86/xen/irq.c
>>> +++ b/arch/x86/xen/irq.c
>>> @@ -57,24 +57,20 @@ asmlinkage __visible void xen_irq_enable(void)
>>>   {
>>>     struct vcpu_info *vcpu;
>>>   
>>> -   /*
>>> -    * We may be preempted as soon as vcpu->evtchn_upcall_mask is
>>> -    * cleared, so disable preemption to ensure we check for
>>> -    * events on the VCPU we are still running on.
>>> -    */
>>> -   preempt_disable();
>>> -
>>>     vcpu = this_cpu_read(xen_vcpu);
>>>     vcpu->evtchn_upcall_mask = 0;
>>>   
>>> -   /* Doesn't matter if we get preempted here, because any
>>> -      pending event will get dealt with anyway. */
>>> +   /*
>>> +    * Now preemption could happen, but this is only possible if an event
>>> +    * was handled, so missing an event due to preemption is not
>>> +    * possible at all.
>>> +    * The worst possible case is to be preempted and then check events
>>> +    * pending on the old vcpu, but this is not problematic.
>>> +    */
>>
>> I agree this isn't problematic from a functional perspective, but ...
>>
>>>     barrier(); /* unmask then check (avoid races) */
>>>     if (unlikely(vcpu->evtchn_upcall_pending))
>>>             xen_force_evtchn_callback();
>>
>> ... is a stray call here cheaper than ...
>>
>>> -
>>> -   preempt_enable();
>>
>> ... the preempt_{dis,en}able() pair?
> 
> The question is if a stray call in case of preemption (very unlikely)
> is cheaper than the preempt_{dis|en}able() pair on each IRQ enabling.
> 
> I'm quite sure removing the preempt_*() calls will be a net benefit.

Well, yes, I agree. It would have been nice if the description pointed
out the fact that preemption kicking in precisely here is very unlikely.
But perhaps that's considered rather obvious ... The issue I'm having
is with the prior comments: They indicated that preemption happening
before the "pending" check would be okay, _despite_ the
preempt_{dis,en}able() pair. One could view this as an indication that
this pair was put there for another reason (e.g. to avoid the stray
calls). But it may of course also be that the comment simply was stale.

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

Jan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.