[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/6] test-rcu-list: avoid torn accesses to n_rec
Re: [Qemu-devel] [PATCH 2/6] test-rcu-list: avoid torn accesses to n_reclaims and n_nodes_removed
Tue, 11 Sep 2018 13:25:29 +0200
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
On 04/09/2018 22:56, Murilo Opsfelder Araujo wrote:
>>> +static inline void count_add(Count *c, long long val)
>>> +#ifdef CONFIG_ATOMIC64
>>> + atomic_set__nocheck(&c->val, c->val + val);
>>> + seqlock_write_begin(&c->sequence);
>>> + c->val += val;
>>> + seqlock_write_end(&c->sequence);
>>> +static inline void count_inc(Count *c)
>>> + count_add(c, 1);
>> Are these `#ifdef CONFIG_ATOMIC64` required?
>> The bodies of
>> in include/qemu/seqlock.h make me think that they already use atomic
>> What am I missing?
> atomic_read/set(*foo), as defined in qemu/atomic.h, are as wide as
> foo. The sequence number in a seqlock is an "unsigned", so those
> atomics won't be larger than 32 bits.
> The counts we're dealing with here are 64-bits, so with
> #ifdef CONFIG_ATOMIC64 we ensure that the host can actually
> perform those 64-bit atomic accesses.
Like for patch 1, I'm not sure I like introducing the data races...
While reads inside the seqlock do not need atomics, I think the write
should be atomic in both cases.
[Qemu-devel] [PATCH 2/6] test-rcu-list: avoid torn accesses to n_reclaims and n_nodes_removed, Emilio G. Cota, 2018/09/03
[Qemu-devel] [PATCH 1/6] qsp: drop atomics when using the seqlock, Emilio G. Cota, 2018/09/03
Re: [Qemu-devel] [PATCH 0/6] i386 + x86_64 mttcg, Paolo Bonzini, 2018/09/11
- Re: [Qemu-devel] [PATCH 5/6] target/i386/translate: use thread-local storage in !user-mode, (continued)