[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: |
Emilio G. Cota |
Subject: |
Re: [Qemu-devel] [PATCH 1/4] ptr_ring: port ptr_ring from linux kernel to QEMU |
Date: |
Tue, 16 Oct 2018 12:40:19 -0400 |
User-agent: |
Mutt/1.9.4 (2018-02-28) |
On Tue, Oct 16, 2018 at 19:10:03 +0800, address@hidden wrote:
(snip)
> diff --git a/include/qemu/ptr_ring.h b/include/qemu/ptr_ring.h
> new file mode 100644
> index 0000000000..d8266d45f6
> --- /dev/null
> +++ b/include/qemu/ptr_ring.h
> @@ -0,0 +1,235 @@
(snip)
> +#define SMP_CACHE_BYTES 64
> +#define ____cacheline_aligned_in_smp \
> + __attribute__((__aligned__(SMP_CACHE_BYTES)))
You could use QEMU_ALIGNED() here.
> +
> +#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?
Furthermore, READ_ONCE in the kernel implies smp_read_barrier_depends,
whereas here you're not bringing that in. That means that your
barrier pairing, e.g.
> + /* Pairs with READ_ONCE in ptr_ring_consume. */
> + smp_wmb();
is incorrect for Alpha.
Thanks,
E.