]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: event: poller pipe optimisation
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 10 Jan 2020 13:11:46 +0000 (13:11 +0000)
committerIan Jackson <ian.jackson@eu.citrix.com>
Mon, 27 Jan 2020 16:03:17 +0000 (16:03 +0000)
Track in userland whether the poller pipe is nonempty.  This saves us
writing many many bytes to the pipe if nothing ever reads them.

This is going to be relevant in a moment, where we are going to create
a situation where this will happen quite a lot.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Tested-by: George Dunlap <george.dunlap@citrix.com>
tools/libxl/libxl_event.c
tools/libxl/libxl_internal.h

index b50d4e507432445e06ec791aacad46a3f69d2d3b..3e76fa5af5c7ce4a8152f5dafb9992a65f48a1cd 100644 (file)
@@ -1417,6 +1417,7 @@ static void afterpoll_internal(libxl__egc *egc, libxl__poller *poller,
     }
 
     if (afterpoll_check_fd(poller,fds,nfds, poller->wakeup_pipe[0],POLLIN)) {
+        poller->pipe_nonempty = 0;
         int e = libxl__self_pipe_eatall(poller->wakeup_pipe[0]);
         if (e) LIBXL__EVENT_DISASTER(gc, "read wakeup", e, 0);
     }
@@ -1809,6 +1810,8 @@ void libxl__poller_put(libxl_ctx *ctx, libxl__poller *p)
 
 void libxl__poller_wakeup(libxl__gc *gc, libxl__poller *p)
 {
+    if (p->pipe_nonempty) return;
+    p->pipe_nonempty = 1;
     int e = libxl__self_pipe_wakeup(p->wakeup_pipe[1]);
     if (e) LIBXL__EVENT_DISASTER(gc, "cannot poke watch pipe", e, 0);
 }
index f2ff5e6c2d83a82f1dc1eed53574b274d677e821..2555aa457547228edb4e40a527372cb5a0913077 100644 (file)
@@ -625,6 +625,7 @@ struct libxl__poller {
     int (*fd_rindices)[3]; /* see libxl_event.c:beforepoll_internal */
 
     int wakeup_pipe[2]; /* 0 means no fd allocated */
+    bool pipe_nonempty;
 
     /*
      * We also use the poller to record whether any fds have been