From: Anoob Soman <anoob.soman@citrix.com>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>,
<xen-devel@lists.xenproject.org>, <linux-kernel@vger.kernel.org>
Cc: <jgross@suse.com>
Subject: Re: [Xen-devel] [PATCH] xen-evtchn: Bind dyn evtchn:qemu-dm interrupt to next online VCPU
Date: Mon, 5 Jun 2017 15:49:42 +0100 [thread overview]
Message-ID: <0c2a3a4b-e442-8c8c-6a71-6f9972ff29fc@citrix.com> (raw)
In-Reply-To: <c8640680-b179-a6d6-cbb9-825d4bf0017d@oracle.com>
On 05/06/17 15:10, Boris Ostrovsky wrote:
>> The reason for percpu instead of global, was to avoid locking. We can
>> have a global variable (last_cpu) without locking, but value of
>> last_cpu wont be consistent, without locks. Moreover, since
>> irq_affinity is also used in the calculation of cpu to bind, having a
>> percpu or global wouldn't really matter, as the result (selected_cpu)
>> is more likely to be random (because different irqs can have different
>> affinity). What do you guys suggest.
> Doesn't initial affinity (which is what we expect here since irqbalance
> has not run yet) typically cover all guest VCPUs?
Yes, initial affinity covers all online VCPUs. But there is a small
chance that initial affinity might change, before
evtch_bind_interdom_next_vcpu is called. For example, I could run a
script to change irq affinity, just when irq sysfs entry appears. This
is the reason that I thought it would be sensible (based on your
suggestion) to include irq_affinity to calculate the next VCPU. If you
think, changing irq_affinity between request_irq() and
evtch_bind_interdom_next_vcpu is virtually impossible, then we can drop
affinity and just use cpu_online_mask.
>>
>> I think we would still require spin_lock(). spin_lock is for irq_desc.
> If you are trying to protect affinity then it may well change after you
> drop the lock.
>
> In fact, don't you have a race here? If we offline a VCPU we will (by
> way of cpu_disable_common()->fixup_irqs()) update affinity to reflect
> that a CPU is gone and there is a chance that xen_rebind_evtchn_to_cpu()
> will happen after that.
>
> So, contrary to what I said earlier ;-) not only do you need the lock,
> but you should hold it across xen_rebind_evtchn_to_cpu() call. Does this
> make sense?
Yes, you are correct. .irq_set_affinity pretty much does the same thing.
The code will now looks like this.
raw_spin_lock_irqsave(lock, flags);
percpu read
select_cpu
percpu write
xen_rebind_evtchn_to_cpu(evtchn, selected_cpu)
raw_spin_unlock_irqsave(lock, flags);
next prev parent reply other threads:[~2017-06-05 14:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-02 14:49 Anoob Soman
2017-06-02 15:10 ` Juergen Gross
2017-06-05 9:54 ` Anoob Soman
2017-06-02 16:24 ` Boris Ostrovsky
2017-06-05 10:14 ` Anoob Soman
2017-06-05 14:10 ` Boris Ostrovsky
2017-06-05 14:49 ` Anoob Soman [this message]
2017-06-05 15:32 ` [Xen-devel] " Boris Ostrovsky
2017-06-05 16:14 ` Anoob Soman
2017-06-05 16:46 ` Boris Ostrovsky
2017-06-05 17:13 ` Anoob Soman
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=0c2a3a4b-e442-8c8c-6a71-6f9972ff29fc@citrix.com \
--to=anoob.soman@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.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®