From patchwork Mon Sep 14 14:37:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Van Haaren, Harry" X-Patchwork-Id: 77630 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 613F7A04C7; Mon, 14 Sep 2020 16:36:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 46DAF1C0DB; Mon, 14 Sep 2020 16:36:22 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 5C32F1C0D2 for ; Mon, 14 Sep 2020 16:36:20 +0200 (CEST) IronPort-SDR: 4yHoS9YDsnyAkeRvioiYW8tWGWfX7YBfjfA+wU2REgt/sw3QfgvxHDk10rxJ8qnvpHL7yHq7Ct pQN0eDQVZ6PQ== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="223269464" X-IronPort-AV: E=Sophos;i="5.76,426,1592895600"; d="scan'208";a="223269464" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 07:36:16 -0700 IronPort-SDR: DToorJzHwCE9VJAwWu+kIohHVCq0KrWJVicvQfmbIvGygKe9WK5rN1R0Kxf3Wx3qP1ooGE8PAG lat2fy23Es+w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,426,1592895600"; d="scan'208";a="301770375" Received: from silpixa00399779.ir.intel.com (HELO silpixa00399779.ger.corp.intel.com) ([10.237.222.209]) by orsmga003.jf.intel.com with ESMTP; 14 Sep 2020 07:36:14 -0700 From: Harry van Haaren To: dev@dpdk.org Cc: david.marchand@dpdk.org, Harry van Haaren Date: Mon, 14 Sep 2020 15:37:31 +0100 Message-Id: <20200914143732.87907-1-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200907162149.31454-1-harry.van.haaren@intel.com> References: <20200907162149.31454-1-harry.van.haaren@intel.com> Subject: [dpdk-dev] [PATCH v2 1/2] service: add component useful work attribute 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" 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 --- v2: - Add experimental tag to new function. --- 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/rte_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 6a0e0ff65d..f9792a138b 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 */ @@ -293,6 +294,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) { @@ -778,6 +794,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 e2d0a6dd32..e9836a1a68 100644 --- a/lib/librte_eal/include/rte_service.h +++ b/lib/librte_eal/include/rte_service.h @@ -370,6 +370,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/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 0b18e2ef85..bb5e19ae9e 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -397,6 +397,9 @@ EXPERIMENTAL { rte_mp_disable; rte_thread_register; rte_thread_unregister; + + # added in 20.11 + rte_service_component_attr_set; }; INTERNAL { From patchwork Mon Sep 14 14:37:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Van Haaren, Harry" X-Patchwork-Id: 77631 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7DC2DA04C7; Mon, 14 Sep 2020 16:36:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D03EF1C10F; Mon, 14 Sep 2020 16:36:23 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 1F2C31C0D2 for ; Mon, 14 Sep 2020 16:36:20 +0200 (CEST) IronPort-SDR: mCFnExa6sHuqyxb7pZbT+tlvPzLPgFFVmxRvs8EPmqB/TIkwJaBKnfOJnAqd40Ok0ZCqrIvvnd ZwViykcOaJGA== X-IronPort-AV: E=McAfee;i="6000,8403,9744"; a="223269467" X-IronPort-AV: E=Sophos;i="5.76,426,1592895600"; d="scan'208";a="223269467" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2020 07:36:17 -0700 IronPort-SDR: ffIWtG9z5wopn1KLV3r3vI9EHqtnqFt67SS4HweeJH58OzDs01DrspAzhmZ4BV8XLmZw2RjXjC urAvcO1whK3Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,426,1592895600"; d="scan'208";a="301770393" Received: from silpixa00399779.ir.intel.com (HELO silpixa00399779.ger.corp.intel.com) ([10.237.222.209]) by orsmga003.jf.intel.com with ESMTP; 14 Sep 2020 07:36:16 -0700 From: Harry van Haaren To: dev@dpdk.org Cc: david.marchand@dpdk.org, Harry van Haaren Date: Mon, 14 Sep 2020 15:37:32 +0100 Message-Id: <20200914143732.87907-2-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914143732.87907-1-harry.van.haaren@intel.com> References: <20200907162149.31454-1-harry.van.haaren@intel.com> <20200914143732.87907-1-harry.van.haaren@intel.com> Subject: [dpdk-dev] [PATCH v2 2/2] event/sw: add useful work done attribute 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" This commit exposes if useful work is done to the service instance. The normal service_attr_get() API can be used to retrieve the value of the attribute. Signed-off-by: Harry van Haaren --- drivers/event/sw/sw_evdev_scheduler.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/event/sw/sw_evdev_scheduler.c b/drivers/event/sw/sw_evdev_scheduler.c index cff747da89..4e932612d5 100644 --- a/drivers/event/sw/sw_evdev_scheduler.c +++ b/drivers/event/sw/sw_evdev_scheduler.c @@ -5,6 +5,9 @@ #include #include #include + +#include + #include "sw_evdev.h" #include "iq_chunk.h" @@ -554,6 +557,10 @@ sw_event_schedule(struct rte_eventdev *dev) sw->sched_no_iq_enqueues += (in_pkts_total == 0); sw->sched_no_cq_enqueues += (out_pkts_total == 0); + uint64_t work_done = (in_pkts_total + out_pkts_total) != 0; + rte_service_component_attr_set(sw->service_id, + RTE_SERVICE_ATTR_USEFUL_WORK_LAST_ITER, work_done); + /* push all the internal buffered QEs in port->cq_ring to the * worker cores: aka, do the ring transfers batched. */