From: Anthony Liguori <anthony@codemonkey.ws>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 08/16] tap: insert tap_can_send() into tap_send()
Date: Wed, 17 Mar 2010 12:52:06 -0500 [thread overview]
Message-ID: <4BA116C6.7010405@codemonkey.ws> (raw)
In-Reply-To: <00a2a114337c94c23068737bbe99cb044c84bbe6.1268326362.git.quintela@redhat.com>
On 03/11/2010 10:55 AM, Juan Quintela wrote:
> This way we can remove the poll test
>
> Signed-off-by: Juan Quintela<quintela@redhat.com>
>
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)
>
next prev parent reply other threads:[~2010-03-17 17:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-11 16:55 [Qemu-devel] [PATCH 00/16] *** SUBJECT HERE *** Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 01/16] migration: Clear fd also in error cases Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 02/16] migration: unix migration should obey autostart are the other ones Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 03/16] Convert io handlers to QLIST Juan Quintela
2010-03-22 19:40 ` Anthony Liguori
2010-03-11 16:55 ` [Qemu-devel] [PATCH 04/16] remove useless cast Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 05/16] rename IOCanRWHandler to IOCanReadHandler Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 06/16] bt: remove bt_host_read_poll() Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 07/16] Handle deleted IOHandlers in a single buffer Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 08/16] tap: insert tap_can_send() into tap_send() Juan Quintela
2010-03-17 17:52 ` Anthony Liguori [this message]
2010-03-11 16:55 ` [Qemu-devel] [PATCH 09/16] qemu-char:stdio insert poll call into read one Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 10/16] qemu-char:tcp " Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 11/16] qemu-char:fd " Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 12/16] qemu-char:pty " Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 13/16] qemu-char:udp " Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 14/16] Remove qemu_set_fd_handler2() Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 15/16] Remove now unused fd_read_poll and all its only left user Juan Quintela
2010-03-11 16:55 ` [Qemu-devel] [PATCH 16/16] Add qemu_remove_fd_handler() Juan Quintela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BA116C6.7010405@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).