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 E0B24A04B7; Wed, 14 Oct 2020 12:03:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1CAFE1DDF2; Wed, 14 Oct 2020 12:02:37 +0200 (CEST) Received: from nat-hk.nvidia.com (nat-hk.nvidia.com [203.18.50.4]) by dpdk.org (Postfix) with ESMTP id 0EAA51DDF2 for ; Wed, 14 Oct 2020 12:02:34 +0200 (CEST) Received: from HKMAIL101.nvidia.com (Not Verified[10.18.92.9]) by nat-hk.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Wed, 14 Oct 2020 18:02:32 +0800 Received: from HKMAIL103.nvidia.com (10.18.16.12) by HKMAIL101.nvidia.com (10.18.16.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 14 Oct 2020 10:02:21 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.109) by HKMAIL103.nvidia.com (10.18.16.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 14 Oct 2020 10:02:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=epknSLGIyrCGN/tv5fuvvn3HifqgGbzS4bGAmBs9q7yyoL/QBWYUjgqo+/8QMqgEw8cPtlgE1OELr7fqe/A33TrA+G8woKzCLmD4NXygq9eeWUte2OTGG+etT9bpa7h6/lDO21PXS0SubDuw3LxUPtroQcn+4uBan4STMaauefoYkWGi0bwhxL5xNq7bLdyzRW08T3E3pt32C1165biGDZeLCHu/AhYsaBSgvRaGLR2aNAIpoXLpbXqqB3OXbZFGyOoOKvSpIotN0Fx2fsEa84tRzYy5I8keUocPJhLA/kMEyP/FYAXmp0dJZ3JbmdxXlbsHfKsQ6eagVGWolzpqQg== 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=oZyZcxrU7g72qi8kCeoQ0vznYmfuiNyREEOY9pErfzc=; b=mZifbsyQs3Iy7KiW1L/wSt5DnUhEwsxbRIO19g4rqGzeM0ubcy/79iFdf9R91ZonUwalgK9epg5G3DcS8VKfO+qCXw+7FGW8fbe6kC6UxP/0Zd0ZoV80ngv/TjT/4IJGxUvL9rkT0GqVPWEAR7lMV31h/hEQlxB+HDL4jksfQcN4vrnD0M4I89rAMA+QhI1gl2Oz3nId7aLNH3CdfWSqps40DnIw3vQthvqnnRmwEB3aRF4y/OeXQiVeVeAtSlMLra6VVwfHrJTcrfdsBLIK+2Ks8F/y8amzQ1aNse1z4/s3Z/VuC4AfxnyUwfdyK0ynHM+aUKVLIO+BLhJbOqYLKg== 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 BYAPR12MB3285.namprd12.prod.outlook.com (2603:10b6:a03:134::14) by BYAPR12MB2597.namprd12.prod.outlook.com (2603:10b6:a03:6e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Wed, 14 Oct 2020 10:02:17 +0000 Received: from BYAPR12MB3285.namprd12.prod.outlook.com ([fe80::9577:cc9f:6780:4c6c]) by BYAPR12MB3285.namprd12.prod.outlook.com ([fe80::9577:cc9f:6780:4c6c%7]) with mapi id 15.20.3455.032; Wed, 14 Oct 2020 10:02:17 +0000 From: Tal Shnaiderman To: Dmitry Malloy , Narcisa Ana Maria Vasile CC: NBU-Contact-Thomas Monjalon , "Narcisa Ana Maria Vasile" , Pallavi Kadam , "dev@dpdk.org" , Dmitry Kozlyuk , Suanming Mou Thread-Topic: [PATCH v3 1/2] eal/windows: add pthread mutex lock Thread-Index: AQHWnR1iQx3aCKprAkSPJIIzZFiFSKmW5j0w Date: Wed, 14 Oct 2020 10:02:16 +0000 Message-ID: References: <1601194817-208834-1-git-send-email-suanmingm@nvidia.com> <1602080249-36533-1-git-send-email-suanmingm@nvidia.com> <1602080249-36533-2-git-send-email-suanmingm@nvidia.com> <20201007195358.6687cc42@sovereign> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: microsoft.com; dkim=none (message not signed) header.d=none;microsoft.com; dmarc=none action=none header.from=nvidia.com; x-originating-ip: [77.137.141.17] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b0ccd367-0f06-4e60-bcbf-08d870283b8e x-ms-traffictypediagnostic: BYAPR12MB2597: x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: JMWKXFH1PFCVXK5VwnhMTj8b5Iw9a1v9O+fUrtTPwfrDoIjYHnT6Glh/bW3ComLQQ9dmJ99n2XfaOTCdTKUYBuGxJL6oVf5T4Y8CvJepySiNWwp4nAiIXv2DWAQbd0fq41ufTvn9jgnQdLhV4ziUrsSVu9BoFOKymXfTvkqDZSIWMAnmU79S0GXmBfZURmcyziJ/9Xwg9czsZoP4n1IzM70eKhZVHWwNsZR9moUK/rO7VTKDnceUXPF/GHpDPr8WJpXoG3gLgfVTICE73b4B0E0qK0q63vZ3tU3aOjF02tozDo5xzFCJZULlFryxZUYHkhSw480IZYZEMPLvssVtYlVzKrpkCc2LruADBViepFM= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR12MB3285.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(26005)(52536014)(186003)(54906003)(86362001)(6506007)(110136005)(2906002)(71200400001)(55016002)(53546011)(33656002)(4326008)(9686003)(316002)(107886003)(478600001)(66476007)(7696005)(66946007)(8676002)(5660300002)(64756008)(66556008)(8936002)(966005)(83380400001)(66446008)(76116006)(45080400002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: a0lp2bI+/3GaUcdsX+59LN1HakQZGBykPfVZf/Z8or4rc0YXFZJUjd7fip2pp7FBhikOksBxw0uaU7hdrNh9FxKf0mqHhHsLak7RZR1M8r6T5jnXRA0yDzP8enF1t0vg1iTKcHE+ME+3UfAz/44F0xz6zZHr5WXLz37CN286VDH6MVXZ8qFQNfSiEedkBdwk3D5VJ1H4+1hnPqfqYs9wsaxBz6eU7nLb6ookuUXmtg61qlbWp2Au+li7geUDqV5xyCnIO1izeMu4vIFJYDkSA8lzKQmuKXfMckRgTp4Rb4Ul5AZ4sN7KkrZWO5tSPQut2XQVgl+evoII4IgDgHskdDFUTomjZhpIdt8zS4wYO3x7U4Pz2BkJLDW58TuoXGdEul5zC4XuVDhx2HaGWIYrQy3hd98AWA61uibkzYtFEgqJ9e1ZqaSJ188rLWOyOB0HFUcpWgQV1KFEdN763FF/OVfgypd3ylPUcRFHbb8WjOZx2uFoTa9RjsG56+Erb37vAAaYxyLs/tnZ0jpCx/2zlpkXKsGADdl0cpzjrqhY6pPSIRbybvw21LzuohHvQqWm9vTb5OqyX5GSmE8y8kf11pI+0z9a5UbsQamTNMwbjWNCz4tJCmFY5IS9P55t+bU4xYfoC+h/1lmqek5NELRaXw== 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: BYAPR12MB3285.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0ccd367-0f06-4e60-bcbf-08d870283b8e X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Oct 2020 10:02:17.0809 (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: ZNd3iNnL9F/U1ah0towIXmEmsQZ3opjTfWOOuWm1JosUslITr3HCFMzt2HftSipwzmZ3WhgaiTcmzWd/xd0Y4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2597 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1602669752; bh=oZyZcxrU7g72qi8kCeoQ0vznYmfuiNyREEOY9pErfzc=; h=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-ms-exchange-transport-forked:x-microsoft-antispam-prvs: 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=ljWuYgB5nj1YY/t3gGis0+BOM2ZsoN7lvF2LtxiBu8GAzQsb246Ec6e/0nSpPo72c ppq5aRbYAi8Cht5Ui0LDTYC/adOpF6e9Dh51brX+UmAsBTKaHRlEjCB8On7afcyTS6 JOBG4AprfkodbNhJu+X5TvtGPmqK3zpPg7jZhcLQq2r4CDeD57kb4Fsv1IHP9l9ByF 7mG5ksoQznRJcDCiHCo2dd/IOZp7OIHAB9Ob+8aXtQZGJV2fLOwF924kSJlTX1gz5A +quvufkqOBQ7r+GrVg9mfZifMU+VFGHrRAtNU8DibF9Lr4N/799lGOY9fa/gVpvI7D 8HtiwWXSivThg== Subject: Re: [dpdk-dev] [PATCH v3 1/2] eal/windows: add pthread mutex lock 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 DmitryM, Naty, We would like to know if the macro added below for PTHREAD_MUTEX_INITIALIZE= R is a safe initialization of a CRITICAL_SECTION. Can you please review the code and explanation below and check it internall= y? =20 > Subject: Re: [dpdk-dev] [PATCH v3 1/2] eal/windows: add pthread mutex > lock >=20 > External email: Use caution opening links or attachments >=20 >=20 > Hi Dmitry, >=20 > Thank you very much. > I also got some messages that they wish the PTHREAD_MUTEX_INITIALIZER > macro can also be supported. >=20 > Refer to [1], we found that with critical section solution, maybe the mac= ro > can be defined as this: > #define PTHREAD_MUTEX_INITIALIZER {(void*)-1,-1,0,0,0,0} >=20 > We have tested that works, so I would prefer to add that if the macro is = also > OK with you. > What do you think about that? >=20 > The explanation from [1]: > " The pthreads API has an initialization macro that has no correspondence= to > anything in the windows API. By investigating the internal definition of = the > critical section type, one may work out how to initialize one without cal= ling > InitializeCriticalSection(). The trick here is that InitializeCriticalSec= tion() is not > allowed to fail. It tries to allocate a critical section debug object, bu= t if no > memory is available, it sets the pointer to a specific value. (One would = expect > that value to be NULL, but it is actually (void *)-1 for some reason.) Th= us we > can use this special value for that pointer, and the critical section cod= e will > work. >=20 > The other important part of the critical section type to initialize is th= e number > of waiters. This controls whether or not the mutex is locked. Fortunately= , this > part of the critical section is unlikely to change. Apparently, many prog= rams > already test critical sections to see if they are locked using this value= , so > Microsoft felt that it was necessary to keep it set at -1 for an unlocked= critical > section, even when they changed the underlying algorithm to be more > scalable. The final parts of the critical section object are unimportant,= and can > be set to zero for their defaults." >=20 > [1] > https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Flockl > essinc.com%2Farticles%2Fpthreads_on_windows%2F&data=3D02%7C01% > 7Ctalshn%40nvidia.com%7C4533970f5c964751eeea08d86b3483e3%7C43083d > 15727340c1b7db39efd9ccc17a%7C0%7C0%7C637377220576713708&sdat > a=3DqELFpXSw7%2Fk8m9FMIidiQsnTq%2BeyJRII8C1sDyrHJe4%3D&reserv > ed=3D0 >=20 > BR, > SuanmingMou >=20 > > -----Original Message----- > > From: Dmitry Kozlyuk > > Sent: Thursday, October 8, 2020 12:54 AM > > To: Suanming Mou > > Cc: Narcisa Ana Maria Vasile ; Dmitry > > Malloy ; Pallavi Kadam > > ; dev@dpdk.org > > Subject: Re: [PATCH v3 1/2] eal/windows: add pthread mutex lock > > > > On Wed, 7 Oct 2020 22:17:28 +0800, Suanming Mou wrote: > > > Add pthread mutex lock as it is needed for the thread safe rte_flow > > > functions. > > > > > > Signed-off-by: Suanming Mou > > > > Acked-by: Dmitry Kozlyuk