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 B5BD7A0526; Wed, 22 Jul 2020 23:39:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C98B51BFBB; Wed, 22 Jul 2020 23:39:33 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50058.outbound.protection.outlook.com [40.107.5.58]) by dpdk.org (Postfix) with ESMTP id CDA0C1BF7B for ; Wed, 22 Jul 2020 23:39:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V+EJ9MzZ8UcyShvkHOGC5oPYn14KrI4YJ8o/ZQxLn+s=; b=r1BidPoC5JXLAOJEhAiWoaph4BxxdOJpMFe5ZpeQ4lauryNI1YoPjzjSFjjVH41HugF3fSe5JBUTZfOja9GL0SnDQ3t22lX2UHML1dRPVIvByNp4+aBbaZkN/TSBUCcrlMF/it3vFaPKrch0veDVISpXtkgpRc5fHMZ8J29bdIk= Received: from DB6PR0301CA0061.eurprd03.prod.outlook.com (2603:10a6:4:54::29) by VI1PR08MB3981.eurprd08.prod.outlook.com (2603:10a6:803:ed::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18; Wed, 22 Jul 2020 21:39:30 +0000 Received: from DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:54:cafe::8b) by DB6PR0301CA0061.outlook.office365.com (2603:10a6:4:54::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.22 via Frontend Transport; Wed, 22 Jul 2020 21:39:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT031.mail.protection.outlook.com (10.152.20.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.10 via Frontend Transport; Wed, 22 Jul 2020 21:39:30 +0000 Received: ("Tessian outbound c4059ed8d7bf:v62"); Wed, 22 Jul 2020 21:39:30 +0000 X-CR-MTA-TID: 64aa7808 Received: from 850e5d3c1928.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7D65B223-33CC-4E1A-B3F8-C93E265E3C09.1; Wed, 22 Jul 2020 21:39:25 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 850e5d3c1928.3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 22 Jul 2020 21:39:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KucW5GvF68c8WgbVbyF5ubzpMOzdVrM2xOuGNyo8kOpDU1dmktGhX181H7WpoyxPCl/XxH9TWiv9hTh2ySck5M/XYetHZub+4mXy1vR2S7JwajXFLPtbq+xPB6gLU8fI11rIKo3XtiSbv5LVcAFVl+/ZMFirCstG0qREjJijRgfjZw99aQnQ4tUuBjSc/Mtt/5xYG1dADyfbhIDOPXOn6Ds65+qB7pIwcWu1upc2VdJ6NV9+WX+TwKg4gBqVT6+NIiWQRC2ui5rahQ0OL9QV/xK2VS9ihIl2Yugfi5KTy/00DK6mgHx3B7pRkYCFMOrvIcJDGfkBYn/eAL1SVGUyZg== 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=V+EJ9MzZ8UcyShvkHOGC5oPYn14KrI4YJ8o/ZQxLn+s=; b=CqVQztWOh0luDIMkJfk5W5GFPnCXl4gbVzG3XAtkPAuWJ8coN/AaYGifTVqtR4B2NeWpMu3jS3YA6kcPKsNLoJHV1D84g1NzAk9X2ysJkJG3CdTxPmxq+GxmcfIcef62YK4kFnr99YjYOVZreJ5FfaHf1hrmKOHKOHxobX3RuFgBS4YJlSHlW5ZWgvSJc9LpXXy1en/B6qtXzKZnuMrexFCIIq1oasoes+hvUQZPfzdamBdFyf3/IRjVwe4e53YFhBupP3/IY/l4SmNjF4NwX0sdWNKhH6S8svBPfWH7hiWu/SQLC7iO5eAoITJO3EJvKVPtvHb7GqHapHRW0b/0zg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V+EJ9MzZ8UcyShvkHOGC5oPYn14KrI4YJ8o/ZQxLn+s=; b=r1BidPoC5JXLAOJEhAiWoaph4BxxdOJpMFe5ZpeQ4lauryNI1YoPjzjSFjjVH41HugF3fSe5JBUTZfOja9GL0SnDQ3t22lX2UHML1dRPVIvByNp4+aBbaZkN/TSBUCcrlMF/it3vFaPKrch0veDVISpXtkgpRc5fHMZ8J29bdIk= Received: from DB6PR0802MB2216.eurprd08.prod.outlook.com (2603:10a6:4:85::9) by DB8PR08MB4105.eurprd08.prod.outlook.com (2603:10a6:10:b0::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.23; Wed, 22 Jul 2020 21:39:23 +0000 Received: from DB6PR0802MB2216.eurprd08.prod.outlook.com ([fe80::9d1d:207b:e89d:199d]) by DB6PR0802MB2216.eurprd08.prod.outlook.com ([fe80::9d1d:207b:e89d:199d%10]) with mapi id 15.20.3195.028; Wed, 22 Jul 2020 21:39:23 +0000 From: Honnappa Nagarahalli To: Harry van Haaren , "dev@dpdk.org" CC: "david.marchand@redhat.com" , "igor.romanov@oktetlabs.ru" , "ferruh.yigit@intel.com" , nd , "aconole@redhat.com" , "l.wojciechow@partner.samsung.com" , Phil Yang , Honnappa Nagarahalli , nd Thread-Topic: [PATCH v3 1/2] service: add API to retrieve service core active Thread-Index: AQHWYBP1HnOlVWXjVE2oOAlHdmWMxakUGZhw Date: Wed, 22 Jul 2020 21:39:22 +0000 Message-ID: References: <20200720143829.46280-1-harry.van.haaren@intel.com> <20200722103701.7244-1-harry.van.haaren@intel.com> In-Reply-To: <20200722103701.7244-1-harry.van.haaren@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 2a693f79-7381-4c00-b816-233b2380c8f3.0 x-checkrecipientchecked: true Authentication-Results-Original: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=arm.com; x-originating-ip: [217.140.111.135] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9ebd88c7-8b61-44a6-98ea-08d82e87b758 x-ms-traffictypediagnostic: DB8PR08MB4105:|VI1PR08MB3981: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:2399;OLM:2399; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ipBCTHo14CULFpgVTSSqxw6B1OwOi71Li3wJ11NHT8gGYkDzr13qgitNR2L08i0pdnUY78JHu43itsI4umTreuNcwOtOb3dhrJ4Y8jb0vUHz0HKFURyf1Ita2X2X8KlElRJUEgbl3HBdpWl4MhMAd2v9qUUH+Qc0AxN1vapUayVHa4K9FiakLHl82AReUSKm47B/+38y7VJC1qwsELylY6EjcPH1jGC02iyj8YtIG4ZyCkp65YRjOq9txiX4N+uuJN/p/B3tdEQ1stwT1Cn3WnMwtcbLpWuS3MDVUQmU73Js10jsnHOw0JeQk2lOOyTXVmLg31PWhOmVBNQqssvC+VH0b2yfpdye1qrE2+Tcig0vFx/jQHdsW/cfZca+teEc X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB6PR0802MB2216.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(376002)(136003)(396003)(366004)(346002)(39860400002)(316002)(9686003)(86362001)(8936002)(6506007)(55016002)(7696005)(71200400001)(186003)(4326008)(66946007)(66556008)(64756008)(66446008)(110136005)(52536014)(5660300002)(76116006)(2906002)(54906003)(8676002)(26005)(478600001)(66476007)(33656002)(83380400001)(87944003); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: WK+VfNmpmtwjnTPE7IOFZTcGyNwTmGKm9097F6sBtOE5JNSLActo3LncZomlCXWojcjgG/LrbSa7w2JkpQ6vdMHw3l3kaG0OZsSHJjc/2Q0onV5772EE5zCBt33ZV/danBOSJawbr60GJRq47n9vpbdm7ksxSbwwzHUIbP2QRnP0jKhy22tk3gaTQKdpHoF25wlOFKIxwORGS3u41AbFvulhHGO5Zd4SHWUsRy1ZFNGisqxsHHxlYwoDwk5oPCepsDWKqC8ER9oWCB4SFuBnOIYM/1PhMD5xS9olyPAZNKSHmMNrTp9Qfh5K/PfISUyQzVbAXViDsQqA12zhz9F0dQUip5JBBvY4EEI6WiZKYyXirgrIp2ufLU+zi1ICla0M3yQqnwrPrXFxxFrqwI5hM2M9DxhqwYEt2bQfKEJRBU8DRyZljtWn8y/Nu3V7lnzS8UqBgr9hyjxTXEwvmvbUR82FO4My7PSWla0Edoxdhsw0NvV6HuMUsePHL1yqoyBt Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB4105 Original-Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5ca7242e-b742-40bc-056e-08d82e87b2fe X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D0jLsalS6BddBxmh9QipJIEjAYmRZG+bU0YOqjZRsVhkhM4II17cSxRXtHlCaE7K1jBXsjee9jhazDN3h0M+nkAFnb27GgjENIUXIrMYLOG+vaZGUOx9smlL+ki+aWE0ShjShkoAfiSGQYF70Ni16BKaZTzPFUAOmXbWlHNq66LX4HPGpc1xC7zlO9trwpca58E9L8YS1oFrho/7kPeIwS78v5ZXLWD9zT9hXzPgla4AWl9p9U8cVXNpF1Sqx2aXis0WheRPlbbSOKWRDbPnO9Bcae6+7XLkPQ/Hubf7rijG0n4o47QxzKOZ5ve7qmC6J08DDmMdWpXnnTy85xHfXNh/LpQIqrutgXyFRo50HXDVe5ABuF0nPcbX0RZAUmzJuFx+Pd6IyJHBRjs/LFLAH/crkpwZeCEYbrA4V96yfHU= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(346002)(396003)(136003)(376002)(46966005)(8676002)(110136005)(54906003)(26005)(186003)(82740400003)(70586007)(83380400001)(7696005)(478600001)(70206006)(6506007)(4326008)(47076004)(5660300002)(9686003)(33656002)(2906002)(52536014)(82310400002)(81166007)(316002)(356005)(55016002)(8936002)(336012)(86362001)(87944003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2020 21:39:30.4354 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ebd88c7-8b61-44a6-98ea-08d82e87b758 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3981 Subject: Re: [dpdk-dev] [PATCH v3 1/2] service: add API to retrieve service core active 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" > Subject: [PATCH v3 1/2] service: add API to retrieve service core active >=20 > This commit adds a new experimental API which allows the user to retrieve > the active state of an lcore. Knowing when the service lcore is completed= its > polling loop can be useful to applications to avoid race conditions when = e.g. > finalizing statistics. >=20 > The service thread itself now has a variable to indicate if its thread is= active. > When zero the service thread has completed its service, and has returned > from the service_runner_func() function. >=20 > Suggested-by: Lukasz Wojciechowski > Signed-off-by: Harry van Haaren > Reviewed-by: Phil Yang Over all looks good, few nits inline. Reviewed-by: Honnappa Nagarahalli >=20 > --- >=20 > v3: > - Change service lcore stores to SEQ_CST (Honnappa, David) > - Change control thread load to ACQ (Honnappa, David) > - Comment reasons for SEQ_CST/ACQ (Honnappa, David) > - Add comments to Doxygen for _stop() and _lcore_active() (Honnappa, Davi= d) > - Add Phil's review tag from ML > --- > lib/librte_eal/common/rte_service.c | 23 ++++++++++++++++++++++- > lib/librte_eal/include/rte_service.h | 20 +++++++++++++++++++- > lib/librte_eal/rte_eal_version.map | 1 + > 3 files changed, 42 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_eal/common/rte_service.c > b/lib/librte_eal/common/rte_service.c > index 6a0e0ff65..b0cf7c4ab 100644 > --- a/lib/librte_eal/common/rte_service.c > +++ b/lib/librte_eal/common/rte_service.c > @@ -65,6 +65,7 @@ struct core_state { > /* map of services IDs are run on this core */ > uint64_t service_mask; > uint8_t runstate; /* running or stopped */ > + uint8_t thread_active; /* indicates when thread is in service_run() */ > uint8_t is_service_core; /* set if core is currently a service core */ > uint8_t service_active_on_lcore[RTE_SERVICE_NUM_MAX]; > uint64_t loops; > @@ -422,7 +423,7 @@ rte_service_may_be_active(uint32_t id) > return -EINVAL; >=20 > for (i =3D 0; i < lcore_count; i++) { > - if (lcore_states[ids[i]].service_active_on_lcore[id]) > + if (lcore_states[ids[i]].service_active_on_lcore[id]) nit, I think the is required here. > return 1; > } >=20 > @@ -457,6 +458,8 @@ service_runner_func(void *arg) > const int lcore =3D rte_lcore_id(); > struct core_state *cs =3D &lcore_states[lcore]; >=20 > + __atomic_store_n(&cs->thread_active, 1, __ATOMIC_SEQ_CST); > + > /* runstate act as the guard variable. Use load-acquire > * memory order here to synchronize with store-release > * in runstate update functions. > @@ -475,9 +478,27 @@ service_runner_func(void *arg) > cs->loops++; > } >=20 > + /* Use SEQ CST memory ordering to avoid any re-ordering around > + * this store, ensuring that once this store is visible, the service > + * lcore thread really is done in service cores code. > + */ > + __atomic_store_n(&cs->thread_active, 0, __ATOMIC_SEQ_CST); > return 0; > } >=20 > +int32_t > +rte_service_lcore_active(uint32_t lcore) { > + if (lcore >=3D RTE_MAX_LCORE || !lcore_states[lcore].is_service_core) > + return -EINVAL; > + > + /* Load thread_active using ACQUIRE to avoid instructions dependent > on > + * the result being re-ordered before this load completes. > + */ > + return __atomic_load_n(&lcore_states[lcore].thread_active, > + __ATOMIC_ACQUIRE); > +} > + > int32_t > rte_service_lcore_count(void) > { > diff --git a/lib/librte_eal/include/rte_service.h > b/lib/librte_eal/include/rte_service.h > index e2d0a6dd3..84245020d 100644 > --- a/lib/librte_eal/include/rte_service.h > +++ b/lib/librte_eal/include/rte_service.h > @@ -249,7 +249,9 @@ int32_t rte_service_lcore_start(uint32_t lcore_id); > * Stop a service core. > * > * Stopping a core makes the core become idle, but remains assigned as = a > - * service core. > + * service core. Note that the service lcore thread may not have > + returned from > + * the service it is running when this API returns. To check if the > + service > + * lcore is still active, the *rte_service_lcore_active* API is added. nit Instead of "To check if the service lcore is still active, the *rte_service= _lcore_active* API is added.", may be "*rte_service_lcore_active* API can b= e used to check if the service lcore is still active"? > * > * @retval 0 Success > * @retval -EINVAL Invalid *lcore_id* provided @@ -261,6 +263,22 @@ > int32_t rte_service_lcore_start(uint32_t lcore_id); > */ > int32_t rte_service_lcore_stop(uint32_t lcore_id); >=20 > +/** > + * Reports if a service lcore is currently running. nit ^^^^^^^^^^^^^^^ may= be "currently running mapped services"? (matching with the documentation f= or existing APIs) > + * > + * This function returns if the core has finished service cores code, nit ^^^= ^^^^^^^^^^^^^^^^^^^ may be "completed running assigned services"? > +and has > + * returned to EAL control. If *rte_service_lcore_stop* has been called > +but > + * the lcore has not returned to EAL yet, it might be required to wait > +and call > + * this function again. The amount of time to wait before the core > +returns > + * depends on the duration of the services being run. > + * > + * @retval 0 Service thread is not active, and has been returned to EAL. nit, ^^^^^ lcore? > + * @retval 1 Service thread is in the service core polling loop. nit, may be "Service lcore is running assigned services."? (matching the te= rms used in existing APIs) > + * @retval -EINVAL Invalid *lcore_id* provided. > + */ > +__rte_experimental > +int32_t rte_service_lcore_active(uint32_t lcore_id); > + > /** > * Adds lcore to the list of service cores. > * > diff --git a/lib/librte_eal/rte_eal_version.map > b/lib/librte_eal/rte_eal_version.map > index bf0c17c23..d53d5d5b9 100644 > --- a/lib/librte_eal/rte_eal_version.map > +++ b/lib/librte_eal/rte_eal_version.map > @@ -401,6 +401,7 @@ EXPERIMENTAL { > rte_lcore_dump; > rte_lcore_iterate; > rte_mp_disable; > + rte_service_lcore_active; > rte_thread_register; > rte_thread_unregister; > }; > -- > 2.17.1