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 D632CA0547; Fri, 12 Feb 2021 17:58:26 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 548F322A2AC; Fri, 12 Feb 2021 17:58:26 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 46B0822A2AB for ; Fri, 12 Feb 2021 17:58:24 +0100 (CET) IronPort-SDR: uVse3fUR3u9DQL5eBhCCJ+C5kggn5KuBaAiZpaO0DXfNj/R7h0xfD5CBy/ao8XoaSD2ibaOv8L gDVGO9KQR6Aw== X-IronPort-AV: E=McAfee;i="6000,8403,9893"; a="182511455" X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="182511455" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2021 08:58:22 -0800 IronPort-SDR: rJ4b3Y3+He3/NSx9sB1fymXcGS+j9lktFwrPYr/OfKaWb8ldlni2dTfTLGi5o7h3IMN8ovkET8 1iXyjojIlTSg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,174,1610438400"; d="scan'208";a="360466416" Received: from silpixa00400633.ir.intel.com ([10.237.213.44]) by orsmga003.jf.intel.com with ESMTP; 12 Feb 2021 08:58:21 -0800 From: Harry van Haaren To: dev@dpdk.org Cc: david.marchand@redhat.com, mattias.ronnblom@ericsson.com, honnappa.nagarahalli@arm.com, Harry van Haaren Date: Fri, 12 Feb 2021 16:58:12 +0000 Message-Id: <20210212165814.2189305-1-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 1/3] service: add component useful work attribute 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" This commit adds a new attribute which allows the service to indicate if the previous iteration of work was "useful". Useful work here implies forward progress was made. Exposing this information via an attribute to the application allows tracking of CPU cycles as being useful or not-useful, and a CPU load estimate can be deduced from that information. Signed-off-by: Harry van Haaren --- lib/librte_eal/common/rte_service.c | 19 +++++++++++++++++++ lib/librte_eal/include/rte_service.h | 5 +++++ .../include/rte_service_component.h | 13 +++++++++++++ lib/librte_eal/version.map | 3 +++ 4 files changed, 40 insertions(+) diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c index bd8fb72e78..8595555fc3 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -58,6 +58,7 @@ struct rte_service_spec_impl { uint32_t num_mapped_cores; uint64_t calls; uint64_t cycles_spent; + uint8_t useful_work_last_iter; } __rte_cache_aligned; /* the internal values of a service core */ @@ -294,6 +295,21 @@ rte_service_component_unregister(uint32_t id) return 0; } +int32_t +rte_service_component_attr_set(uint32_t id, uint32_t attr, uint64_t value) +{ + struct rte_service_spec_impl *s; + SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL); + + switch (attr) { + case RTE_SERVICE_ATTR_USEFUL_WORK_LAST_ITER: + s->useful_work_last_iter = value; + return 0; + default: + return -EINVAL; + }; +} + int32_t rte_service_component_runstate_set(uint32_t id, uint32_t runstate) { @@ -799,6 +815,9 @@ rte_service_attr_get(uint32_t id, uint32_t attr_id, uint64_t *attr_value) return -EINVAL; switch (attr_id) { + case RTE_SERVICE_ATTR_USEFUL_WORK_LAST_ITER: + *attr_value = s->useful_work_last_iter; + return 0; case RTE_SERVICE_ATTR_CYCLES: *attr_value = s->cycles_spent; return 0; diff --git a/lib/librte_eal/include/rte_service.h b/lib/librte_eal/include/rte_service.h index ca9950d091..d50b5c8d7a 100644 --- a/lib/librte_eal/include/rte_service.h +++ b/lib/librte_eal/include/rte_service.h @@ -390,6 +390,11 @@ int32_t rte_service_dump(FILE *f, uint32_t id); */ #define RTE_SERVICE_ATTR_CALL_COUNT 1 +/** + * Returns if the last iteration of the service resulted in useful work done. + */ +#define RTE_SERVICE_ATTR_USEFUL_WORK_LAST_ITER 2 + /** * Get an attribute from a service. * diff --git a/lib/librte_eal/include/rte_service_component.h b/lib/librte_eal/include/rte_service_component.h index 9e66ee7e29..534f41f531 100644 --- a/lib/librte_eal/include/rte_service_component.h +++ b/lib/librte_eal/include/rte_service_component.h @@ -87,6 +87,19 @@ int32_t rte_service_component_register(const struct rte_service_spec *spec, */ int32_t rte_service_component_unregister(uint32_t id); +/** + * Set an attribute for this service. + * + * Note this API is to be called by the service implementation, to make the + * statistic available via the usual attr_get() service APIs. + * + * @retval 0 Success + * @retval -EINVAL Invalid service id or attribute provided + */ +__rte_experimental +int32_t rte_service_component_attr_set(uint32_t id, uint32_t attr, + uint64_t value); + /** * Private function to allow EAL to initialized default mappings. * diff --git a/lib/librte_eal/version.map b/lib/librte_eal/version.map index fce90a112f..e60eaa3dd9 100644 --- a/lib/librte_eal/version.map +++ b/lib/librte_eal/version.map @@ -412,6 +412,9 @@ EXPERIMENTAL { rte_thread_tls_key_delete; rte_thread_tls_value_get; rte_thread_tls_value_set; + + # added in 21.05 + rte_service_component_attr_set; }; INTERNAL { -- 2.25.1