mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Juergen Gross <jgross@suse.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	xen-devel@lists.xenproject.org, x86@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/xen: remove unneeded preempt_disable() from xen_irq_enable()
Date: Tue, 21 Sep 2021 10:11:16 +0200	[thread overview]
Message-ID: <6305dfb1-15bc-ce4b-cbf7-d44ef5c0456d@suse.com> (raw)
In-Reply-To: <599f4e20-a25d-6cd0-ced5-f2deaf997535@suse.com>

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@suse.com>

Jan


  reply	other threads:[~2021-09-21  8:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21  7:02 Juergen Gross
2021-09-21  7:53 ` Jan Beulich
2021-09-21  7:58   ` Juergen Gross
2021-09-21  8:11     ` Jan Beulich [this message]
2021-09-21  8:24       ` Juergen Gross
2021-09-21  8:27 ` Peter Zijlstra
2021-09-21  9:48   ` Juergen Gross
2021-09-22 10:46 ` Juergen Gross

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=6305dfb1-15bc-ce4b-cbf7-d44ef5c0456d@suse.com \
    --to=jbeulich@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=sstabellini@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@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

all inboxes | Powered by JetHome®