[dpdk-dev] [PATCH 1/2] ethdev: make flow API primary/secondary process safe
Ferruh Yigit
ferruh.yigit at intel.com
Fri Apr 16 10:18:51 CEST 2021
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 <stephen at networkplumber.org>
> Fixes: 80d1a9aff7f6 ("ethdev: make flow API thread safe")
> Cc: suanmingm at 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 <ferruh.yigit at intel.com>
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.
More information about the dev
mailing list