qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 1/1] linux-aio: prevent submitting more than


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v3 1/1] linux-aio: prevent submitting more than MAX_EVENTS
Date: Thu, 14 Jul 2016 13:19:23 +0100
User-agent: Mutt/1.6.1 (2016-04-27)

On Wed, Jul 13, 2016 at 03:03:24PM +0200, Roman Pen wrote:
> 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 <address@hidden>
> Reviewed-by: Fam Zheng <address@hidden>
> Reviewed-by: Paolo Bonzini <address@hidden>
> Cc: Stefan Hajnoczi <address@hidden>
> Cc: address@hidden
> ---
> v3:
>   o comment tweaks.
> 
> v2:
>   o comment tweaks.
>   o fix QEMU coding style.
> 
>  block/linux-aio.c | 26 ++++++++++++++++----------
>  1 file changed, 16 insertions(+), 10 deletions(-)

Reviewed-by: Stefan Hajnoczi <address@hidden>

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]