aio: self-tune polling time
commit82a41186941c419afde977f477f19c545b40c1c5
authorStefan Hajnoczi <stefanha@redhat.com>
Thu, 1 Dec 2016 19:26:51 +0000 (1 19:26 +0000)
committerStefan Hajnoczi <stefanha@redhat.com>
Tue, 3 Jan 2017 16:38:50 +0000 (3 16:38 +0000)
tree32d517c6b4b6454814fd54af17bc0b5f7f0ed82c
parenta7c8215e3bbcdd3b5dbaabfcecf236d4a9880558
aio: self-tune polling time

This patch is based on the algorithm for the kvm.ko halt_poll_ns
parameter in Linux.  The initial polling time is zero.

If the event loop is woken up within the maximum polling time it means
polling could be effective, so grow polling time.

If the event loop is woken up beyond the maximum polling time it means
polling is not effective, so shrink polling time.

If the event loop makes progress within the current polling time then
the sweet spot has been reached.

This algorithm adjusts the polling time so it can adapt to variations in
workloads.  The goal is to reach the sweet spot while also recognizing
when polling would hurt more than help.

Two new trace events, poll_grow and poll_shrink, are added for observing
polling time adjustment.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 20161201192652.9509-13-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
aio-posix.c
aio-win32.c
async.c
include/block/aio.h
iothread.c
trace-events