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 ED4B9A04BE; Mon, 7 Sep 2020 04:36:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 491062BAB; Mon, 7 Sep 2020 04:36:57 +0200 (CEST) Received: from hqnvemgate24.nvidia.com (hqnvemgate24.nvidia.com [216.228.121.143]) by dpdk.org (Postfix) with ESMTP id 5938A1DB8 for ; Mon, 7 Sep 2020 04:36:55 +0200 (CEST) Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Sun, 06 Sep 2020 19:34:42 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Sun, 06 Sep 2020 19:36:54 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Sun, 06 Sep 2020 19:36:54 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 7 Sep 2020 02:36:49 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.169) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Mon, 7 Sep 2020 02:36:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=emQ8Wexsv11kAy3WC8VV2wibPPyQtSC2iCBBjdYvoQzJwZVC+cutnT080vOQmQu6Rt3iU6L/a2RXZSjhuVsY8OJHFZzX89Mk3uvB1eNNundrlj2kMWFDiCc7uwZsHm5jvMGpe0dqH5ttbo2qLLQx2eIy85jq0zyI3X4sN81v3PVHJbQiLqrdTkBhyWuCgi/BXsGS7Cf3Zz0ip6Ujh6sOcILY0fpAAnLN/eYMlebsOX6l/sm1ePhQw+EiAuZalgQMGDz2m3hsP/w3HRmEZnAkXF83Iltud8k86c5j6/NxB9YV3cvKl5Zt/hLfPqjzlQobwqpKojFvovQlMQT0932oMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KKf+Bupgs/ElBI73NXI1PkEmGdj+S5+gQo9V6nfFIs4=; b=iI62mp7f7fVFz9l7j71Thwfc0Ml02usFPdC8+jSR9U/zGZdGrtXTmX+Sh88PBMqFV3XvUPhZoOtYaJcxrWYUyPGn3qTF1T93ysnrUa6zL1cziXQMumI3BHzf34jTMcV3vHqUU3g5pK7YJ4/YObQw/VR+rCBhIymRzk1Ax7zlf8p9M1Sx42x5bt7YL9AIg4ZE+BdQxQBvv0vOV6Ee6h7zWadyeygGi7QjcTu2KsmXwifLdzNB3OUpxBzVbrcbacdArgiSQbuhOhhmZ0fEgFuU1USWNrJ5G4iGgyjIj30BYyBAi/uQryoffeAulTZjMrH6EAmkT2avZ05OZtQXsAfNdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none Received: from MN2PR12MB3550.namprd12.prod.outlook.com (2603:10b6:208:108::22) by MN2PR12MB2863.namprd12.prod.outlook.com (2603:10b6:208:103::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.17; Mon, 7 Sep 2020 02:36:48 +0000 Received: from MN2PR12MB3550.namprd12.prod.outlook.com ([fe80::b514:9492:7a05:75bf]) by MN2PR12MB3550.namprd12.prod.outlook.com ([fe80::b514:9492:7a05:75bf%4]) with mapi id 15.20.3348.019; Mon, 7 Sep 2020 02:36:48 +0000 From: Suanming Mou To: Stephen Hemminger CC: Ori Kam , John McNamara , Marko Kovacevic , Matan Azrad , Shahaf Shuler , "Viacheslav Ovsiienko" , NBU-Contact-Thomas Monjalon , Ferruh Yigit , "Andrew Rybchenko" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [RFC] ethdev: make rte flow API thread safe Thread-Index: AQHWghj/PKRqPjtRmE+dlUFVZ4B+AalcdyOQ Date: Mon, 7 Sep 2020 02:36:48 +0000 Message-ID: References: <1599108782-230624-1-git-send-email-suanmingm@nvidia.com> <20200903103739.1d1b4b0e@hermes.lan> In-Reply-To: <20200903103739.1d1b4b0e@hermes.lan> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: networkplumber.org; dkim=none (message not signed) header.d=none;networkplumber.org; dmarc=none action=none header.from=nvidia.com; x-originating-ip: [60.176.163.47] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 327ca9c3-eac2-409b-a7d5-08d852d6de93 x-ms-traffictypediagnostic: MN2PR12MB2863: x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-transport-forked: True x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pMGydAtgx2fl3Siw+x+3nKz8tjBupzlb1c+DmJkgURL8ovYHQAIBT/jh5TWxyiEGNOuDMh73JLP1S7JDkWu5zV4h+Esgu9pC2he22PmHX5thurho0Ke6kM1SaxGV2GsjPYuweZt7ejS94N21+Ecje8diTETWc7cgi6svzbzoZ5MsWyce1qLeq3kHRpHstQj82KnnWT0+Y8ytJbPFOkUEkFgXQ+dJKElCAgjXUPOHGI7STW7hZM0u5iOQRebAalF/Uju9WRRbxvu4eiJRTPIZr3I1PxcaIpyKuaQtNM8F4biNQwdxFrLzpUIZUXrj+UP7 x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR12MB3550.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(346002)(39860400002)(366004)(396003)(136003)(66556008)(64756008)(66446008)(66476007)(8676002)(76116006)(66946007)(33656002)(86362001)(316002)(26005)(71200400001)(7696005)(6506007)(186003)(52536014)(83380400001)(4326008)(5660300002)(9686003)(6916009)(2906002)(55016002)(478600001)(54906003)(8936002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: yy9Q+Gd8fYyAv+AD7znYg+3Gyzwj55MqLPpn85lG/qQjoyKGS9IlV30wft6rNM9DyF+JMG3ibFbHUgzwvLp23ch5zIqqoq+Q36jW5ItjKAfqj22wSMdfMYa0BgThDOV0uqNbi3DcxbFBDKR0i/AJdG6/YmhWqEfv5CYqNy/YKn7v3HcxIzw08S4s0q/X4Kmvd1yfgO9bkoTUeFMQZW5kD1pIfntveSIL8+6aOduQyUtey+UUcm5eFHFmZW1JbnYhJ/Q1ikfADYZSQ9856NurZW8QEXKKenyIiuTuy0dQwDWqs3GlpggMfcy9ivUHA11w8wR8fbP64XXVPf2CGPMx4UUw+0YwkrV8YD1xYhSWamaM6uyEMNzNwvfYpxTXd4GZMTn3HOTYlMl8cxD+xRqP6dsPo2ChPuh29UP8bV7LE3BAcQV0TgYG9vMCTIQmaeiBwyAFOYYwvhqxbxf/dS1k4wbw4ouxVQvW2EBglf/fpPYszyJL/DHzQOvBaWBxKIIidhfHkxJop/cX5GTQ+MqVAVeAbg0DjPHWevOE3KRw9LDOt5++9oiQg6wEIIL+/NoJKe+NYxR5ylmJQqbyGOuMwkOBzR00O2pG+BTgZJrWhdPkzjfwpMZQq/oo5mD2CID2uobxkb/Vjo02hvTjfFqx5g== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3550.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 327ca9c3-eac2-409b-a7d5-08d852d6de93 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Sep 2020 02:36:48.2053 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: KuFzK8wLFpFrO7FPYzt35QW51jszLTSDK1lip5COL6uNPQfuyoLc2d9aUl90rmoPc+lUGhOxKDrlc1jG/be2Qw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB2863 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1599446082; bh=KKf+Bupgs/ElBI73NXI1PkEmGdj+S5+gQo9V6nfFIs4=; h=X-PGP-Universal:ARC-Seal:ARC-Message-Signature: ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic: Thread-Index:Date:Message-ID:References:In-Reply-To: Accept-Language:Content-Language:X-MS-Has-Attach: X-MS-TNEF-Correlator:authentication-results:x-originating-ip: x-ms-publictraffictype:x-ms-office365-filtering-correlation-id: x-ms-traffictypediagnostic:x-ld-processed: x-microsoft-antispam-prvs:x-ms-exchange-transport-forked: x-ms-oob-tlc-oobclassifiers:x-ms-exchange-senderadcheck: x-microsoft-antispam:x-microsoft-antispam-message-info: x-forefront-antispam-report:x-ms-exchange-antispam-messagedata: Content-Type:Content-Transfer-Encoding:MIME-Version: X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-AuthSource: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-originalarrivaltime: X-MS-Exchange-CrossTenant-fromentityheader: X-MS-Exchange-CrossTenant-id:X-MS-Exchange-CrossTenant-mailboxtype: X-MS-Exchange-CrossTenant-userprincipalname: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg; b=rJUPIQ0cpjFld/nyiY4wTI1PCRHuzlvs273CePdcXYYm4GafICsBUfa8NnDx8mcA/ Aexg7q0VruJu7ETc6qaABUL4m24MIZciLAxAHMRMy4gQU1BEzB533HSP0RkLeUluk0 qCslWexzvmbgDAsnQPsBWBPdo/XtDNhqtFnSLhmh0oU9ptjvhhOJGNPEFERZJjOQHL gu8o1X9Hk7PeJG5lt9EHzxgB+UU85PGo1lIgC0oGeElzCmO11QuUuxuwCEx5sX5KxQ d72mLDpW8IA2GwaMkjdsdeIFujzJL1XRAG14xaiuizW5pKuyReVEoDVIPO/Oby0EPv sPuvMsf7QIrRg== Subject: Re: [dpdk-dev] [RFC] 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" Hi, Sorry for my late reply due to the vacation. > What is the performance impact of this for currently working applications= that > use a single thread to program flow rules. You are adding a couple of sy= stem > calls to what was formerly a totally usermode operation. If I understand correctly, in the non-contended single thread case, pthread= mutex lock should not go to the kernel space. I also wrote a small application with pthread mutex, and strace shows no sy= stem call was introduced. Another simple testing code below is to check the cycles cost difference in= every round between pthread mutex and spin_lock. //#define FT_USE_SPIN 1 #define NLOOP 1000000 #ifdef FT_USE_SPIN static rte_spinlock_t sp_lock; #else static pthread_mutex_t ml_lock; #endif static inline void ft_init_lock(void) { #ifdef FT_USE_SPIN rte_spinlock_init(&sp_lock); #else pthread_mutex_init(&ml_lock, NULL); #endif } static inline void ft_unlock(void) { #ifdef FT_USE_SPIN rte_spinlock_unlock(&sp_lock); #else pthread_mutex_unlock(&ml_lock); #endif } static inline void ft_lock(void) { #ifdef FT_USE_SPIN rte_spinlock_lock(&sp_lock); #else pthread_mutex_lock(&ml_lock); #endif } static void ft_check_cycles(void) { static int init =3D 0; uint64_t start, end; int i, n; if (!init) { init =3D 1; ft_init_lock(); } /* Make code hot. */ ft_lock(); n =3D 0; ft_unlock(); start =3D rte_rdtsc(); for (i =3D 0; i < NLOOP; i++) { ft_lock(); n++; ft_unlock(); } end =3D rte_rdtsc(); printf("loop:%d, cycles per loop:%f\n", n, (end - start) / (float)n); } They both showed around 50 cycles similar costing per loop. The reason pthread mutex lock chosen here is that most DPDK applications li= ke OVS-DPDK is using that. Thanks, SuanmingMou