qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 3/3] AioContext: fix broken ctx->dispatching


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH v2 3/3] AioContext: fix broken ctx->dispatching optimization
Date: Fri, 17 Jul 2015 04:27:58 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1


On 17/07/2015 04:25, Fam Zheng wrote:
> What if aio_notify happens after the previous aio_dispatch() but before the
> next necessary atomic_add? The aio_notify would still skip the
> event_notifier_set(), and the next ppoll() will not return. For example:
> 
>   Thread A                             Thread B
> ------------------------------------------------------------------------
>   aio_poll(blocking=true)
>                                        aio_notify()
>                                          smp_mb()
>                                          if (ctx->notify_me) /* false! */
>     atomic_add(ctx->notify_me, 2)
>     ppoll()
>     atomic_sub(ctx->notify_me, 2)           event_notifier_set() /* not run */

It's not a problem because ppoll() has exited.  The next call to
aio_poll or aio_ctx_prepare will notice the bottom half, do a
non-blocking ppoll(), and then service the bottom half.

> 
> And if that's not a problem, why don't we need something like ACCESS_ONCE in
> aio_noitfy()?

Because there's already a smp_mb() which is stronger.

Paolo



reply via email to

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