xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Bruno Alvisio <bruno.alvisio@gmail.com>
To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org
Cc: jgross@suse.com, samuel.thibault@ens-lyon.org, wei.liu2@citrix.com
Subject: [PATCH v2 04/16] Save/Restore Support: Add xenbus_release_wait_for_watch
Date: Tue, 13 Feb 2018 18:27:27 -0800	[thread overview]
Message-ID: <1518575259-71141-5-git-send-email-bruno.alvisio@gmail.com> (raw)
In-Reply-To: <1518575259-71141-1-git-send-email-bruno.alvisio@gmail.com>

xenbus_release_wait_for_watch generates a fake event to trigger make
xenbus_wait_for_watch return. This is necessary to wake up waiting threads.

release_xenbus_id additionally checks if the number of requests == 0 to wake
up the 'waiting' suspend xenbus thread.

Signed-off-by: Bruno Alvisio <bruno.alvisio@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
Changed since v1:
  * Added doc for change in release_xenbus_id
---
 include/xenbus.h |  1 +
 xenbus/xenbus.c  | 10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/include/xenbus.h b/include/xenbus.h
index 12391b9..b2d5072 100644
--- a/include/xenbus.h
+++ b/include/xenbus.h
@@ -42,6 +42,7 @@ char *xenbus_unwatch_path_token(xenbus_transaction_t xbt, const char *path, cons
 extern struct wait_queue_head xenbus_watch_queue;
 void xenbus_wait_for_watch(xenbus_event_queue *queue);
 char **xenbus_wait_for_watch_return(xenbus_event_queue *queue);
+void xenbus_release_wait_for_watch(xenbus_event_queue *queue);
 char* xenbus_wait_for_value(const char *path, const char *value, xenbus_event_queue *queue);
 char *xenbus_wait_for_state_change(const char* path, XenbusState *state, xenbus_event_queue *queue);
 char *xenbus_switch_state(xenbus_transaction_t xbt, const char* path, XenbusState state);
diff --git a/xenbus/xenbus.c b/xenbus/xenbus.c
index 636786c..c2d2bd1 100644
--- a/xenbus/xenbus.c
+++ b/xenbus/xenbus.c
@@ -129,6 +129,14 @@ void xenbus_wait_for_watch(xenbus_event_queue *queue)
         printk("unexpected path returned by watch\n");
 }
 
+void xenbus_release_wait_for_watch(xenbus_event_queue *queue)
+{
+    struct xenbus_event *event = malloc(sizeof(*event));
+    event->next = *queue;
+    *queue = event;
+    wake_up(&xenbus_watch_queue);
+}
+
 char* xenbus_wait_for_value(const char* path, const char* value, xenbus_event_queue *queue)
 {
     if (!queue)
@@ -318,7 +326,7 @@ static void release_xenbus_id(int id)
     req_info[id].in_use = 0;
     nr_live_reqs--;
     req_info[id].in_use = 0;
-    if (nr_live_reqs == NR_REQS - 1)
+    if (nr_live_reqs == 0 || nr_live_reqs == NR_REQS - 1)
         wake_up(&req_wq);
     spin_unlock(&req_lock);
 }
-- 
2.3.2 (Apple Git-55)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-02-14  2:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14  2:27 [PATCH v2 00/16] Save/Restore Support for mini-OS PVH Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 01/16] Save/Restore Support: Refactor HYPERVISOR_suspend hypercall Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 02/16] Save/Restore Support: Refactor trap_init() and setup vector callbacks Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 03/16] Save/Restore Support: Declare kernel and arch pre/post suspend functions Bruno Alvisio
2018-02-14  2:27 ` Bruno Alvisio [this message]
2018-02-14  2:27 ` [PATCH v2 05/16] Save/Restore Support: Add kernel shutdown logic to shutdown.c Bruno Alvisio
2018-02-14  8:19   ` Juergen Gross
2018-02-14  2:27 ` [PATCH v2 06/16] Save/Restore Support: Moved shutdown thread " Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 07/16] Save/Restore Support: Add unmap_shared_info Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 08/16] Save/Restore Support: Add arch_mm_pre|post_suspend Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 09/16] Save/Restore Support: Disable/enable IRQs during suspend/restore Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 10/16] Save/Restore Support: Add suspend/resume support for timers Bruno Alvisio
2018-02-14  8:20   ` Juergen Gross
2018-02-14  2:27 ` [PATCH v2 11/16] Save/Restore Support: Add suspend/restore support for console Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 12/16] Save/Restore Support: Add support for suspend/restore events Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 13/16] Save/Restore Support: Add suspend/restore support for Grant Tables Bruno Alvisio
2018-02-14 12:42   ` Juergen Gross
2018-02-14  2:27 ` [PATCH v2 14/16] Save/Restore Support: Add suspend/restore support for xenbus Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 15/16] Save/Restore Support: Add suspend/restore support for netfront Bruno Alvisio
2018-02-14  2:27 ` [PATCH v2 16/16] Save/Restore Support: Implement code for arch suspend/resume Bruno Alvisio

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=1518575259-71141-5-git-send-email-bruno.alvisio@gmail.com \
    --to=bruno.alvisio@gmail.com \
    --cc=jgross@suse.com \
    --cc=minios-devel@lists.xenproject.org \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=wei.liu2@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 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).