qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Qemu-block] [PATCH 1/3] aio-posix: fix concurrent acce


From: Fam Zheng
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 1/3] aio-posix: fix concurrent access to poll_disable_cnt
Date: Thu, 13 Sep 2018 16:34:05 +0800
User-agent: Mutt/1.10.1 (2018-07-13)

On Thu, 09/13 10:29, Paolo Bonzini wrote:
> On 13/09/2018 08:56, Fam Zheng wrote:
> >> +    /* No need to order poll_disable_cnt writes against other updates;
> >> +     * the counter is only used to avoid wasting time and latency on
> >> +     * iterated polling when the system call will be ultimately necessary.
> >> +     * Changing handlers is a rare event, and a little wasted polling 
> >> until
> >> +     * the aio_notify below is not an issue.
> >> +     */
> >> +    atomic_set(&ctx->poll_disable_cnt,
> >> +               atomic_read(&ctx->poll_disable_cnt) + poll_disable_change);
> >
> > Why not atomic_add?
> 
> This is not lockless, it's protected by list_lock, so there's no race
> condition involved.  I'm just mimicking what is done for other similar
> cases, for example involving seqlocks.

Yeah, no doubt about the correctness. Just curious about the preference since
atomic_add is less typing and one less atomic_* op.

Fam

> 
> The alternative would be to add a full set of
> atomic_{add,sub,...}_relaxed atomics.
> 
> Paolo



reply via email to

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