From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by dpdk.org (Postfix) with ESMTP id 694C9C4E6 for ; Wed, 15 Jun 2016 13:17:34 +0200 (CEST) Received: by mail-wm0-f42.google.com with SMTP id m124so31146772wme.1 for ; Wed, 15 Jun 2016 04:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-transfer-encoding; bh=VyVRMmSPI4LKsJZCmEsRlCcoKBBllSF61J2z/oXmkUQ=; b=XP5reV1uipcznnoxptOBRgPXcdRST1qQoNrr9WVRFcGBV8hMvM1nQU3tGHmt07TaYc Di0bzwvCmb2aXhuaL2btV7XKgbglcfl/7F3JqvdBZEeygroKBc8CgJlEOYfhbnwqja/C fwiPcNSK8MzMK8vh6nmJ8weehd5oLmZO9/fXh0egW2GqIsNpzd4FgjP7FAQ2Q4sVynZU YCxWyF+SGU8Xc5oqnwcoqXdQoHE03uB5My0p33xl1Qasp+6UFWmVdqzad+nQ1tfLBHSa 088GIZ3/yCo6NIEFzX94VwuH07H7n0KvCw0wtLcP2kdqkVTywNx6ruMcd821VnKZKjCg AMVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :in-reply-to:references:mime-version:content-transfer-encoding; bh=VyVRMmSPI4LKsJZCmEsRlCcoKBBllSF61J2z/oXmkUQ=; b=Wx1m0J3oawcWWR/KaL7hrGSKYMJOKzqsLo/XSIXl7z4gv0O+pNZL7WWNfR13aycIyb Q1+RqfLeDXTEaRxEhuxQdQEDeV3V8rYYFIoSSkRO7BfaLvgazJ22mRhEqE/rA+Ke1QOa LOrKFn5XajKX9uIaJEsUr3AV7smDxjP7uyJE4oGTDPudq0awuT9QsQ2HGr2Cuh3mVKOd /IONxgy0vdwGI7X9smj77xG44C4Vxj8F9MrnzAydXW5IveNNukc2kWi4qya72u7wqd8F dnf3YBsUxCqMlnC8h15Ry+8G0H8P9TjImo0S/pQQGIpdARgOrZ3tOCthsB3+StJbB5L3 URzA== X-Gm-Message-State: ALyK8tJbiHh5I4wXo+2BgCa3JdjHbCdS+E8Ia72wGHSa2SemAlLzVxJVZP48N3TECpISStEG X-Received: by 10.195.9.67 with SMTP id dq3mr11903467wjd.140.1465989454117; Wed, 15 Jun 2016 04:17:34 -0700 (PDT) Received: from xps13.localnet (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id wb10sm37953073wjc.8.2016.06.15.04.17.32 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 15 Jun 2016 04:17:33 -0700 (PDT) From: Thomas Monjalon To: "Ananyev, Konstantin" Cc: "Pattan, Reshma" , dev@dpdk.org Date: Wed, 15 Jun 2016 13:17:32 +0200 Message-ID: <3682885.ZONGT1nz9t@xps13> User-Agent: KMail/4.14.10 (Linux/4.5.4-1-ARCH; KDE/4.14.11; x86_64; ; ) In-Reply-To: <2601191342CEEE43887BDE71AB97725836B7164D@irsmsx105.ger.corp.intel.com> References: <1465575534-23605-1-git-send-email-reshma.pattan@intel.com> <2907169.iIEIeOfXh7@xps13> <2601191342CEEE43887BDE71AB97725836B7164D@irsmsx105.ger.corp.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 11:17:34 -0000 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 > > > > > > > > > > > > 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