From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NrxPj-0005cz-8o for qemu-devel@nongnu.org; Wed, 17 Mar 2010 13:52:15 -0400 Received: from [199.232.76.173] (port=45260 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NrxPi-0005cM-JZ for qemu-devel@nongnu.org; Wed, 17 Mar 2010 13:52:14 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NrxPg-0007Y3-8t for qemu-devel@nongnu.org; Wed, 17 Mar 2010 13:52:14 -0400 Received: from mail-pv0-f173.google.com ([74.125.83.173]:61638) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NrxPf-0007Xs-Ua for qemu-devel@nongnu.org; Wed, 17 Mar 2010 13:52:12 -0400 Received: by pvf33 with SMTP id 33so654754pvf.4 for ; Wed, 17 Mar 2010 10:52:10 -0700 (PDT) Message-ID: <4BA116C6.7010405@codemonkey.ws> Date: Wed, 17 Mar 2010 12:52:06 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 08/16] tap: insert tap_can_send() into tap_send() References: <00a2a114337c94c23068737bbe99cb044c84bbe6.1268326362.git.quintela@redhat.com> In-Reply-To: <00a2a114337c94c23068737bbe99cb044c84bbe6.1268326362.git.quintela@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org On 03/11/2010 10:55 AM, Juan Quintela wrote: > This way we can remove the poll test > > Signed-off-by: Juan Quintela > Won't this cause unnecessary wake ups? Right now, we use the can_read() poll function to determine whether to add an fd to a fdset. With this patch, we always add the fd to the fdset and then we just fail the read. To eliminate the poll function, we need to change the handlers from polling, to noticing when they no longer can be read, and remove the read callback entirely. Regards, Anthony Liguori > --- > net/tap.c | 27 +++++++++------------------ > 1 files changed, 9 insertions(+), 18 deletions(-) > > diff --git a/net/tap.c b/net/tap.c > index 7a7320c..3ab65a3 100644 > --- a/net/tap.c > +++ b/net/tap.c > @@ -61,17 +61,15 @@ typedef struct TAPState { > > static int launch_script(const char *setup_script, const char *ifname, int fd); > > -static int tap_can_send(void *opaque); > static void tap_send(void *opaque); > static void tap_writable(void *opaque); > > static void tap_update_fd_handler(TAPState *s) > { > - qemu_set_fd_handler2(s->fd, > - s->read_poll ? tap_can_send : NULL, > - s->read_poll ? tap_send : NULL, > - s->write_poll ? tap_writable : NULL, > - s); > + qemu_set_fd_handler(s->fd, > + s->read_poll ? tap_send : NULL, > + s->write_poll ? tap_writable : NULL, > + s); > } > > static void tap_read_poll(TAPState *s, int enable) > @@ -165,13 +163,6 @@ static ssize_t tap_receive(VLANClientState *nc, const uint8_t *buf, size_t size) > return tap_write_packet(s, iov, 1); > } > > -static int tap_can_send(void *opaque) > -{ > - TAPState *s = opaque; > - > - return qemu_can_send_packet(&s->nc); > -} > - > #ifndef __sun__ > ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen) > { > @@ -188,12 +179,10 @@ static void tap_send_completed(VLANClientState *nc, ssize_t len) > static void tap_send(void *opaque) > { > TAPState *s = opaque; > - int size; > > - do { > + while (qemu_can_send_packet(&s->nc)> 0) { > uint8_t *buf = s->buf; > - > - size = tap_read_packet(s->fd, s->buf, sizeof(s->buf)); > + int size = tap_read_packet(s->fd, s->buf, sizeof(s->buf)); > if (size<= 0) { > break; > } > @@ -206,8 +195,10 @@ static void tap_send(void *opaque) > size = qemu_send_packet_async(&s->nc, buf, size, tap_send_completed); > if (size == 0) { > tap_read_poll(s, 0); > + } else if (size< 0) { > + return; > } > - } while (size> 0&& qemu_can_send_packet(&s->nc)); > + } > } > > int tap_has_ufo(VLANClientState *nc) >