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; > + } > + } > + } > +