From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 85F67A04BC; Sun, 27 Sep 2020 10:20:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F01241D8EA; Sun, 27 Sep 2020 10:20:35 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 9A5DE1D8E8 for ; Sun, 27 Sep 2020 10:20:33 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from suanmingm@nvidia.com) with SMTP; 27 Sep 2020 11:20:27 +0300 Received: from nvidia.com (mtbc-r640-04.mtbc.labs.mlnx [10.75.70.9]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 08R8KQ1Q027083 for ; Sun, 27 Sep 2020 11:20:27 +0300 From: Suanming Mou To: Cc: dev@dpdk.org Date: Sun, 27 Sep 2020 16:20:15 +0800 Message-Id: <1601194817-208834-1-git-send-email-suanmingm@nvidia.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH 0/2] ethdev: make rte flow API thread safe 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Currently, the rte flow functions are not defined as thread safety. DPDK applications either call the functions in single thread or add locks around the functions for the critical section. For PMDs support the flow operations thread safe natively, the redundant protection in application hurts the performance of the rte flow operation functions. And the restriction of thread safety not guaranteed for the rte flow functions also limits the applications' expectation. This feature is going to change the rte flow functions to be thread safety. As different PMDs have different flow operations, some may support thread safety already and others may not. For PMDs don't support flow thread safe operation, a new lock is defined in ethdev in order to protects thread unsafe PMDs from rte flow level. A new RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE device flag is added to determine whether the PMD supports thread safe flow operation or not. For PMDs support thread safe flow operations, set the RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE flag, rte flow level functions will skip the thread safe helper lock for these PMDs. Again the rte flow level thread safe lock only works when PMD operation functions are not thread safety. For the PMDs which don't want the default mutex lock, just set the flag in the PMD, and add the perfer type of lock in the PMD. Then the default mutex lock is easily replaced by the PMD level lock. The change has no effect on the current DPDK applications. No change is required for the current DPDK applications. If no lock contention with the added rte flow level mutex, the mutex only does the atomic increasing in pthread_mutex_lock() and decreasing in pthread_mutex_unlock(). No futex() syscall will be involved. Suanming Mou (2): eal/windows: add pthread mutex lock ethdev: make rte flow API thread safe doc/guides/prog_guide/rte_flow.rst | 7 ++- drivers/net/mlx5/linux/mlx5_os.c | 2 + lib/librte_eal/windows/include/pthread.h | 46 +++++++++++++++++ lib/librte_ethdev/rte_ethdev.c | 2 + lib/librte_ethdev/rte_ethdev.h | 2 + lib/librte_ethdev/rte_ethdev_core.h | 4 ++ lib/librte_ethdev/rte_flow.c | 84 ++++++++++++++++++++++++-------- 7 files changed, 124 insertions(+), 23 deletions(-) -- 1.8.3.1