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 81B15A04A5; Tue, 16 Jun 2020 20:53:14 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 627E61BFA0; Tue, 16 Jun 2020 20:53:13 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60041.outbound.protection.outlook.com [40.107.6.41]) by dpdk.org (Postfix) with ESMTP id BB2871BF9D for ; Tue, 16 Jun 2020 20:53:12 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jmz4J2CaHtVZFV4/ApKi88D8aXsVqSMPsC5Kj9Ep3YLJ5+E1LzUk4yLJdjIeHrDPolkzSixS5yjO3R9CqeUElNy12/QNR64npeN4/SjjYzMfZrzXdaQQQJkFGbR0jf5szVN1v276pEtXrTOOshAr5c9bUBtzw7/tzYL693Jc88QSwL1KpZxhwmuiTWrlLskD79LlgYscQ4IVgs0PxpKPtHUYHB+uwJNtI6RWXENoWPsMr7s+HG3J8mbDMx30v0n3YRkadvB48qTjxM+Ju33eEF13UD7oJ5nIYweEzUEc/5bwBTz0twrYNnQUBgO0n10IcCUMuv+x33VQCm0mkQu71Q== 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=OCNPviQFvtT0RxboqavNW92NagXLgFkCJW6UzbhXEM0=; b=fmyDnrMSsc2NHFsViCgf0lckR4OgzWsuSj5wh1X0G6BJIZ3G/Xekt693lmgdcUfC1nxq5Sscl6g42Yo8QkN2Yc6A9bV9dMVMe8vUWCL/O4LjuOM1R/jC1aKEbI2uneTZV8UlufLsgbx2Vg9suTy+uWKvlQPjLE1PD3/VpheSgN2HGmyMQf8xSXXf8+DInDwjjAk4SuCR/Q39bBFWQBKk805bcL/xZ1cUOIZG03M6eO/coRTp5y7I0YPa+4NJ/3U0EnAUevySMGapeba2FQ8D4kk/d2ASay8o0SIwUm4OTuEt1Y2Dhj6/L8c1t9Yn1BsEeLAkekGAY2OPZDJzccMQBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OCNPviQFvtT0RxboqavNW92NagXLgFkCJW6UzbhXEM0=; b=RZi7Pr/Yh0JqsLv8EBgTxXOd0M1HzinXuCO0TqmYaToLQzS+HGKhyhyMtOLR1PxxgP88YdmBvqoP5NhJ/c8j90fo8eJBQvkYoALweH8dl7ih2gwN21vFjtZE2sPeVkago3f5b0aWD9zKaihW7raMbiCULRk4O7/tqDMPMLMXN9o= Received: from VI1PR05MB6128.eurprd05.prod.outlook.com (2603:10a6:803:ec::26) by VI1PR05MB4816.eurprd05.prod.outlook.com (2603:10a6:803:54::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.18; Tue, 16 Jun 2020 18:53:09 +0000 Received: from VI1PR05MB6128.eurprd05.prod.outlook.com ([fe80::e98d:c6c9:be41:86e1]) by VI1PR05MB6128.eurprd05.prod.outlook.com ([fe80::e98d:c6c9:be41:86e1%3]) with mapi id 15.20.3088.029; Tue, 16 Jun 2020 18:53:09 +0000 From: Tasnim Bashar To: Thomas Monjalon , "dmitry.kozliuk@gmail.com" CC: "dev@dpdk.org" , "harini.ramakrishnan@microsoft.com" , "pallavi.kadam@intel.com" , "ranjit.menon@intel.com" , "ocardona@microsoft.com" , "navasile@linux.microsoft.com" , Tal Shnaiderman , Fady Bader , Ophir Munk Thread-Topic: [dpdk-dev] [PATCH v3] eal/windows: fix invalid thread handle Thread-Index: AQHWOIG0Frjhw4BpeUSqtQMYBkbQ0KjZaXUAgAJAcfA= Date: Tue, 16 Jun 2020 18:53:09 +0000 Message-ID: References: <20200522001112.48932-1-tbashar@mellanox.com> <20200602020052.4540-1-tbashar@mellanox.com> <1716943.Gv3JEJsLzV@thomas> In-Reply-To: <1716943.Gv3JEJsLzV@thomas> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=none action=none header.from=mellanox.com; x-originating-ip: [2601:600:8680:3880:9d7f:8ce4:10ca:cdb4] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 866579de-2da1-4b83-16aa-08d81226837e x-ms-traffictypediagnostic: VI1PR05MB4816: x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 04362AC73B x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /O7TRzMV+xSkK3Hvs0zVc5MkdsLj792eacS5a7XfAQ1Q2Dek5Bsb6rahuj73aMqyXLDZzDiMJZPhI+zopzN9ZF0RttxrL2U4Ru6yFkG84EXOBDn1Yf1gl6fL7lvyv0ix3nuI/bCBzomowj+ypzowWxSrtllhBRmXwozhDtIzaGA78w+oyLiqk7U3AhBQEkLbf5TyX80ly54zuiTImBplBjkCbPjvqhPNsV4uAUVccjMKdz5jAhRbD6Lgd3DMXlshNWhH8mkBVlBRXxn01bo6UqmQk9V1HFUAVISQ4qIO3klGwY+pqCY7HpR5q3tCyrXMp4iibhQoIOCsTwPjo7VpdQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR05MB6128.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(110136005)(54906003)(186003)(8936002)(107886003)(5660300002)(55016002)(7696005)(52536014)(498600001)(2906002)(9686003)(6506007)(4326008)(86362001)(33656002)(66446008)(66556008)(64756008)(66946007)(66476007)(76116006)(83380400001)(71200400001)(8676002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: 9WAlZ7mL6c9eq5hDnOWGpTdyRHwbO4UgXGGgL76uUxQaVT7IL4fjJAugF1WVM/7OlaYwFKztuVPt8cgeOPwSX33Y0qQJOqnjHJUA0BROzejDeLDpXUbofTpBxCxn0TZia8P78NmpMeOLuUZx3eEFKAxECZfYDgGVRcywNLA1G5RdIt3B3o73qPZIPKyvMkDumCTTXoAdCVXsfc8/6e3w7NmtCnzMIxSKn5lR+bYKbOYicBVkVWwq/ShoWMYW256+J2txybs3kiKvyo/VgJt4NHGgyF5g5ynooBcibWHHaJWQp1rbdIHol6V4VUJYnJ7i90kKLe1zSTO66zU8iryGCaYk0zEbf5sQzeBHRp2Pu8Tnf24INBbhh0IXvwpK3Rxh9PS3mtD5r+0BWnb5T1/041YSJ+rGn0UzxM4q1ne4sN8tAPOD+uBWQ7M602VKD2Jzp3bbIM1hpPAD4hoGRCPKD5UCthJahusu6oXfg8TH6BHK8VZNUceYKDqtK2O1zyXi2W+UBuXRSJs3el2hcHEXjoR0JiVTJifrkhI4rQxX85ggTjFB9AOoVfxf1BfMF6LP Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 866579de-2da1-4b83-16aa-08d81226837e X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jun 2020 18:53:09.5162 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: U9KHp4AuamdZK0HFQrt8Ezkcx/cEvOOVnzriNF+R7ck8wS7AbOt57DOnWjRgPtosK1zhJmOPH+4lVMsziRTYSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4816 Subject: Re: [dpdk-dev] [PATCH v3] eal/windows: fix invalid thread handle 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" > From: Thomas Monjalon > 02/06/2020 04:00, Tasnim Bashar: > > Casting thread ID to handle is not accurate way to get thread handle. > > Need to use OpenThread function to get thread handle from thread ID. > > > > pthread_setaffinity_np and pthread_getaffinity_np functions for > > Windows are affected because of it. > > > > Signed-off-by: Tasnim Bashar > > --- > > v3: WA to remove warning(-Wmaybe-uninitialized) >=20 > The -Wmaybe-uninitialized warning was there before this patch. > Shouldn't it be a separate patch before this one? The warning appeared only on this patch, so we don't need to separate it >=20 > > static inline int > > -eal_get_thread_affinity_mask(pthread_t threadid, unsigned long > > *cpuset) > > +eal_get_thread_affinity_mask(pthread_t threadid, rte_cpuset_t > > +*cpuset) > > { > > /* Workaround for the lack of a GetThreadAffinityMask() > > *API in Windows > > */ > > - /* obtain previous mask by setting dummy mask */ > > - DWORD dwprevaffinitymask =3D > > - SetThreadAffinityMask((HANDLE) threadid, 0x1); > > + DWORD_PTR dwprevaffinitymask; >=20 > Please use underscores to separate parts in names. >=20 > > + HANDLE thread_handle; > > + DWORD_PTR ret; > > + > > + thread_handle =3D OpenThread(THREAD_ALL_ACCESS, FALSE, threadid); > > + if (thread_handle =3D=3D NULL) { > > + RTE_LOG_WIN32_ERR("OpenThread()"); > > + return -1; > > + } > > + > > + /* obtain previous mask by setting dummy mask */ > > + dwprevaffinitymask =3D SetThreadAffinityMask(thread_handle, 0x1); > > + if (dwprevaffinitymask =3D=3D 0) { > > + RTE_LOG_WIN32_ERR("SetThreadAffinityMask()"); > > + CloseHandle(thread_handle); > > + return -1; > > + } > > + > > /* set it back! */ > > - SetThreadAffinityMask((HANDLE) threadid, dwprevaffinitymask); > > - *cpuset =3D dwprevaffinitymask; > > + ret =3D SetThreadAffinityMask(thread_handle, dwprevaffinitymask); > > + if (ret =3D=3D 0) { > > + RTE_LOG_WIN32_ERR("SetThreadAffinityMask()"); > > + CloseHandle(thread_handle); > > + return -1; > > + } > > + memset(cpuset, 0, sizeof(rte_cpuset_t)); >=20 > Shouldn't we use RTE_CPU_ZERO instead of memset? If we use CPU_ZERO or CPU_SET, we still get the same warning! >=20 > > + *cpuset->_bits =3D dwprevaffinitymask; > > + CloseHandle(thread_handle); > > return 0; > > } >=20 >=20