DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
Cc: "Pattan, Reshma" <reshma.pattan@intel.com>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx callback lists
Date: Wed, 15 Jun 2016 13:17:32 +0200	[thread overview]
Message-ID: <3682885.ZONGT1nz9t@xps13> (raw)
In-Reply-To: <2601191342CEEE43887BDE71AB97725836B7164D@irsmsx105.ger.corp.intel.com>

2016-06-15 09:54, Ananyev, Konstantin:
> 
> > -----Original Message-----
> > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > Sent: Wednesday, June 15, 2016 9:49 AM
> > To: Ananyev, Konstantin
> > Cc: Pattan, Reshma; dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx callback lists
> > 
> > 2016-06-15 08:37, Ananyev, Konstantin:
> > > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > > 2016-06-15 05:30, Pattan, Reshma:
> > > > > From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> > > > > > 2016-06-14 10:38, Reshma Pattan:
> > > > > > > Added spinlocks around add/remove logic of Rx and Tx callbacks to
> > > > > > > avoid corruption of callback lists in multithreaded context.
> > > > > > >
> > > > > > > Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
> > > > > >
> > > > > > Why cb->next is not locked in burst functions?
> > > > > It is safe to do "read access" here and doesn't require any locking as rx/tx burst is initiated  by only local user(control plane)
> > thread.
> > > > >
> > > > > > Just protecting add/remove but not its usage seems useless.
> > > > > Here locks were required  around add/remove to protect "write access"  because write to callback list is now done from 2
> > threads
> > > > > i.e. one from local user thread(control plane) and another from pdump control thread(initiated by remote pdump request).
> > > >
> > > > So read and write can be done by different threads.
> > >
> > > Yes, and this is possible even in current DPDK version (16.04).
> > > What is added by Reshma's patch - now it is possible to have concurrent write
> > > from 2 different thread to that list.
> > >
> > > > I think the read access would need locking but we do not want it
> > > > in fast path.
> > >
> > > I don't think it would be needed.
> > > As I said - read/write interaction didn't change from what we have right now.
> > > But if you have some particular scenario in mind that you believe would cause
> > > a race condition - please speak up.
> > 
> > If we add/remove a callback during a burst? Is it possible that the next
> > pointer would have a wrong value leading to a crash?
> > Maybe we need a comment to state that we should not alter burst
> > callbacks while running burst functions.
> 
> Current status (16.04):
> It is safe to add/remove RX/TX callbacks while 
> another thread is doing simultaneously RX/TX burst over same queue.
> I.E: it is supposed to be safe to invoke
> rte_eth_add(/remove)_rx(/tx)_callback() and rte_eth_rx_burst()/rte_eth_tx_burst()
> from different threads simultaneously.
> Though it is not safe to free/modify that rte_eth_rxtx_callback while current
> rte_eth_rx_burst()/rte_eth_tx_burst() are still active.
> That exactly what comments for rte_eth_remove_rx_callback() say:
> 
> * Note: the callback is removed from the callback list but it isn't freed
>  * since the it may still be in use. The memory for the callback can be
>  * subsequently freed back by the application by calling rte_free():
>  *
>  * - Immediately - if the port is stopped, or the user knows that no
>  *   callbacks are in flight e.g. if called from the thread doing RX/TX
>  *   on that queue.
>  *
>  * - After a short delay - where the delay is sufficient to allow any
>  *   in-flight callbacks to complete.
> 
> In other words, right now there only way to know for sure that it is safe
> to free the removed callback - is to stop the port.
> 
> Does it need to be changed, so when rte_eth_remove_rx_callback() returns
> user can safely free the callback (or even better rte_eth_remove_rx_callback free the callback for us)?
> In my opinion - yes.
> Though, I think, it has nothing to do with pdump patches, and I think should be a matter
> for separate a patch/discussion.
> 
> Now with pdump library introduction - there is possibility that 2 different threads
> can try to  add/remove callbacks for the same queue simultaneously.
> First one - thread executing control requests from local user,
> second  one - pdump control thread executing pdump requests from pdump client.
> That lock is introduced to avoid race condition between such 2 threads:
> i.e. to prevent multiple threads to modify same list simultaneously.   
> It is not intended to synchronise read/write accesses to the list, see above. 

OK thanks for the explanations

  reply	other threads:[~2016-06-15 11:17 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1465487895-5870-1-git-send-email-reshma.pattan@intel.com>
2016-06-10 16:18 ` [dpdk-dev] [PATCH v8 0/8] add packet capture framework Reshma Pattan
2016-06-10 16:18   ` [dpdk-dev] [PATCH v8 1/8] librte_ether: protect add/remove of rxtx callbacks with spinlocks Reshma Pattan
2016-06-10 16:18   ` [dpdk-dev] [PATCH v8 2/8] librte_ether: add new api rte_eth_add_first_rx_callback Reshma Pattan
2016-06-10 16:18   ` [dpdk-dev] [PATCH v8 3/8] librte_ether: add new fields to rte_eth_dev_info struct Reshma Pattan
2016-06-10 16:18   ` [dpdk-dev] [PATCH v8 4/8] librte_ether: make rte_eth_dev_get_port_by_name rte_eth_dev_get_name_by_port public Reshma Pattan
2016-06-10 16:18   ` [dpdk-dev] [PATCH v8 5/8] lib/librte_pdump: add new library for packet capturing support Reshma Pattan
2016-06-10 18:48     ` Aaron Conole
2016-06-10 22:14       ` Pattan, Reshma
2016-06-13 13:28         ` Aaron Conole
2016-06-10 16:18   ` [dpdk-dev] [PATCH v8 6/8] app/pdump: add pdump tool for packet capturing Reshma Pattan
2016-06-10 16:18   ` [dpdk-dev] [PATCH v8 7/8] app/test-pmd: add pdump initialization uninitialization Reshma Pattan
2016-06-10 16:18   ` [dpdk-dev] [PATCH v8 8/8] doc: update doc for packet capture framework Reshma Pattan
2016-06-10 23:23   ` [dpdk-dev] [PATCH v8 0/8] add " Neil Horman
2016-06-13  8:47     ` Pattan, Reshma
2016-06-14  9:38   ` [dpdk-dev] [PATCH v9 " Reshma Pattan
2016-06-14  9:38     ` [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx callback lists Reshma Pattan
2016-06-14 19:59       ` Thomas Monjalon
2016-06-15  5:30         ` Pattan, Reshma
2016-06-15  8:19           ` Thomas Monjalon
2016-06-15  8:37             ` Ananyev, Konstantin
2016-06-15  8:48               ` Thomas Monjalon
2016-06-15  9:54                 ` Ananyev, Konstantin
2016-06-15 11:17                   ` Thomas Monjalon [this message]
2016-06-15 13:49                   ` Thomas Monjalon
2016-06-15 12:15                 ` Ivan Boule
2016-06-15 12:40                   ` Ananyev, Konstantin
2016-06-15 13:29                     ` Bruce Richardson
2016-06-15 14:07                       ` Ivan Boule
2016-06-15 14:19                         ` Bruce Richardson
2016-06-15 14:20                         ` Ananyev, Konstantin
2016-06-15 14:22                           ` Bruce Richardson
2016-06-15 14:27                             ` Ananyev, Konstantin
2016-06-15 15:33                               ` Ivan Boule
2016-06-14  9:38     ` [dpdk-dev] [PATCH v9 2/8] ethdev: add new api to add Rx callback as head of the list Reshma Pattan
2016-06-14 20:01       ` Thomas Monjalon
2016-06-14 21:43         ` Pattan, Reshma
2016-06-14  9:38     ` [dpdk-dev] [PATCH v9 3/8] ethdev: add new fields to ethdev info struct Reshma Pattan
2016-06-14 20:10       ` Thomas Monjalon
2016-06-14 21:57         ` Pattan, Reshma
2016-06-14  9:38     ` [dpdk-dev] [PATCH v9 4/8] ethdev: make get port by name and get name by port public Reshma Pattan
2016-06-14 20:23       ` Thomas Monjalon
2016-06-14 21:55         ` Pattan, Reshma
2016-06-14  9:38     ` [dpdk-dev] [PATCH v9 5/8] pdump: add new library for packet capturing support Reshma Pattan
2016-06-14 20:28       ` Thomas Monjalon
2016-06-14 21:59         ` Pattan, Reshma
2016-06-15  9:05         ` Mcnamara, John
2016-06-15  9:32           ` Thomas Monjalon
2016-06-15  9:43             ` Bruce Richardson
2016-06-15 15:44             ` Mcnamara, John
2016-06-14  9:38     ` [dpdk-dev] [PATCH v9 6/8] app/pdump: add pdump tool for packet capturing Reshma Pattan
2016-06-14 19:56       ` Thomas Monjalon
2016-06-14  9:38     ` [dpdk-dev] [PATCH v9 7/8] app/testpmd: add pdump initialization uninitialization Reshma Pattan
2016-06-14  9:38     ` [dpdk-dev] [PATCH v9 8/8] doc: update doc for packet capture framework Reshma Pattan
2016-06-14 20:41       ` Thomas Monjalon
2016-06-15  5:44         ` Pattan, Reshma
2016-06-15  8:24           ` Thomas Monjalon
2016-06-15 14:06     ` [dpdk-dev] [PATCH v10 0/7] add " Reshma Pattan
2016-06-15 14:06       ` [dpdk-dev] [PATCH v10 1/7] ethdev: use locks to protect Rx/Tx callback lists Reshma Pattan
2016-06-15 14:06       ` [dpdk-dev] [PATCH v10 2/7] ethdev: add new api to add Rx callback as head of the list Reshma Pattan
2016-06-15 14:06       ` [dpdk-dev] [PATCH v10 3/7] ethdev: add new fields to ethdev info struct Reshma Pattan
2016-06-16 19:14         ` Thomas Monjalon
2016-06-15 14:06       ` [dpdk-dev] [PATCH v10 4/7] ethdev: make get port by name and get name by port public Reshma Pattan
2016-06-16 20:27         ` Thomas Monjalon
2016-06-15 14:06       ` [dpdk-dev] [PATCH v10 5/7] pdump: add new library for packet capturing support Reshma Pattan
2016-06-15 14:06       ` [dpdk-dev] [PATCH v10 6/7] app/pdump: add pdump tool for packet capturing Reshma Pattan
2016-06-15 14:06       ` [dpdk-dev] [PATCH v10 7/7] app/testpmd: add pdump initialization uninitialization Reshma Pattan
2016-06-16 21:55       ` [dpdk-dev] [PATCH v10 0/7] add packet capture framework Thomas Monjalon

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=3682885.ZONGT1nz9t@xps13 \
    --to=thomas.monjalon@6wind.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.com \
    --cc=reshma.pattan@intel.com \
    /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).