From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8B8DFA0C43; Wed, 18 Aug 2021 21:42:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EF184069C; Wed, 18 Aug 2021 21:42:52 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2066.outbound.protection.outlook.com [40.107.223.66]) by mails.dpdk.org (Postfix) with ESMTP id 97D0940140 for ; Wed, 18 Aug 2021 21:42:50 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fAisyy3kzznbwg7CM0m6ULq3PR5CT48Gd4twQ79uUx0dsG/k4MA1KlBtImC8cLmI/AO8SXRA8+adcsxaxubw3gzqtc+Gv1Tw7fsCCtRNq0wif/NiBeh1iHA/JuLKU9I5gmLQmNH0hnJBGLdj5p+3mcPjpCqlhT+06hH3Qwp9k9wox4c6aJD3d9t6gLnWpH4AWq69H7dS+ZBewjthKB24G6lSiaNBdwnjXf1Hxer9ujXsAGudL6qevUcIykrJAau9H8TVOza7yOiBvrvn6ArYwUSkmApfmoa3iOgBrCyDF+yuGwvJshxMWQFZ5pIMvbJu+lT2udX9VK6UnvFBilhi3A== 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=cZt7o21wfoRHEWYviY/X08oorWMVSPbAPimfDlh4sp0=; b=HTpOwOkxhVibCTABrQR5U2l+NuZxuLmUGe3QiMsR4FBjiETmenW5vdZIP0zcyuREehnw3an89++akcogkeds8qHYR6FnJ4hQYveQ1vFElVOQHPcx99OtKIZrZngwL8zBnT8la+dM2evcl08yUBqdgVV/WO7+8sEQjKEY9RZm2tVZ6hM0ZkG9cnWn3xmskCdC1CsxzD45AHZs+k6421X2w7wsibOk5mY7pWKm8wDG+VyNqs+Pzrtx8cyETCiuD42cKLaRTHeTitYanU0yCQ2l7/LH6925uwNs1akALPFUZatRMxhJ8Tr1tUNQPMi6fn2MWPSyL6J0ZatR2cXa8Krl8Q== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cZt7o21wfoRHEWYviY/X08oorWMVSPbAPimfDlh4sp0=; b=Rbtq5VmaTR0shoDu4w6E8YPC8UjAFJlX1XNWFiO480Ka92YkQ3NcE+TUYC2+Y+208FbUuRakMKalVbO291FQh55DXiaguN24uTLNAq2O5r4BRExdEZc8qk/UP1eXK2pBMoqZj+mZYjSGQqcVUJqtTyuufHB3Ses+y3L/lps3xdnpc2mKKEMWe9t4jFtDH4klR7blKewfBIVrvN6lyr5o7I+VG+Zo/y9tVy80x3d+owmsqARjrNGjMudA0AsypO0AGoiQWNELT5rlUn61FVOTCuJIuH07vf7YTziHXwoKyB1ekLYlxOu7FMgHoEj20MzXjo13Bn2FD+NMPuU+cMRk2Q== Received: from DM4PR12MB5389.namprd12.prod.outlook.com (2603:10b6:5:39a::7) by DM4PR12MB5118.namprd12.prod.outlook.com (2603:10b6:5:391::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.15; Wed, 18 Aug 2021 19:42:48 +0000 Received: from DM4PR12MB5389.namprd12.prod.outlook.com ([fe80::6823:63cc:f7d6:dd00]) by DM4PR12MB5389.namprd12.prod.outlook.com ([fe80::6823:63cc:f7d6:dd00%8]) with mapi id 15.20.4415.024; Wed, 18 Aug 2021 19:42:48 +0000 From: Tal Shnaiderman To: Narcisa Ana Maria Vasile , "dev@dpdk.org" , NBU-Contact-Thomas Monjalon , "dmitry.kozliuk@gmail.com" , Khoa To , "navasile@microsoft.com" , "dmitrym@microsoft.com" , "roretzla@microsoft.com" , "ocardona@microsoft.com" CC: "bruce.richardson@intel.com" , "david.marchand@redhat.com" , "pallavi.kadam@intel.com" Thread-Topic: [PATCH v3 1/6] eal: add function that sets thread name Thread-Index: AQHXlDcitXsP/4jIPkaw2jPfz+Rdtqt5qGbg Date: Wed, 18 Aug 2021 19:42:48 +0000 Message-ID: References: <1624067878-2130-1-git-send-email-navasile@linux.microsoft.com> <1629294247-5207-1-git-send-email-navasile@linux.microsoft.com> <1629294247-5207-2-git-send-email-navasile@linux.microsoft.com> In-Reply-To: <1629294247-5207-2-git-send-email-navasile@linux.microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linux.microsoft.com; dkim=none (message not signed) header.d=none;linux.microsoft.com; dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d1740dcc-f1e5-47bc-0ddf-08d962805bc8 x-ms-traffictypediagnostic: DM4PR12MB5118: x-ld-processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: bKhwMvpivpyN+bSruBDR4JoM7UwDE7VavsGDJzN/7rPWoSt9N6YqO2p+ncvY4uw2Fetfua+6zTMU1p1Y0oCAE+04EzcoItq2lfkUDBlwsa9qEOmvy768eifN+OekNhl+WPYxkZ3xqBO1lvWVoxPOMfBZ4oIiOBDMJoemmFyPVU+62ER/ttyBSCZuRgZxe8a7+b3DCfMeFl1LXaEhvdbEgcs+uxV6/iMMSjha4/hloo38I96cWFW42GTjQWzYrMRI0VhIgU8i0hiS5FHMvt/GJmsTMdggE01TuTFSiDAwqVpQb64rAXb3HxathQyUkReAP3nwdnI0hV4JOTUHVM5yBb51ivim0P28s8EluWx/xl0ifHXP2Sz8oAdFLS5AG3GHOjo2yYJ9V83wZnDAyL7YJqqL+LBohkRcfO/pCavctRJvR/pT1kZQOkjSmAURAmGv6wEXD5hzFE//wXdFWtIhtBU9TBbSb4p7Bk184ypNQUQKts+D7vZ7+xojXVXvPya2VLN+/+6r5FbO0cLa12hwAq5p9g6JyGRHyNm777x3YC/cYXRcsfVgIDzWMbARsKVEIVkLOQf39GaV6ugG/Wucoash9cMjglhe5o9wWLjauvWzgA3NTXnj+OoGKzHSeD+fqI8WGudWXgA1WiAC2hmtuO7x/cEdeq1I+jY3gApPYdjRyV4zBjtBcWMx8GV5Ed5OSvUnIylH4Um6/VhHRmxCpQ== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR12MB5389.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(5660300002)(6506007)(38070700005)(55016002)(33656002)(66946007)(7416002)(316002)(122000001)(52536014)(508600001)(9686003)(38100700002)(8936002)(83380400001)(71200400001)(86362001)(54906003)(26005)(8676002)(76116006)(110136005)(4326008)(66446008)(7696005)(64756008)(66556008)(2906002)(66476007)(186003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?i65BJYfsX6HacGRwvh7Vuq9LB5zl/8LJ/B6Dmz9nJg/wAj5V9TQwmnS5vdcV?= =?us-ascii?Q?AeUNoRj0OmwIjLkQwYSTPXmIfbwBKTwfu2vsUTeV1OwYFbVWaoxIL0r8jpMi?= =?us-ascii?Q?62t8yIAu+FnkNqqbFZhNbtFqqKokdmwHwolR9PvRhIvAJ4lbUqRV+PEn9u+0?= =?us-ascii?Q?lUJ23jTIFSJS2agP8U+0g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q?SrcynW/6uJXkwmuAReppSmEkL6Bc5Ks01oDwWCZXocvNJAQ3xoOhSE80GESs?= =?us-ascii?Q?A5R3H5O/6BhJahzSx0KatJ9V5As9z+M+8Wooi1xWXQODrdAZ/rYkk8IOoVUD?= =?us-ascii?Q?P4xRCn19zq9UIOj8dclVyrslC8GhaCMxIEnS6vEcB84vn5NHrAE4N8GtKks5?= =?us-ascii?Q?k0xaa/iNbIM7gwaenZ0UXRa8gqQygOAsSytizca/oMcLD9jkUS/ywkKumzRD?= =?us-ascii?Q?prg=3D?= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5389.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1740dcc-f1e5-47bc-0ddf-08d962805bc8 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Aug 2021 19:42:48.4261 (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: ZVb97gZq+nDi6yq/riLA54YFC2DK6DnAHHrZuR0V6ewJp1pU3XzqKlNdtNXiuWW3mwmddcUqVbncq7c5mTSl2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5118 Subject: Re: [dpdk-dev] [PATCH v3 1/6] eal: add function that sets thread name X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" > Subject: [PATCH v3 1/6] eal: add function that sets thread name >=20 > External email: Use caution opening links or attachments >=20 >=20 > From: Narcisa Vasile >=20 > Implement function that sets the name of a thread. > On Windows, SetThreadDescription() is used. Use GetProcAddress() to obtai= n > the address of the function for MinGW compatibility. >=20 > Signed-off-by: Narcisa Vasile > --- > lib/eal/common/rte_thread.c | 17 +++++++++ lib/eal/include/rte_thread.= h | > 16 +++++++++ > lib/eal/version.map | 1 + > lib/eal/windows/rte_thread.c | 68 > ++++++++++++++++++++++++++++++++++++ > 4 files changed, 102 insertions(+) > +RTE_INIT(rte_thread_description_ptr_init) > +{ > + HMODULE kernel_lib =3D NULL; > + static const char library_name[] =3D "kernel32.dll"; > + static const char function[] =3D "SetThreadDescription"; > + > + kernel_lib =3D LoadLibraryA(library_name); > + if (kernel_lib =3D=3D NULL) { > + (void)thread_log_last_error("LoadLibraryA(\"kernel32.dll\= ")"); > + return; > + } > + > + SetThreadDescription_ptr =3D (SetThreadDescription_type)( > + (void *)GetProcAddress(kernel_lib, function)); > + if (SetThreadDescription_ptr =3D=3D NULL) { > + (void)thread_log_last_error("GetProcAddress(\"kernel32.dl= l\", > \"SetThreadDescription\")"); > + return; You need to remove the return above to also free kernel32.dll in error flow= . > + } > + > + FreeLibrary(kernel_lib); > +} > + > +int > +rte_thread_name_set(rte_thread_t thread_id, const char *name) { > + int ret =3D 0; > + size_t count; > + HRESULT hr; > + HANDLE thread_handle =3D NULL; > + WCHAR w_name[16]; > + > + thread_handle =3D OpenThread(THREAD_SET_LIMITED_INFORMATION, > FALSE, > + thread_id.opaque_id); > + if (thread_handle =3D=3D NULL) { > + ret =3D thread_log_last_error("OpenThread()"); > + goto cleanup; > + } > + > + count =3D mbstowcs(w_name, name, RTE_DIM(w_name)); > + if (count =3D=3D (size_t) (-1)) { > + RTE_LOG(DEBUG, EAL, "Invalid thread name!\n"); > + ret =3D EINVAL; > + goto cleanup; > + } > + > + if (SetThreadDescription_ptr =3D=3D NULL) { > + RTE_LOG(DEBUG, EAL, "Invalid function pointer to > SetThreadDescription()!\n"); > + ret =3D EINVAL; > + goto cleanup; > + } > + > + hr =3D SetThreadDescription_ptr(thread_handle, w_name); > + if (FAILED(hr)) { > + ret =3D thread_log_last_error("SetThreadDescription()"); > + goto cleanup; > + } > + > +cleanup: > + if (thread_handle !=3D NULL) > + CloseHandle(thread_handle); > + return ret; > +} > + > int > rte_thread_key_create(rte_thread_key *key, > __rte_unused void (*destructor)(void *)) > -- > 2.31.0.vfs.0.1