From: Samuel Thibault Subject: Re: [PATCH 10/11] mini-os/xenbus: Provide queue->wakeup hook Date: Thu, 26 Jun 2014 14:18:10 +0200 Message-ID: <20140626121810.GY6046@type.bordeaux.inria.fr> References: <1403291090-8657-1-git-send-email-ian.jackson@eu.citrix.com> <1403291090-8657-11-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X08d3-0003Jt-9x for xen-devel@lists.xenproject.org; Thu, 26 Jun 2014 12:18:13 +0000 Content-Disposition: inline In-Reply-To: <1403291090-8657-11-git-send-email-ian.jackson@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: xen-devel@lists.xenproject.org, Keir Fraser , Ian Campbell List-Id: xen-devel@lists.xenproject.org Ian Jackson, le Fri 20 Jun 2014 20:04:49 +0100, a =E9crit : > This allows xenbus's caller to get called back when an item is put on > the queue, rather than simply having the waitq signaled. Mmm, so the callback will be made with lock held, is that not a problem in the use you plan? Although I don't usually like callbacks precisely for that kind of reason, I'm not against it, but it should at least be documented. > Signed-off-by: Ian Jackson > --- > include/mini-os/xenbus.h | 15 +++++++++++++++ > xen/xenbus/xenbus.c | 8 +++++++- > 2 files changed, 22 insertions(+), 1 deletion(-) > = > diff --git a/include/mini-os/xenbus.h b/include/mini-os/xenbus.h > index a811c19..1900e55 100644 > --- a/include/mini-os/xenbus.h > +++ b/include/mini-os/xenbus.h > @@ -46,6 +46,7 @@ struct xenbus_event { > }; > struct xenbus_event_queue { > MINIOS_STAILQ_HEAD(, xenbus_event) events; > + void (*wakeup)(struct xenbus_event_queue*); /* can be safely ignored= */ > struct wait_queue_head waitq; > }; > = > @@ -129,6 +130,20 @@ domid_t xenbus_get_self_id(void); > * ----- asynchronous low-level interface ----- > */ > = > +/* > + * Use of queue->wakeup: > + * > + * If queue->wakeup is set, it will be called instead of > + * wake_up(&queue->waitq); > + * > + * queue->wakeup is initialised (to a function which just calls > + * wake_up) by xenbus_event_queue_init. The user who wants something > + * different should set ->wakeup after the init, but before the queue > + * is used for xenbus_id_allocate or xenbus_watch_prepare. > + * > + * queue->wakeup() is called with the req_lock held. > + */ > + > /* Allocate an identifier for a xenbus request. Blocks if none are > * available. Cannot fail. On return, we may use the returned value > * as the id in a xenbus request. > diff --git a/xen/xenbus/xenbus.c b/xen/xenbus/xenbus.c > index 7b391c5..e5d7f36 100644 > --- a/xen/xenbus/xenbus.c > +++ b/xen/xenbus/xenbus.c > @@ -67,9 +67,15 @@ spinlock_t xenbus_req_lock =3D SPIN_LOCK_UNLOCKED; > * watches > */ > = > +static void queue_wakeup(struct xenbus_event_queue *queue) > +{ > + wake_up(&queue->waitq); > +} > + > void xenbus_event_queue_init(struct xenbus_event_queue *queue) > { > MINIOS_STAILQ_INIT(&queue->events); > + queue->wakeup =3D queue_wakeup; > init_waitqueue_head(&queue->waitq); > } > = > @@ -92,7 +98,7 @@ static void queue_event(struct xenbus_event_queue *queu= e, > { > /* Called with lock held */ > MINIOS_STAILQ_INSERT_TAIL(&queue->events, event, entry); > - wake_up(&queue->waitq); > + queue->wakeup(queue); > } > = > static struct xenbus_event *await_event(struct xenbus_event_queue *queue) > -- = > 1.7.10.4 > = > = > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel > = -- = Samuel argh, pi est plus grand que 2. Ca casse tout -+- #ens-mim -+-