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