From: Ian Jackson Subject: [PATCH 10/11] mini-os/xenbus: Provide queue->wakeup hook Date: Fri, 20 Jun 2014 20:04:49 +0100 Message-ID: <1403291090-8657-11-git-send-email-ian.jackson@eu.citrix.com> References: <1403291090-8657-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wy47W-0000rZ-Up for xen-devel@lists.xenproject.org; Fri, 20 Jun 2014 19:05:07 +0000 In-Reply-To: <1403291090-8657-1-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: xen-devel@lists.xenproject.org Cc: Keir Fraser , Ian Jackson , Ian Campbell List-Id: xen-devel@lists.xenproject.org This allows xenbus's caller to get called back when an item is put on the queue, rather than simply having the waitq signaled. 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 = 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 = queue_wakeup; init_waitqueue_head(&queue->waitq); } @@ -92,7 +98,7 @@ static void queue_event(struct xenbus_event_queue *queue, { /* 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