From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id DF7A71B3B7 for ; Thu, 2 Nov 2017 10:41:09 +0100 (CET) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Nov 2017 02:41:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,333,1505804400"; d="scan'208";a="170383238" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.221.32]) by fmsmga005.fm.intel.com with SMTP; 02 Nov 2017 02:41:05 -0700 Received: by (sSMTP sendmail emulation); Thu, 02 Nov 2017 09:41:05 +0000 Date: Thu, 2 Nov 2017 09:41:05 +0000 From: Bruce Richardson To: Harry van Haaren Cc: dev@dpdk.org, thomas@monjalon.net, pbhagavatula@caviumnetworks.com Message-ID: <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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1509562081-52763-1-git-send-email-harry.van.haaren@intel.com> Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.9.1 (2017-09-22) 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: Thu, 02 Nov 2017 09:41:10 -0000 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