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 135C8A034F; Tue, 8 Jun 2021 10:07:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 954CD410E7; Tue, 8 Jun 2021 10:07:15 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 2EE7F4013F for ; Tue, 8 Jun 2021 10:07:14 +0200 (CEST) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 983327F52A; Tue, 8 Jun 2021 11:07:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 983327F52A DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1623139633; bh=a5fgtJEQV5yLiJeJLp3xANwkdB72qco4c7PiejgSjCQ=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=u7SEFyvSfQfCQo2cNis9TK7yqA1xhoygiOLIz91GGYsf/431k65i5kuOsKh07k/ew 4icE8vsV9YpkC71guHTIU9BF6vKiSpdg0aQ2hDlLTLlmAIOSdxNw7QSD7IOt5gym2L VwHrIYoWseK+t5AsG/UCDYLCOWxKFMI1dsN/L2Rg= To: Stephen Hemminger , dev@dpdk.org Cc: suanmingm@nvidia.com References: <20210315192722.35490-1-stephen@networkplumber.org> <20210315192722.35490-2-stephen@networkplumber.org> From: Andrew Rybchenko Organization: OKTET Labs Message-ID: <3fd9cfbc-ed10-a11e-f10c-73ea3864acf9@oktetlabs.ru> Date: Tue, 8 Jun 2021 11:07:13 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210315192722.35490-2-stephen@networkplumber.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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/21 10: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); Return value must be checked here. It may return ENOTSUP and EINVAL. If it fails, IMHO we should do cleanup and return NULL. > + pthread_mutex_init(ð_dev->data->flow_ops_mutex, &attr); > > unlock: > rte_spinlock_unlock(ð_dev_shared_data->ownership_lock); > Please, fix notes from Thomas and above. Overall these patches LGTM. I think we should not introduce any flags that flow ops are multi-process safe. Nobody prevents to call the API in multi-process case and it must behave consistently. The patch makes ethdev API safe and it is responsibility of the driver care about final multi-process safety.