Re: Question on ptr_ring linux header

2019-02-28 Thread fei phung
Hi Michael , I have solved all the data race issue , it seems. The data race culprit is the ring index which I have removed in the latest datarace-free code. The diff can be found at https://www.diffchecker.com/w0Pxp2mF I plan to study the internal implementation of ptr_ring c coding in the comi

Re: Question on ptr_ring linux header

2019-02-14 Thread fei phung
Hi Michael, > If I had to guess I'd say the way you play with indices is probably racy > so you are producing an invalid index. You are probably right. I am suspecting item_recv_push_index and item_send_push_index in https://gist.github.com/promach/7716ee8addcaa33fda140d74d1ad94d6#file-riffa_dri

Re: Question on ptr_ring linux header

2019-02-01 Thread Michael S. Tsirkin
On Fri, Feb 01, 2019 at 04:12:46PM +0800, fei phung wrote: > > I am not sure what does assignment of pointers mean in this context. > > ptr_ring is designed for a single producer and a single consumer. For > > why it works see explanation about data dependencies in > > Documentation/memory-barrier

Re: Question on ptr_ring linux header

2019-02-01 Thread fei phung
> I am not sure what does assignment of pointers mean in this context. > ptr_ring is designed for a single producer and a single consumer. For > why it works see explanation about data dependencies in > Documentation/memory-barriers.txt. You will have to be more specific > about the data race tha

Re: Question on ptr_ring linux header

2019-01-31 Thread Michael S. Tsirkin
On Thu, Jan 31, 2019 at 01:16:31PM +0800, fei phung wrote: > Hi, > > /* > * Filename: circ_ring.c > * Version: 1.0 > * Description: A circular buffer using API from > * https://github.com/torvalds/linux/blob/master/include/linux/ptr_ring.h > */ > > ptr_ring's void** queue is just giving data

Re: Question on ptr_ring linux header

2019-01-30 Thread fei phung
Hi, /* * Filename: circ_ring.c * Version: 1.0 * Description: A circular buffer using API from * https://github.com/torvalds/linux/blob/master/include/linux/ptr_ring.h */ ptr_ring's void** queue is just giving data race problem, running consume() together with [assignment of pointers+produce(

Re: Question on ptr_ring linux header

2019-01-16 Thread fei phung
Hi, I am having data race from threadsanitizer report. Could you see if there is still data race in the following code using ptr_ring API ? /* * Filename: circ_ring.c * Version: 1.0 * Description: A circular buffer using API from * https://github.com/torvalds/linux/blob/master/include/linu

Re: Question on ptr_ring linux header

2019-01-16 Thread Michael S. Tsirkin
On Wed, Jan 16, 2019 at 06:48:41AM +, Cheng Fei Phung wrote: > Hi, > > > https://gist.github.com/promach/65e9331d55a43a2815239430a28e29c6#file-circ_ring-c-L62 > > racy if there are multiple consumers. > > just call ptr_ring_consume_any. > > If I modify pop_circ_queue() below to directly use p

Re: Question on ptr_ring linux header

2019-01-15 Thread fei phung
Hi, > https://gist.github.com/promach/65e9331d55a43a2815239430a28e29c6#file-circ_ring-c-L62 > racy if there are multiple consumers. > just call ptr_ring_consume_any. If I modify pop_circ_queue() below to directly use ptr_ring_consume_any() without ptr_ring_empty_any() , I am afraid I am running i

Re: Question on ptr_ring linux header

2019-01-15 Thread Michael S. Tsirkin
On Wed, Jan 16, 2019 at 01:10:31AM +0800, fei phung wrote: > Hi, > > inline int pop_circ_queue(struct ptr_ring * buffer, struct item * item_pop) > { > if (!ptr_ring_empty_any(buffer)) // if (not empty) > { > DEBUG_MSG(KERN_INFO "Before pop, head = %u , tail = > %u\n

Re: Question on ptr_ring linux header

2019-01-15 Thread fei phung
Hi, inline int pop_circ_queue(struct ptr_ring * buffer, struct item * item_pop) { if (!ptr_ring_empty_any(buffer)) // if (not empty) { DEBUG_MSG(KERN_INFO "Before pop, head = %u , tail = %u\n", buffer->consumer_head, buffer->consumer_tail); /* extra

Re: Question on ptr_ring linux header

2019-01-15 Thread Michael S. Tsirkin
On Tue, Jan 15, 2019 at 12:33:28PM +0800, fei phung wrote: > Hi netdev mailing list and Michael, > > I am having problem getting proper ptr_ring operation where one > ptr_ring entry (val1=2 for item_recv_pop) is missing from the void ** > queue > > Did I initialize the ring pointers (ptr_ring_ini

Question on ptr_ring linux header

2019-01-14 Thread fei phung
Hi netdev mailing list and Michael, I am having problem getting proper ptr_ring operation where one ptr_ring entry (val1=2 for item_recv_pop) is missing from the void ** queue Did I initialize the ring pointers (ptr_ring_init()) correctly ? See the following for more context: https://i.imgur.co