From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id 69EE21B33E for ; Tue, 7 Nov 2017 01:26:43 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 1C4F420A62; Mon, 6 Nov 2017 19:26:43 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Mon, 06 Nov 2017 19:26:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=tvUaBK/1gR0xtYTrordOG8bO1l o7/X2wK2QE6A93Mvk=; b=Uu/2H5V51TugTM0jj5tkBsdCE4a8LJ4k+btdJH70Xe 9/p/uqXKGsg6+Zm9Hf70Is8cUh8ZDOszwF/MvpHMgXWlDsjnw0v4wlpwQ75uh0y6 BM5r/tptJs5quf0KR+v3sAhkBkDtGuj5qvAia+432aY19xb/lMIOcq01qlbcu56S w= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=tvUaBK /1gR0xtYTrordOG8bO1lo7/X2wK2QE6A93Mvk=; b=YmSgqgfG6WLtRzpv4jrLvl ygVXhCWKmS1a16MaiYKOVkGkA/lVY9GmR0P3DVnpc7YaA1qR4Kmm1EPoQ55gEMvQ zjgAzqT0+DHajezyNho+yGIXB1rTZ1tM6DWzaVeI5R/TF8YHlA0Pb2ipqm6KMcxh EaYM235IEIKjsofoajYGI1Gni9qaC8CMAW8cRCMjBFt2aNUFz1hHq1uwF6W0YW51 G4ZWOxv3aTTWLcqm2X0yg9PZRB3FU0orPxpy2n4YS8TvVeVD/Eiv8WVMmDl5v9iH e2iV3L0HdxExr8rZJuEjNVd809Zj2JgsRqCDvAiD/VYPKR2lbNvl+8xHQ/WKNrnA == X-ME-Sender: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id D297D241BE; Mon, 6 Nov 2017 19:26:42 -0500 (EST) From: Thomas Monjalon To: Harry van Haaren Cc: dev@dpdk.org, Bruce Richardson , pbhagavatula@caviumnetworks.com Date: Tue, 07 Nov 2017 01:26:42 +0100 Message-ID: <3101300.eJ1rulUoFZ@xps> In-Reply-To: <20171102094105.GB19712@bricha3-MOBL3.ger.corp.intel.com> References: <1509450542-123626-1-git-send-email-harry.van.haaren@intel.com> <1509562081-52763-1-git-send-email-harry.van.haaren@intel.com> <20171102094105.GB19712@bricha3-MOBL3.ger.corp.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v2] service: fix race in service on app lcore function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Nov 2017 00:26:43 -0000 02/11/2017 10:41, Bruce Richardson: > On Wed, Nov 01, 2017 at 06:48:01PM +0000, Harry van Haaren wrote: > > This commit fixes a possible race condition if an application > > uses the service-cores infrastructure and the function to run > > a service on an application lcore at the same time. > > > > The fix is to change the num_mapped_cores variable to be an > > atomic variable. This causes concurrent accesses by multiple > > threads to a service using rte_service_run_iter_on_app_lcore() > > to detect if another core is currently mapped to the service, > > and refuses to run if it is not multi-thread safe. > > > > The run iteration on app lcore function has two arguments, the > > service id to run, and if atomics should be used to serialize access > > to multi-thread unsafe services. This allows applications to choose > > if they wish to use use the service-cores feature, or if they > > take responsibility themselves for serializing invoking a service. > > See doxygen documentation for more details. > > > > Two unit tests were added to verify the behaviour of the > > function to run a service on an application core, testing both > > a multi-thread safe service, and a multi-thread unsafe service. > > > > The doxygen API documentation for the function has been updated > > to reflect the current and correct behaviour. > > > > Fixes: e9139a32f6e8 ("service: add function to run on app lcore") > > > > Signed-off-by: Harry van Haaren > > > > --- > > > > v2: > > - Rework function to have parameter that allows the application > > to select if it requires atomics to be used of it the application > > wishes to take responsibility for serializing instead. > > > This approach seems better to me. I think the function itself might be > better if you just duplicated a bit more code to reduce the number of > checks on the serialization variable, but it's readable enough as it is > now, so > > Acked-by: Bruce Richardson Applied, thanks