[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/4] ptr_ring: port ptr_ring from linux kernel t
From: |
Xiao Guangrong |
Subject: |
Re: [Qemu-devel] [PATCH 1/4] ptr_ring: port ptr_ring from linux kernel to QEMU |
Date: |
Thu, 18 Oct 2018 14:52:17 +0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
On 10/17/2018 04:14 PM, Paolo Bonzini wrote:
On 16/10/2018 18:40, Emilio G. Cota wrote:
+#define SMP_CACHE_BYTES 64
+#define ____cacheline_aligned_in_smp \
+ __attribute__((__aligned__(SMP_CACHE_BYTES)))
You could use QEMU_ALIGNED() here.
Yes, you are right.
+
+#define WRITE_ONCE(ptr, val) \
+ (*((volatile typeof(ptr) *)(&(ptr))) = (val))
+#define READ_ONCE(ptr) (*((volatile typeof(ptr) *)(&(ptr))))
Why not atomic_read/set, like in the rest of the QEMU code base?
Or even atomic_rcu_read/atomic_rcu_set, which includes the necessary
barriers.
Okay, will fix it, thank you and Emilio for pointing the
issue out.
Also, please do not use __ identifiers in QEMU code.
____cacheline_aligned_in_smp can become just QEMU_ALIGNED(SMP_CACHE_BYTES).
Sure, will keep that in my mind. :)