On August 19, 2016 2:50:30 AM PDT, Aleksander Alekseev 
<a.aleks...@postgrespro.ru> wrote:
>Heikki, Peter, thanks a lot for code review!
>> What's going on here? Surely pg_atomic_init_u64() should initialize
>> the value?
>It's because of how pg_atomic_exchange_u64_impl is implemented:
>while (true)
>    old = ptr->value; /* <-- reading of uninitialized value! */
>    if (pg_atomic_compare_exchange_u64_impl(ptr, &old, xchg_))
>        break;
>Currently pg_atomic_init_u64 works like this:
>`- pg_atomic_init_u64_impl
>   `- pg_atomic_write_u64_impl
>      `- pg_atomic_exchange_u64_impl
>I suspect there is actually no need to make an atomic exchange during
>initialization of an atomic variable. Regular `mov` should be enough
>(IIRC there is no need to do `lock mov` since `mov` is already atomic).
>Anyway I don't feel brave enough right now to mess with atomic
>operations since it involves all sort of portability issues. So I
>removed this change for now.

There's platforms with atomic 8 byte compare exchange, without atomic 8 byte 
regular stores.
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to