From: David Vrabel <david.vrabel@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: David Vrabel <david.vrabel@citrix.com>,
Jan Beulich <jbeulich@suse.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCHv1 2/2] passthrough: improve locking when iterating over interrupts bound to VMs
Date: Fri, 23 Oct 2015 12:05:22 +0100 [thread overview]
Message-ID: <1445598322-22154-3-git-send-email-david.vrabel@citrix.com> (raw)
In-Reply-To: <1445598322-22154-1-git-send-email-david.vrabel@citrix.com>
radix_tree_gang_lookup() only requires a RCU read lock, not the
per-domain event_lock.
Introduce a new RCU read lock and take the per-interrupt lock before
calling the callback instead.
This eliminates all contention on the event_lock when injecting
interrupts from passthrough devices.
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
xen/drivers/passthrough/io.c | 10 +++++++---
xen/include/xen/sched.h | 1 +
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c
index 7c86c20..9b51ef0 100644
--- a/xen/drivers/passthrough/io.c
+++ b/xen/drivers/passthrough/io.c
@@ -601,7 +601,7 @@ int pt_pirq_iterate(struct domain *d,
unsigned int pirq = 0, n, i;
struct pirq *pirqs[8];
- ASSERT(spin_is_locked(&d->event_lock));
+ rcu_read_lock(&d->pirq_rcu_lock);
do {
n = radix_tree_gang_lookup(&d->pirq_tree, (void **)pirqs, pirq,
@@ -610,12 +610,18 @@ int pt_pirq_iterate(struct domain *d,
{
struct hvm_pirq_dpci *pirq_dpci = pirq_dpci(pirqs[i]);
+ spin_lock(&pirq_dpci->lock);
+
pirq = pirqs[i]->pirq;
if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MAPPED) )
rc = cb(d, pirq_dpci, arg);
+
+ spin_unlock(&pirq_dpci->lock);
}
} while ( !rc && ++pirq < d->nr_pirqs && n == ARRAY_SIZE(pirqs) );
+ rcu_read_unlock(&d->pirq_rcu_lock);
+
return rc;
}
@@ -678,9 +684,7 @@ void hvm_dpci_msi_eoi(struct domain *d, int vector)
if ( !iommu_enabled || !d->arch.hvm_domain.irq.dpci )
return;
- spin_lock(&d->event_lock);
pt_pirq_iterate(d, _hvm_dpci_msi_eoi, (void *)(long)vector);
- spin_unlock(&d->event_lock);
}
static void hvm_dirq_assist(struct domain *d, struct hvm_pirq_dpci *pirq_dpci)
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 3729b0f..ae98c1e 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -355,6 +355,7 @@ struct domain
*/
struct radix_tree_root pirq_tree;
unsigned int nr_pirqs;
+ rcu_read_lock_t pirq_rcu_lock;
enum guest_type guest_type;
--
2.1.4
next prev parent reply other threads:[~2015-10-23 11:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-23 11:05 passthrough: improve interrupt injection locking David Vrabel
2015-10-23 11:05 ` [PATCHv1 1/2] passthrough: use per-interrupt lock when injecting an interrupt David Vrabel
2015-10-27 11:56 ` Jan Beulich
2015-10-28 20:18 ` Konrad Rzeszutek Wilk
2015-10-29 9:11 ` Jan Beulich
2015-10-30 14:45 ` Konrad Rzeszutek Wilk
2015-10-23 11:05 ` David Vrabel [this message]
2015-10-27 12:44 ` [PATCHv1 2/2] passthrough: improve locking when iterating over interrupts bound to VMs Jan Beulich
2015-10-27 13:11 ` David Vrabel
2015-10-28 20:42 ` Konrad Rzeszutek Wilk
2015-10-23 12:37 ` passthrough: improve interrupt injection locking Ian Campbell
2015-10-23 12:38 ` David Vrabel
2015-10-23 12:45 ` Ian Campbell
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=1445598322-22154-3-git-send-email-david.vrabel@citrix.com \
--to=david.vrabel@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=jbeulich@suse.com \
--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).