From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 686B7A0C41; Fri, 16 Apr 2021 10:19:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 567D8141B9F; Fri, 16 Apr 2021 10:19:00 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mails.dpdk.org (Postfix) with ESMTP id 14D8D141B99 for ; Fri, 16 Apr 2021 10:18:57 +0200 (CEST) IronPort-SDR: tzxtqy0qP1FFjci6LFTA4ROyNL3T9mCrVbSsvIrt3ny49OxYkxpjDxnuFUYPguYdp1Eft0QhOW C2SbkmSuz2IA== X-IronPort-AV: E=McAfee;i="6200,9189,9955"; a="174501856" X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="174501856" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2021 01:18:56 -0700 IronPort-SDR: qr3EhGWadCx9QgnjhYYiwYVWGOXsmryojzwaD5NKldo/fEJu16t1UA5s9fdmAw6F9vcQTq1cDa hkF+mpI8tadA== X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="425510294" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.207.150]) ([10.213.207.150]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2021 01:18:54 -0700 To: Stephen Hemminger , dev@dpdk.org Cc: suanmingm@nvidia.com, Thomas Monjalon , Andrew Rybchenko References: <20210315192722.35490-1-stephen@networkplumber.org> <20210315192722.35490-2-stephen@networkplumber.org> From: Ferruh Yigit X-User: ferruhy Message-ID: <1dd118a9-6c6e-a53a-cfb0-eeb03ba2c6df@intel.com> Date: Fri, 16 Apr 2021 09:18:51 +0100 MIME-Version: 1.0 In-Reply-To: <20210315192722.35490-2-stephen@networkplumber.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH 1/2] ethdev: make flow API primary/secondary process safe X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 3/15/2021 7:27 PM, Stephen Hemminger wrote: > Posix mutex are not by default safe for protecting for usage > from multiple processes. The flow ops mutex could be used by > both primary and secondary processes. > > Bugzilla ID: 662 > Signed-off-by: Stephen Hemminger > Fixes: 80d1a9aff7f6 ("ethdev: make flow API thread safe") > Cc: suanmingm@nvidia.com > --- > lib/librte_ethdev/rte_ethdev.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c > index 6f514c388b4e..d1024df408a5 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -470,6 +470,7 @@ rte_eth_dev_allocate(const char *name) > { > uint16_t port_id; > struct rte_eth_dev *eth_dev = NULL; > + pthread_mutexattr_t attr; > size_t name_len; > > name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN); > @@ -506,7 +507,10 @@ rte_eth_dev_allocate(const char *name) > strlcpy(eth_dev->data->name, name, sizeof(eth_dev->data->name)); > eth_dev->data->port_id = port_id; > eth_dev->data->mtu = RTE_ETHER_MTU; > - pthread_mutex_init(ð_dev->data->flow_ops_mutex, NULL); > + > + pthread_mutexattr_init(&attr); > + pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); > + pthread_mutex_init(ð_dev->data->flow_ops_mutex, &attr); > > unlock: > rte_spinlock_unlock(ð_dev_shared_data->ownership_lock); > The problem looks legit, and there seems no obvious downside of the patch. Also Huawei test result was good, hence: Acked-by: Ferruh Yigit And the PMDs that set the 'RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE' flag already not affected from this change at all, but how safe mutli process applications will be for them is still not clear.