diff options
author | Roman Pen <roman.penyaev@profitbricks.com> | 2016-07-13 15:03:24 +0200 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2016-07-18 15:10:52 +0100 |
commit | 5e1b34a3fa0a0fbf46628aab10cc49f6f855520e (patch) | |
tree | 27920ed6b6541922199e088e659b3eca3d992aab /aio-posix.c | |
parent | 6977d901c43f6c2fc811c4ca9bf45bf0af6bb689 (diff) | |
download | qemu-5e1b34a3fa0a0fbf46628aab10cc49f6f855520e.zip qemu-5e1b34a3fa0a0fbf46628aab10cc49f6f855520e.tar.gz qemu-5e1b34a3fa0a0fbf46628aab10cc49f6f855520e.tar.bz2 |
linux-aio: prevent submitting more than MAX_EVENTS
Invoking io_setup(MAX_EVENTS) we ask kernel to create ring buffer for us
with specified number of events. But kernel ring buffer allocation logic
is a bit tricky (ring buffer is page size aligned + some percpu allocation
are required) so eventually more than requested events number is allocated.
From a userspace side we have to follow the convention and should not try
to io_submit() more or logic, which consumes completed events, should be
changed accordingly. The pitfall is in the following sequence:
MAX_EVENTS = 128
io_setup(MAX_EVENTS)
io_submit(MAX_EVENTS)
io_submit(MAX_EVENTS)
/* now 256 events are in-flight */
io_getevents(MAX_EVENTS) = 128
/* we can handle only 128 events at once, to be sure
* that nothing is pended the io_getevents(MAX_EVENTS)
* call must be invoked once more or hang will happen. */
To prevent the hang or reiteration of io_getevents() call this patch
restricts the number of in-flights, which is now limited to MAX_EVENTS.
Signed-off-by: Roman Pen <roman.penyaev@profitbricks.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1468415004-31755-1-git-send-email-roman.penyaev@profitbricks.com
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'aio-posix.c')
0 files changed, 0 insertions, 0 deletions