Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-07-03 Thread Paul E. McKenney
On Fri, Jun 29, 2018 at 11:55:08AM +0800, Xiao Guangrong wrote: > > > On 06/28/2018 07:55 PM, Wei Wang wrote: > >On 06/28/2018 06:02 PM, Xiao Guangrong wrote: > >> > >>CC: Paul, Peter Zijlstra, Stefani, Lai who are all good at memory barrier. > >> > >> > >>On 06/20/2018 12:52 PM, Peter Xu wrote:

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-07-03 Thread Xiao Guangrong
On 06/29/2018 09:08 PM, Michael S. Tsirkin wrote: On Fri, Jun 29, 2018 at 03:30:44PM +0800, Xiao Guangrong wrote: Hi Michael, On 06/20/2018 08:38 PM, Michael S. Tsirkin wrote: On Mon, Jun 04, 2018 at 05:55:17PM +0800, guangrong.x...@gmail.com wrote: From: Xiao Guangrong (1)

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-29 Thread Michael S. Tsirkin
On Fri, Jun 29, 2018 at 03:30:44PM +0800, Xiao Guangrong wrote: > > Hi Michael, > > On 06/20/2018 08:38 PM, Michael S. Tsirkin wrote: > > On Mon, Jun 04, 2018 at 05:55:17PM +0800, guangrong.x...@gmail.com wrote: > > > From: Xiao Guangrong > > > > > > > > > > (1) > > >

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-29 Thread Xiao Guangrong
On 06/29/2018 02:15 PM, Jason Wang wrote: On 2018年06月29日 11:59, Xiao Guangrong wrote: On 06/28/2018 09:36 PM, Jason Wang wrote: On 2018年06月04日 17:55, guangrong.x...@gmail.com wrote: From: Xiao Guangrong It's the simple lockless ring buffer implement which supports both single

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-29 Thread Xiao Guangrong
On 06/29/2018 12:23 PM, Michael S. Tsirkin wrote: On Thu, Jun 28, 2018 at 09:36:00PM +0800, Jason Wang wrote: On 2018年06月04日 17:55, guangrong.x...@gmail.com wrote: From: Xiao Guangrong Memory barrier is omitted here, please refer to the comment in the code.

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-29 Thread Xiao Guangrong
Hi Michael, On 06/20/2018 08:38 PM, Michael S. Tsirkin wrote: On Mon, Jun 04, 2018 at 05:55:17PM +0800, guangrong.x...@gmail.com wrote: From: Xiao Guangrong (1) https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/kfifo.h (2)

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-29 Thread Jason Wang
On 2018年06月29日 11:59, Xiao Guangrong wrote: On 06/28/2018 09:36 PM, Jason Wang wrote: On 2018年06月04日 17:55, guangrong.x...@gmail.com wrote: From: Xiao Guangrong It's the simple lockless ring buffer implement which supports both single producer vs. single consumer and multiple producers

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-28 Thread Michael S. Tsirkin
On Thu, Jun 28, 2018 at 09:36:00PM +0800, Jason Wang wrote: > > > On 2018年06月04日 17:55, guangrong.x...@gmail.com wrote: > > From: Xiao Guangrong > > > > It's the simple lockless ring buffer implement which supports both > > single producer vs. single consumer and multiple producers vs. > >

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-28 Thread Xiao Guangrong
On 06/28/2018 09:36 PM, Jason Wang wrote: On 2018年06月04日 17:55, guangrong.x...@gmail.com wrote: From: Xiao Guangrong It's the simple lockless ring buffer implement which supports both single producer vs. single consumer and multiple producers vs. single consumer. Finally, it fetches

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-28 Thread Xiao Guangrong
On 06/28/2018 07:55 PM, Wei Wang wrote: On 06/28/2018 06:02 PM, Xiao Guangrong wrote: CC: Paul, Peter Zijlstra, Stefani, Lai who are all good at memory barrier. On 06/20/2018 12:52 PM, Peter Xu wrote: On Mon, Jun 04, 2018 at 05:55:17PM +0800, guangrong.x...@gmail.com wrote: From: Xiao

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-28 Thread Xiao Guangrong
On 06/20/2018 01:55 PM, Peter Xu wrote: On Mon, Jun 04, 2018 at 05:55:17PM +0800, guangrong.x...@gmail.com wrote: [...] (Some more comments/questions for the MP implementation...) +static inline int ring_mp_put(Ring *ring, void *data) +{ +unsigned int index, in, in_next, out; + +

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-28 Thread Jason Wang
On 2018年06月04日 17:55, guangrong.x...@gmail.com wrote: From: Xiao Guangrong It's the simple lockless ring buffer implement which supports both single producer vs. single consumer and multiple producers vs. single consumer. Many lessons were learned from Linux Kernel's kfifo (1) and DPDK's

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-28 Thread Wei Wang
On 06/28/2018 06:02 PM, Xiao Guangrong wrote: CC: Paul, Peter Zijlstra, Stefani, Lai who are all good at memory barrier. On 06/20/2018 12:52 PM, Peter Xu wrote: On Mon, Jun 04, 2018 at 05:55:17PM +0800, guangrong.x...@gmail.com wrote: From: Xiao Guangrong It's the simple lockless ring

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-28 Thread Xiao Guangrong
CC: Paul, Peter Zijlstra, Stefani, Lai who are all good at memory barrier. On 06/20/2018 12:52 PM, Peter Xu wrote: On Mon, Jun 04, 2018 at 05:55:17PM +0800, guangrong.x...@gmail.com wrote: From: Xiao Guangrong It's the simple lockless ring buffer implement which supports both single

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-20 Thread Michael S. Tsirkin
On Mon, Jun 04, 2018 at 05:55:17PM +0800, guangrong.x...@gmail.com wrote: > From: Xiao Guangrong > > It's the simple lockless ring buffer implement which supports both > single producer vs. single consumer and multiple producers vs. > single consumer. > > Many lessons were learned from Linux

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-19 Thread Peter Xu
On Mon, Jun 04, 2018 at 05:55:17PM +0800, guangrong.x...@gmail.com wrote: [...] (Some more comments/questions for the MP implementation...) > +static inline int ring_mp_put(Ring *ring, void *data) > +{ > +unsigned int index, in, in_next, out; > + > +do { > +in =

Re: [Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-19 Thread Peter Xu
On Mon, Jun 04, 2018 at 05:55:17PM +0800, guangrong.x...@gmail.com wrote: > From: Xiao Guangrong > > It's the simple lockless ring buffer implement which supports both > single producer vs. single consumer and multiple producers vs. > single consumer. > > Many lessons were learned from Linux

[Qemu-devel] [PATCH 09/12] ring: introduce lockless ring buffer

2018-06-04 Thread guangrong . xiao
From: Xiao Guangrong It's the simple lockless ring buffer implement which supports both single producer vs. single consumer and multiple producers vs. single consumer. Many lessons were learned from Linux Kernel's kfifo (1) and DPDK's rte_ring (2) before i wrote this implement. It corrects some