From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id E8D79C4AE for ; Wed, 15 Jun 2016 11:54:12 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP; 15 Jun 2016 02:54:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,475,1459839600"; d="scan'208";a="719367382" Received: from irsmsx154.ger.corp.intel.com ([163.33.192.96]) by FMSMGA003.fm.intel.com with ESMTP; 15 Jun 2016 02:54:11 -0700 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.51]) by IRSMSX154.ger.corp.intel.com ([169.254.12.28]) with mapi id 14.03.0248.002; Wed, 15 Jun 2016 10:54:10 +0100 From: "Ananyev, Konstantin" To: Thomas Monjalon CC: "Pattan, Reshma" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx callback lists Thread-Index: AQHRxsb8c+QpcxnBPE2qkSBe1aWjuJ/qHtqAgAAUOJD///QYAIAAHNPg Date: Wed, 15 Jun 2016 09:54:09 +0000 Message-ID: <2601191342CEEE43887BDE71AB97725836B7164D@irsmsx105.ger.corp.intel.com> References: <1465575534-23605-1-git-send-email-reshma.pattan@intel.com> <10886152.VH5xYhdqG2@xps13> <2601191342CEEE43887BDE71AB97725836B714ED@irsmsx105.ger.corp.intel.com> <2907169.iIEIeOfXh7@xps13> In-Reply-To: <2907169.iIEIeOfXh7@xps13> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx callback lists X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2016 09:54:13 -0000 > -----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 >=20 > 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 > > > > > > > > > > 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 acces= s" because write to callback list is now done from 2 > threads > > > > i.e. one from local user thread(control plane) and another from pdu= mp 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 righ= t now. > > But if you have some particular scenario in mind that you believe would= cause > > a race condition - please speak up. >=20 > 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=20 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_b= urst() from different threads simultaneously. Though it is not safe to free/modify that rte_eth_rxtx_callback while curre= nt 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_callbac= k free the callback for us)? In my opinion - yes. Though, I think, it has nothing to do with pdump patches, and I think shoul= d 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 clie= nt. That lock is introduced to avoid race condition between such 2 threads: i.e. to prevent multiple threads to modify same list simultaneously. =20 It is not intended to synchronise read/write accesses to the list, see abov= e.=20 Konstantin