Skip to contentSkip to conversation

Two mini-os xenbus patches

PATCH Applied Wei Liu 3 participants 9 messages Oct 27, 2015 – Nov 16, 2015

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

v3 cover Two mini-os xenbus patches

I broke down my previous patch to two patches. Both of them should be applied to mini-os staging. The first patch should be applied to the (to be created) stable-4.6 mini-os branch, along with a proper fix to oxenstored.

Wei Liu (2):
xenbus: notify the other end when necessary
xenbus: workaround oxenstored short-write

 xenbus/xenbus.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
Signature · 1 line
2.1.4
author
#1 lore raw

PATCH v3 1/2 xenbus: notify the other end when necessary

The xenbus thread didn't send notification to other end when it expected more data or consumed responses, which led to stalling the ring from time to time.

This is the culprit that guest was less responsive when using stubdom because the device model was stalled.

Fix this by sending notification to the other end when it consumes a message. A bunch of memory barriers are also added to ensure correctness.

---
 xenbus/xenbus.c | 5 +++++
 1 file changed, 5 insertions(+)
xenbus/xenbus.c +5 -0
index 4613ed6..0ab387a 100644
@@ -237,6 +237,7 @@ static void xenbus_thread_func(void *ign)
 		event->path = data;
 		event->token = event->path + strlen(event->path) + 1;
 
+                mb();
                 xenstore_buf->rsp_cons += msg.len + sizeof(msg);
 
                 for (watch = watches; watch; watch = watch->next)
@@ -262,9 +263,13 @@ static void xenbus_thread_func(void *ign)
                     req_info[msg.req_id].reply,
                     MASK_XENSTORE_IDX(xenstore_buf->rsp_cons),
                     msg.len + sizeof(msg));
+                mb();
                 xenstore_buf->rsp_cons += msg.len + sizeof(msg);
                 wake_up(&req_info[msg.req_id].waitq);
             }
+
+            wmb();
+            notify_remote_via_evtchn(start_info.store_evtchn);
         }
     }
 }
Signature · 1 line
2.1.4
Acked-by on v3 1/2
#2 lore raw

Re: [PATCH MINI-OS v3 1/2] xenbus: notify the other end when necessary

Quoted 4 lines · Wei Liu, le Tue 27 Oct 2015 15:43:28 +0000, a écrit :

The xenbus thread didn't send notification to other end when it expected more data or consumed responses, which led to stalling the ring from time to time.

Quoted 8 lines

This is the culprit that guest was less responsive when using stubdom because the device model was stalled.

Fix this by sending notification to the other end when it consumes a message. A bunch of memory barriers are also added to ensure correctness.

And it should clearly be backported to stable branches.

Samuel

author
#3 lore raw

Re: [PATCH MINI-OS v3 1/2] xenbus: notify the other end when necessary

Quoted 8 lines · Samuel Thibault
Quoted 7 lines · Wei Liu, le Tue 27 Oct 2015 15:43:28 +0000, a écrit :

The xenbus thread didn't send notification to other end when it expected more data or consumed responses, which led to stalling the ring from time to time.

This is the culprit that guest was less responsive when using stubdom because the device model was stalled.

Quoted 8 lines
Quoted 5 lines

Fix this by sending notification to the other end when it consumes a message. A bunch of memory barriers are also added to ensure correctness.

Thanks for your help along the way!

Quoted 3 lines

And it should clearly be backported to stable branches.

Samuel

Applied
#4 lore raw

Re: [PATCH MINI-OS v3 1/2] xenbus: notify the other end when necessary

In reply to Samuel Thibault
Quoted 9 lines · Samuel Thibault
Quoted 8 lines · Wei Liu, le Tue 27 Oct 2015 15:43:28 +0000, a écrit :

The xenbus thread didn't send notification to other end when it expected
more data or consumed responses, which led to stalling the ring from time to time.

This is the culprit that guest was less responsive when using stubdom because the device model was stalled.

Quoted 7 lines
Quoted 5 lines

Fix this by sending notification to the other end when it consumes a message. A bunch of memory barriers are also added to ensure correctness.

Applied.

Quoted 1 line

And it should clearly be backported to stable branches.

I don't think we have a mini-os branch for stable, but I'll let Ian J figure out the right way to achieve this.

Ian

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#5 lore raw

PATCH v3 2/2 xenbus: workaround oxenstored short-write

In reply to Wei Liu

Oxenstored has a behaviour that it only writes a contiguous piece of data. When it writes across ring boundary it will return a short-write while there is still room. That leads to mini-os stalling when it sees there is not enough data in the ring.

Given that oxenstored is the default xenstored implementation we think it would be useful to workaround this for the benefit of running mini-os (and unikernel based on it) on any Xen installation.

---
 xenbus/xenbus.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
xenbus/xenbus.c +8 -2
index 0ab387a..abf8b1b 100644
@@ -205,8 +205,11 @@ static void xenbus_thread_func(void *ign)
             prod = xenstore_buf->rsp_prod;
             DEBUG("Rsp_cons %d, rsp_prod %d.\n", xenstore_buf->rsp_cons,
                     xenstore_buf->rsp_prod);
-            if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons < sizeof(msg))
+            if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons < sizeof(msg)) {
+                /* Work around oxenstored bug */
+                notify_remote_via_evtchn(start_info.store_evtchn);
                 break;
+            }
             rmb();
             memcpy_from_ring(xenstore_buf->rsp,
                     &msg,
@@ -217,8 +220,11 @@ static void xenbus_thread_func(void *ign)
                     xenstore_buf->rsp_prod - xenstore_buf->rsp_cons,
                     msg.req_id);
             if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons <
-                    sizeof(msg) + msg.len)
+                    sizeof(msg) + msg.len) {
+                /* Work around oxenstored bug */
+                notify_remote_via_evtchn(start_info.store_evtchn);
                 break;
+            }
 
             DEBUG("Message is good.\n");
 
Signature · 1 line
2.1.4
Acked-by on v3 2/2
#6 lore raw

Re: [PATCH MINI-OS v3 2/2] xenbus: workaround oxenstored short-write

Quoted 10 lines · Wei Liu, le Tue 27 Oct 2015 15:43:29 +0000, a écrit :

Oxenstored has a behaviour that it only writes a contiguous piece of data. When it writes across ring boundary it will return a short-write while there is still room. That leads to mini-os stalling when it sees there is not enough data in the ring.

Given that oxenstored is the default xenstored implementation we think it would be useful to workaround this for the benefit of running mini-os (and unikernel based on it) on any Xen installation.

As discussed in the previous thread, this is rather a workaround. Better be safe than sorry.

And could too be backported to stable branches.

Quoted 37 lines
---
 xenbus/xenbus.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
xenbus/xenbus.c +8 -2
index 0ab387a..abf8b1b 100644
@@ -205,8 +205,11 @@ static void xenbus_thread_func(void *ign)
             prod = xenstore_buf->rsp_prod;
             DEBUG("Rsp_cons %d, rsp_prod %d.\n", xenstore_buf->rsp_cons,
                     xenstore_buf->rsp_prod);
-            if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons < sizeof(msg))
+            if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons < sizeof(msg)) {
+                /* Work around oxenstored bug */
+                notify_remote_via_evtchn(start_info.store_evtchn);
                 break;
+            }
             rmb();
             memcpy_from_ring(xenstore_buf->rsp,
                     &msg,
@@ -217,8 +220,11 @@ static void xenbus_thread_func(void *ign)
                     xenstore_buf->rsp_prod - xenstore_buf->rsp_cons,
                     msg.req_id);
             if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons <
-                    sizeof(msg) + msg.len)
+                    sizeof(msg) + msg.len) {
+                /* Work around oxenstored bug */
+                notify_remote_via_evtchn(start_info.store_evtchn);
                 break;
+            }
 
             DEBUG("Message is good.\n");
 
Signature · 1 line
2.1.4
Signature · 2 lines
Samuel
"c'est pas nous qui sommes à la rue, c'est la rue qui est à nous"
#7 lore raw

Re: [PATCH MINI-OS v3 2/2] xenbus: workaround oxenstored short-write

Quoted 6 lines · Samuel Thibault
Quoted 5 lines · Wei Liu, le Tue 27 Oct 2015 15:43:29 +0000, a écrit :

Oxenstored has a behaviour that it only writes a contiguous piece of data. When it writes across ring boundary it will return a short-write while there is still room. That leads to mini-os stalling when it sees there is not enough data in the ring.

Quoted 8 lines
Quoted 6 lines

Given that oxenstored is the default xenstored implementation we think it would be useful to workaround this for the benefit of running mini- os
(and unikernel based on it) on any Xen installation.

As discussed in the previous thread, this is rather a workaround.

Given that I'm in the process of applying "tools/ocaml/xb: Correct calculations of data/space the ring" which I think is the real fix here am unsure if we still want to take this workaround.

Any thoughts?

Quoted 39 lines

Better
be safe than sorry.

And could too be backported to stable branches.

Quoted 32 lines

---
 xenbus/xenbus.c | 10 ++++++++--

 1 file changed, 8 insertions(+), 2 deletions(-)
xenbus/xenbus.c +0 -0
index 0ab387a..abf8b1b 100644
@@ -205,8 +205,11 @@ static void xenbus_thread_func(void *ign)
              prod = xenstore_buf->rsp_prod;

             DEBUG("Rsp_cons %d, rsp_prod %d.\n", xenstore_buf-

Quoted 1 line

rsp_cons,

                     xenstore_buf->rsp_prod);
-            if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons < sizeof(msg))
+            if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons < sizeof(msg)) {
+                /* Work around oxenstored bug */
+                notify_remote_via_evtchn(start_info.store_evtchn); break;
+            }
             rmb();
             memcpy_from_ring(xenstore_buf->rsp,
                     &msg,

xenbus/xenbus.c +0 -0
@@ -217,8 +220,11 @@ static void xenbus_thread_func(void *ign)
                      xenstore_buf->rsp_prod - xenstore_buf->rsp_cons,
                      msg.req_id);

             if (xenstore_buf->rsp_prod - xenstore_buf->rsp_cons < -                    sizeof(msg) + msg.len)
+                    sizeof(msg) + msg.len) {
+                /* Work around oxenstored bug */
+                notify_remote_via_evtchn(start_info.store_evtchn);

Quoted 9 lines
Quoted 8 lines

                 break;
+            }

             DEBUG("Message is good.\n");

Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#8 lore raw

Re: [PATCH MINI-OS v3 2/2] xenbus: workaround oxenstored short-write

Quoted 14 lines · Ian Campbell
Quoted 13 lines · Samuel Thibault
Quoted 11 lines · Wei Liu, le Tue 27 Oct 2015 15:43:29 +0000, a écrit :

Oxenstored has a behaviour that it only writes a contiguous piece of data. When it writes across ring boundary it will return a short-write while there is still room. That leads to mini-os stalling when it sees there is not enough data in the ring.

Given that oxenstored is the default xenstored implementation we think it would be useful to workaround this for the benefit of running mini- os
(and unikernel based on it) on any Xen installation.

Quoted 8 lines
Quoted 1 line

As discussed in the previous thread, this is rather a workaround.

Given that I'm in the process of applying "tools/ocaml/xb: Correct calculations of data/space the ring" which I think is the real fix here am unsure if we still want to take this workaround.

Any thoughts?

We should apply it for master but not 4.6 branch. Because other people will grab mini-os and run it on older version of oxenstored.

Wei.