This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


[Xen-devel] [Patch] Remove timeout in blktap's main tapdisk select loop

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [Patch] Remove timeout in blktap's main tapdisk select loop
From: "Stephen C. Tweedie" <sct@xxxxxxxxxx>
Date: Thu, 28 Sep 2006 23:25:52 +0100
Cc: Julian Chesterfield <jac90@xxxxxxxxx>, Steven Rostedt <rostedt@xxxxxxxxxxx>, Andrew Warfield <andrew.warfield@xxxxxxxxxxxx>
Delivery-date: Thu, 28 Sep 2006 15:50:30 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
tapdisk was using a 1msec select() timeout in its main event loop.  On
timeout, the loop does nothing except repeat, so the timeout achieves
nothing; worse, on a machine with HZ set to less than 1000, a msec
timeout returns immediately, sending tapdisk into a 100%-CPU-
utilisation loop.

Simply remove the timeout entirely; everything still works fine, and
much more efficiently when idle.

Signed-off-by: Stephen Tweedie <sct@xxxxxxxxxx>

diff -r aeba3dd98fbb -r 49d429529228 tools/blktap/drivers/tapdisk.c
--- a/tools/blktap/drivers/tapdisk.c    Thu Sep 28 18:05:08 2006 +0100
+++ b/tools/blktap/drivers/tapdisk.c    Thu Sep 28 23:24:43 2006 +0100
@@ -271,7 +271,6 @@ static int read_msg(char *buf)
        int length, len, msglen, tap_fd, *io_fd;
        char *ptr, *path;
        image_t *img;
-       struct timeval timeout;
        msg_hdr_t *msg;
        msg_newdev_t *msg_dev;
        msg_pid_t *msg_pid;
@@ -579,8 +578,7 @@ int main(int argc, char *argv[])
        int len, msglen, ret;
        char *p, *buf;
-       fd_set readfds, writefds;
-       struct timeval timeout;
+       fd_set readfds, writefds;       
        fd_list_entry_t *ptr;
        struct tap_disk *drv;
        struct td_state *s;
@@ -622,12 +620,9 @@ int main(int argc, char *argv[])
                /*Set all tap fds*/
-               timeout.tv_sec = 0; 
-               timeout.tv_usec = 1000; 
                /*Wait for incoming messages*/
                ret = select(maxfds + 1, &readfds, (fd_set *) 0, 
-                            (fd_set *) 0, &timeout);
+                            (fd_set *) 0, NULL);
                if (ret > 0) 

Xen-devel mailing list

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [Patch] Remove timeout in blktap's main tapdisk select loop, Stephen C. Tweedie <=