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 2758AA0527; Mon, 20 Jul 2020 19:45:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3E3A21BFBD; Mon, 20 Jul 2020 19:45:17 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id A60B21BFBB for ; Mon, 20 Jul 2020 19:45:16 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200720174515euoutp02fc00d077310a9dc1f67e2535182e9fda~jhv1KpeM03202632026euoutp02e for ; Mon, 20 Jul 2020 17:45:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200720174515euoutp02fc00d077310a9dc1f67e2535182e9fda~jhv1KpeM03202632026euoutp02e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1595267115; bh=8Om2pOVhKkJsWmLhy0+xyZrmncYNFv+/O9hg597hqFc=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=KgcAdqXemY/KglxBvxXrZbv00Md+IkX13u8tnqx8tSwwTg5m/PYd3X1KsNKlOGW0h V2NBsIbAGJHLV88s5cw8zz6OFyM+2b5X6Esx4hEVx/klvGIYECUGxfWjXqdaZYWyfu Q75ALBphG2RVFkeRfV97o3va0S3+Nhxl5ECfflW0= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200720174514eucas1p2a78fb6ab1f5ca2390d1abdd6f69866a1~jhv0nb6Iy2304223042eucas1p24; Mon, 20 Jul 2020 17:45:14 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 06.54.05997.A28D51F5; Mon, 20 Jul 2020 18:45:14 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200720174514eucas1p26c2039eec8df7c7de037a760f27f43ff~jhv0Jedsa2720127201eucas1p2_; Mon, 20 Jul 2020 17:45:14 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200720174514eusmtrp1f0b69e73719d0eddc200fd0978644be1~jhv0IyAph1636516365eusmtrp1f; Mon, 20 Jul 2020 17:45:14 +0000 (GMT) X-AuditID: cbfec7f4-677ff7000000176d-40-5f15d82ae7d5 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 18.A2.06017.A28D51F5; Mon, 20 Jul 2020 18:45:14 +0100 (BST) Received: from [106.210.88.70] (unknown [106.210.88.70]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200720174512eusmtip17f4f30bd23d140f3bc911e810fab0200~jhvyAUchw0229102291eusmtip1i; Mon, 20 Jul 2020 17:45:11 +0000 (GMT) To: Harry van Haaren , dev@dpdk.org Cc: david.marchand@redhat.com, igor.romanov@oktetlabs.ru, honnappa.nagarahalli@arm.com, ferruh.yigit@intel.com, nd@arm.com, aconole@redhat.com From: Lukasz Wojciechowski Message-ID: <36874208-5a95-715b-aa15-9af41bdc1c54@partner.samsung.com> Date: Mon, 20 Jul 2020 19:45:11 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200720143829.46280-1-harry.van.haaren@intel.com> Content-Transfer-Encoding: 8bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEKsWRmVeSWpSXmKPExsWy7djPc7paN0TjDS6cNbD49eYBu8X2FV1s Fu8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wBqlZ1OUX1qSqpCRX1xiqxRtaGGkZ2hpoWdkYqlnaGwea2VkqqRvZ5OSmpNZllqk b5eglzH5zxX2gvXyFT8Wr2dtYDwm2cXIySEhYCKxsncacxcjF4eQwFJGiVN9K9i7GDmAEjIS Hy4JQNQIS/y51sUGUfOaUWLzji1sIAlhAR+JLVub2UFsEQF7ic9XTjOBFDELTGKU+Ne5gBWi 4ySjxIfd65hBqtgEbCWOzPzKCmLzCrhJfH06jQXEZhFQlbjefARskqhAnMTyLfPZIWoEJU7O fAJWwyngIDGn9RdYL7OAmcS8zQ+ZIWx5ieats6FscYlbT+YzTWAUmoWkfRaSlllIWmYhaVnA yLKKUSS1tDg3PbfYSK84Mbe4NC9dLzk/dxMjMAK3Hfu5ZQdj17vgQ4wCHIxKPLwfukXjhVgT y4orcw8xSnAwK4nwOp09HSfEm5JYWZValB9fVJqTWnyI0RTouYnMUqLJ+cDkkFcSb2hqaG5h aWhubG5sZqEkztshcDBGSCA9sSQ1OzW1ILUIpo+Jg1OqgZH7gS1j8ffNOys/LNfscPjB8v7N lGWetzepMLswM/rPEkmX7Eq+aV/FdcArYfbms1Nai70veYgWWRztzi5o3HFhn8Ou3QfLI9cG Xv+0Jv/YrHrZJZF/c288W/3eeH2Mi5KufMmuGnFLpz7WpNJo172H2w6yrTvzoqvy8YXt0w12 KnQrNC3Zn6TEUpyRaKjFXFScCAB0NZpR1gIAAA== X-CMS-MailID: 20200720174514eucas1p26c2039eec8df7c7de037a760f27f43ff X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200720143731eucas1p13c21beb109b2b6896a2ca6ca43059d1b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200720143731eucas1p13c21beb109b2b6896a2ca6ca43059d1b References: <20200720120938.34660-1-harry.van.haaren@intel.com> <20200720143829.46280-1-harry.van.haaren@intel.com> Subject: Re: [dpdk-dev] [PATCH v2 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" W dniu 20.07.2020 o 16:38, Harry van Haaren pisze: > 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. > > 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. > > Suggested-by: Lukasz Wojciechowski > Signed-off-by: Harry van Haaren > > --- > > Thanks for feedback Lukasz, please have a look and see if this was > what you were expecting? > > Honnappa/Phil, are the __atomic_load/store's correct? > > --- > lib/librte_eal/common/rte_service.c | 14 ++++++++++++++ > lib/librte_eal/include/rte_service.h | 9 +++++++++ > lib/librte_eal/rte_eal_version.map | 1 + > 3 files changed, 24 insertions(+) > > diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c > index 6a0e0ff65..4c276b006 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; > @@ -457,6 +458,8 @@ service_runner_func(void *arg) > const int lcore = rte_lcore_id(); > struct core_state *cs = &lcore_states[lcore]; > > + __atomic_store_n(&cs->thread_active, 1, __ATOMIC_RELAXED); > + > /* runstate act as the guard variable. Use load-acquire > * memory order here to synchronize with store-release > * in runstate update functions. > @@ -475,9 +478,20 @@ service_runner_func(void *arg) > cs->loops++; > } > > + __atomic_store_n(&cs->thread_active, 0, __ATOMIC_RELAXED); > return 0; > } > > +int32_t > +rte_service_lcore_active(uint32_t lcore) > +{ > + if (lcore >= RTE_MAX_LCORE || !lcore_states[lcore].is_service_core) > + return -EINVAL; > + > + return __atomic_load_n(&lcore_states[lcore].thread_active, > + __ATOMIC_RELAXED); > +} > + > 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..f7134b5c0 100644 > --- a/lib/librte_eal/include/rte_service.h > +++ b/lib/librte_eal/include/rte_service.h > @@ -261,6 +261,15 @@ int32_t rte_service_lcore_start(uint32_t lcore_id); > */ > int32_t rte_service_lcore_stop(uint32_t lcore_id); > > +/** > + * Reports if a service lcore is currently running. > + * @retval 0 Service thread is not active, and has been returned to EAL. > + * @retval 1 Service thread is in the service core polling loop. > + * @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; > }; Acked-by: Lukasz Wojciechowski -- Lukasz Wojciechowski Principal Software Engineer Samsung R&D Institute Poland Samsung Electronics Office +48 22 377 88 25 l.wojciechow@partner.samsung.com