All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: xen-devel@lists.xenproject.org,
	Keir Fraser <keir.fraser@citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>
Subject: Re: [PATCH 03/11] mini-os/xenbus: Add missing locks to xb_write
Date: Thu, 26 Jun 2014 14:04:07 +0200	[thread overview]
Message-ID: <20140626120407.GS6046@type.bordeaux.inria.fr> (raw)
In-Reply-To: <1403291090-8657-4-git-send-email-ian.jackson@eu.citrix.com>

Ian Jackson, le Fri 20 Jun 2014 20:04:42 +0100, a écrit :
> xb_write was missing any locking against concurrent calls.

Well, yes, in its current form mini-os was not really meant to run with
multiple processors. There are probably quite other issues like that in
there.

> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>

Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  xen/xenbus/xenbus.c |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/xen/xenbus/xenbus.c b/xen/xenbus/xenbus.c
> index 0958604..a06dc30 100644
> --- a/xen/xenbus/xenbus.c
> +++ b/xen/xenbus/xenbus.c
> @@ -45,6 +45,7 @@
>  
>  static struct xenstore_domain_interface *xenstore_buf;
>  static DECLARE_WAIT_QUEUE_HEAD(xb_waitq);
> +static spinlock_t xb_lock = SPIN_LOCK_UNLOCKED; /* protects xenbus req ring */
>  DECLARE_WAIT_QUEUE_HEAD(xenbus_watch_queue);
>  
>  xenbus_event_queue xenbus_events;
> @@ -372,6 +373,8 @@ static void xb_write(int type, int req_id, xenbus_transaction_t trans_id,
>      cur_req = &header_req;
>  
>      BUG_ON(len > XENSTORE_RING_SIZE);
> +
> +    spin_lock(&xb_lock);
>      /* Wait for the ring to drain to the point where we can send the
>         message. */
>      prod = xenstore_buf->req_prod;
> @@ -380,9 +383,11 @@ static void xb_write(int type, int req_id, xenbus_transaction_t trans_id,
>          /* Wait for there to be space on the ring */
>          DEBUG("prod %d, len %d, cons %d, size %d; waiting.\n",
>                  prod, len, xenstore_buf->req_cons, XENSTORE_RING_SIZE);
> +        spin_unlock(&xb_lock);
>          wait_event(xb_waitq,
>                  xenstore_buf->req_prod + len - xenstore_buf->req_cons <=
>                  XENSTORE_RING_SIZE);
> +        spin_lock(&xb_lock);
>          DEBUG("Back from wait.\n");
>          prod = xenstore_buf->req_prod;
>      }
> @@ -419,6 +424,7 @@ static void xb_write(int type, int req_id, xenbus_transaction_t trans_id,
>      wmb();
>  
>      xenstore_buf->req_prod += len;
> +    spin_unlock(&xb_lock);
>  
>      /* Send evtchn to notify remote */
>      notify_remote_via_evtchn(start_info.store_evtchn);
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

-- 
Samuel
<N>  sl  -  display animations aimed to correct users who accidentally enter
<N>        sl instead of ls.

  reply	other threads:[~2014-06-26 12:04 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-20 19:04 [RFC PATCH 00/11] mini-os: xenbus changes for rump kernels Ian Jackson
2014-06-20 19:04 ` [PATCH 01/11] mini-os: Make some headers more rumpkernel-friendly Ian Jackson
2014-06-23 10:32   ` Andrew Cooper
2014-06-23 14:24     ` Ian Jackson
2014-06-26 11:54   ` Samuel Thibault
2014-06-20 19:04 ` [PATCH 02/11] mini-os: Provide <mini-os/queue.h> Ian Jackson
2014-06-26 11:59   ` Samuel Thibault
2014-06-20 19:04 ` [PATCH 03/11] mini-os/xenbus: Add missing locks to xb_write Ian Jackson
2014-06-26 12:04   ` Samuel Thibault [this message]
2014-06-30 12:47     ` Ian Jackson
2014-06-30 12:59       ` Samuel Thibault
2014-06-20 19:04 ` [PATCH 04/11] mini-os/xenbus: Change type of xenbus_event_queue Ian Jackson
2014-06-26 12:06   ` Samuel Thibault
2014-06-20 19:04 ` [PATCH 05/11] mini-os/xenbus: Use MINIOS_LIST for the list of watches Ian Jackson
2014-06-26 12:06   ` Samuel Thibault
2014-06-20 19:04 ` [PATCH 06/11] mini-os/xenbus: Rename xenbus_events to xenbus_default_watch_queue Ian Jackson
2014-06-26 12:07   ` Samuel Thibault
2014-06-20 19:04 ` [PATCH 07/11] mini-os/xenbus: Unify watch and reply queues Ian Jackson
2014-06-26 12:15   ` Samuel Thibault
2014-06-20 19:04 ` [PATCH 08/11] mini-os/xenbus: Expose lower-level interface Ian Jackson
2014-06-26 12:24   ` Samuel Thibault
2014-06-20 19:04 ` [PATCH 09/11] mini-os/xenbus: Sort out request and watch locking Ian Jackson
2014-06-26 12:16   ` Samuel Thibault
2014-06-20 19:04 ` [PATCH 10/11] mini-os/xenbus: Provide queue->wakeup hook Ian Jackson
2014-06-26 12:18   ` Samuel Thibault
2014-06-30 12:49     ` Ian Jackson
2014-06-20 19:04 ` [PATCH 11/11] mini-os/xenbus: Provide xenbus_free Ian Jackson
2014-06-26 12:24   ` Samuel Thibault
2014-06-23 10:25 ` [RFC PATCH 00/11] mini-os: xenbus changes for rump kernels George Dunlap
2014-06-23 14:27   ` Ian Jackson
2014-06-23 10:35 ` Andrew Cooper
2014-06-23 14:26   ` Ian Jackson
2014-06-27 11:52     ` Ian Campbell
2014-06-27 11:59       ` Samuel Thibault
2014-06-30 15:19       ` Ian Jackson

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=20140626120407.GS6046@type.bordeaux.inria.fr \
    --to=samuel.thibault@ens-lyon.org \
    --cc=Ian.Campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=keir.fraser@citrix.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 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.