From: Andrew Cooper <andrew.cooper3@citrix.com>
To: David Vrabel <david.vrabel@citrix.com>, xen-devel@lists.xenproject.org
Cc: Tim Deegan <tim@xen.org>, Keir Fraser <keir@xen.org>,
Ian Campbell <ian.campbell@citrix.com>,
Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCHv1 4/6] evtchn: use a per-event channel lock for sending events
Date: Tue, 9 Jun 2015 16:17:00 +0100 [thread overview]
Message-ID: <5577036C.5050006@citrix.com> (raw)
In-Reply-To: <1433861999-15771-5-git-send-email-david.vrabel@citrix.com>
On 09/06/15 15:59, David Vrabel wrote:
> When sending an event, use a new per-event channel lock to safely
> validate the event channel state.
>
> This new lock must be held when changing event channel state.
>
> To avoid having to take the remote event channel locks when sending to
> an interdomain event channel, the local and remote channel locks are
> both held when binding or closing an interdomain event channel.
>
> This significantly increases the number of events that can be sent
> from multiple VCPUs.
>
> But, struct evtchn increases in size, reducing the number that fit
> into a single page to 64 (instead of 128).
>
> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
> ---
> xen/common/event_channel.c | 84 +++++++++++++++++++++++++++++++++++++-------
> xen/include/xen/sched.h | 1 +
> 2 files changed, 73 insertions(+), 12 deletions(-)
>
> diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
> index 482c3ac..71747d1 100644
> --- a/xen/common/event_channel.c
> +++ b/xen/common/event_channel.c
> @@ -139,6 +139,7 @@ static struct evtchn *alloc_evtchn_bucket(struct domain *d, unsigned int port)
> return NULL;
> }
> chn[i].port = port + i;
> + spin_lock_init(&chn[i].lock);
> }
> return chn;
> }
> @@ -228,11 +229,15 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)
> if ( rc )
> goto out;
>
> + spin_lock(&chn->lock);
> +
> chn->state = ECS_UNBOUND;
> if ( (chn->u.unbound.remote_domid = alloc->remote_dom) == DOMID_SELF )
> chn->u.unbound.remote_domid = current->domain->domain_id;
> evtchn_port_init(d, chn);
>
> + spin_unlock(&chn->lock);
> +
> alloc->port = port;
>
> out:
> @@ -243,6 +248,30 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)
> }
>
>
> +static void double_evtchn_lock(struct domain *ld, struct evtchn *lchn,
> + struct domain *rd, struct evtchn *rchn)
> +{
> + if ( ld < rd || (ld == rd && lchn->port < rchn->port) )
ld < rd is undefined behaviour as they are not part of the same
singly-allocated object. It would be better to choose order based on
domid, and looks like the grant code suffers the same issue.
~Andrew
next prev parent reply other threads:[~2015-06-09 15:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-09 14:59 [PATCHv1 0/6] evtchn: Improve scalebility David Vrabel
2015-06-09 14:59 ` [PATCHv1 1/6] evtchn: profile event channel lock David Vrabel
2015-06-09 14:59 ` [PATCHv1 2/6] evtchn: factor out freeing an event channel David Vrabel
2015-06-09 14:59 ` [PATCHv1 3/6] evtchn: simplify port_is_valid() David Vrabel
2015-06-09 15:08 ` Andrew Cooper
2015-06-09 15:16 ` David Vrabel
2015-06-09 14:59 ` [PATCHv1 4/6] evtchn: use a per-event channel lock for sending events David Vrabel
2015-06-09 15:17 ` Andrew Cooper [this message]
2015-06-10 8:59 ` Jan Beulich
2015-06-09 14:59 ` [PATCHv1 5/6] evtchn: remove the locking when unmasking an event channel David Vrabel
2015-06-09 14:59 ` [PATCHv1 6/6] evtchn: pad struct evtchn to 64 bytes David Vrabel
2015-06-10 9:04 ` Jan Beulich
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=5577036C.5050006@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=david.vrabel@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=tim@xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.