direct-io.hg
changeset 11663:16759bdbd6c2
[BLKTAP] Remove unnecessary timeout from tapdisk select() call.
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@redhat.com>
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@redhat.com>
author | kfraser@localhost.localdomain |
---|---|
date | Fri Sep 29 11:16:52 2006 +0100 (2006-09-29) |
parents | 80388aea02a1 |
children | 0c29e0d1c67b |
files | tools/blktap/drivers/tapdisk.c |
line diff
1.1 --- a/tools/blktap/drivers/tapdisk.c Fri Sep 29 11:13:01 2006 +0100 1.2 +++ b/tools/blktap/drivers/tapdisk.c Fri Sep 29 11:16:52 2006 +0100 1.3 @@ -271,7 +271,6 @@ static int read_msg(char *buf) 1.4 int length, len, msglen, tap_fd, *io_fd; 1.5 char *ptr, *path; 1.6 image_t *img; 1.7 - struct timeval timeout; 1.8 msg_hdr_t *msg; 1.9 msg_newdev_t *msg_dev; 1.10 msg_pid_t *msg_pid; 1.11 @@ -579,8 +578,7 @@ int main(int argc, char *argv[]) 1.12 { 1.13 int len, msglen, ret; 1.14 char *p, *buf; 1.15 - fd_set readfds, writefds; 1.16 - struct timeval timeout; 1.17 + fd_set readfds, writefds; 1.18 fd_list_entry_t *ptr; 1.19 struct tap_disk *drv; 1.20 struct td_state *s; 1.21 @@ -622,12 +620,9 @@ int main(int argc, char *argv[]) 1.22 /*Set all tap fds*/ 1.23 LOCAL_FD_SET(&readfds); 1.24 1.25 - timeout.tv_sec = 0; 1.26 - timeout.tv_usec = 1000; 1.27 - 1.28 /*Wait for incoming messages*/ 1.29 ret = select(maxfds + 1, &readfds, (fd_set *) 0, 1.30 - (fd_set *) 0, &timeout); 1.31 + (fd_set *) 0, NULL); 1.32 1.33 if (ret > 0) 1.34 {