On Tue, Nov 29, 2016 at 1:24 PM, Fam Zheng <f...@redhat.com> wrote: > On Tue, 11/29 12:17, Paolo Bonzini wrote: >> On 29/11/2016 11:32, Fam Zheng wrote: >> * it still needs a system call before polling is entered. Ideally, QEMU >> could run without any system call while in polling mode. >> >> Another possibility is to add a system call for single_task_running(). >> It should be simple enough that you can implement it in the vDSO and >> avoid a context switch. There are convenient hooking points in >> add_nr_running and sub_nr_running. > > That sounds good!
With this solution QEMU can either poll virtqueues or the host kernel can poll NIC and storage controller descriptor rings, but not both at the same time in one thread. This is one of the reasons why I think exploring polling in the kernel makes more sense. The disadvantage of the kernel approach is that you must make the ppoll(2)/epoll_wait(2) syscall even for polling, and you probably need to do eventfd reads afterwards so the minimum event loop iteration latency is higher than doing polling in userspace. Stefan