Re: [Qemu-devel] [PATCH 1/4] ptr_ring: port ptr_ring from linux kernel to QEMU

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

 



On Tue, Oct 16, 2018 at 19:10:03 +0800, guangrong.xiao@xxxxxxxxx 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.



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux