netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: fei phung <feiphung27@gmail.com>
Cc: feiphung@hotmail.com, netdev@vger.kernel.org
Subject: Re: Question on ptr_ring linux header
Date: Thu, 31 Jan 2019 09:39:34 -0500	[thread overview]
Message-ID: <20190131093342-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAF8QhUhSWauyg2a1Y_MjP0gk-W9oydbpuBvtZyGZEbfmm8+mQA@mail.gmail.com>

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 race problem, running
> consume() together with [assignment of pointers+produce()] will
> definitely give rise to data race
> 
> mutex or lock cannot help in this case. Please correct me if wrong
> 
> Regards,
> 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 that you see if you expect more specific answers.

Thanks,

-- 
MST

  reply	other threads:[~2019-01-31 14:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17  3:51 Question on ptr_ring linux header fei phung
2019-01-31  5:16 ` fei phung
2019-01-31 14:39   ` Michael S. Tsirkin [this message]
2019-02-01  8:12     ` fei phung
2019-02-01 15:36       ` Michael S. Tsirkin
2019-02-15  3:03         ` fei phung
2019-03-01  3:20           ` fei phung
  -- strict thread matches above, loose matches on Subject: below --
2019-01-16  7:00 fei phung
2019-01-15 17:10 fei phung
2019-01-15 18:13 ` Michael S. Tsirkin
     [not found]   ` <SG2PR06MB3176FA4C12888C84990F109BC1820@SG2PR06MB3176.apcprd06.prod.outlook.com>
2019-01-16 14:09     ` Michael S. Tsirkin
2019-01-15  4:33 fei phung
2019-01-15 12:48 ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190131093342-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=feiphung27@gmail.com \
    --cc=feiphung@hotmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).