[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/2] iohandler: Add Linux implementation of ioha
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 2/2] iohandler: Add Linux implementation of iohandler GSource |
Date: |
Thu, 25 Sep 2014 21:45:40 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 |
Il 25/09/2014 19:21, Fam Zheng ha scritto:
> + while (true) {
> + r = epoll_pwait(s->epollfd.fd, events, MAX_EVENTS, 0, &origmask);
You can save a syscall by doing this just once. You would just get a
readable epoll file descriptor on the next main loop iteration. Also,
origmask is an input parameter, so you need to use epoll_wait.
Also, as an extra optimization perhaps you can make a second list with
iohandlers that were modified or have a read_poll handler, and only call
iohandler_get_events on that one.
Perhaps this together lowers the cost of epoll enough to more easily
reach the break-even point.
Though I wonder if it would be acceptable to make ioeventfd off by
default for virtio-serial...
Thanks,
Paolo
> + if (r < 0) {
> + break;
> + } else if (r == 0) {
> + break;
> + } else {
> + for (i = 0; i < r; i++) {
> + iohandler_dispatch_event(s, &events[i]);
> + }
> + if (r < MAX_EVENTS) {
> + break;
> + }
> + }
> + }
> +