From b97d3a9cbc10034584788cd30354e1c97992786c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20R=C3=B6nnblom?= Date: Mon, 9 Mar 2020 07:51:06 +0100 Subject: [PATCH] event/dsw: add port busy cycles xstats MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit DSW keeps an internal port load estimate, used by the load balancing mechanism. As a side effect, it keeps track of the total number of busy cycles since startup. This metric is indirectly exposed in the form of DSW xstats' "port__event_proc_latency", which is the total number of busy cycles divided by the total number of events processed on a particular port. An external application can take (event_latency * dequeued) to go back to busy_cycles. One reason for doing this is to measure the port's load during a longer time period, without resorting to sampling "port__load". However, as the number dequeued events grows, a rounding error in event_latency renders the application-calculated busy_cycles inaccurate. Thus, it makes sense to directly expose the number of busy cycles as a DSW xstats, even though it might seem redundant. Signed-off-by: Mattias Rönnblom --- drivers/event/dsw/dsw_xstats.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/event/dsw/dsw_xstats.c b/drivers/event/dsw/dsw_xstats.c index d332a57b64..e8e92183e2 100644 --- a/drivers/event/dsw/dsw_xstats.c +++ b/drivers/event/dsw/dsw_xstats.c @@ -109,6 +109,13 @@ dsw_xstats_port_get_event_proc_latency(struct dsw_evdev *dsw, uint8_t port_id, return dequeued > 0 ? total_busy_cycles / dequeued : 0; } +static uint64_t +dsw_xstats_port_get_busy_cycles(struct dsw_evdev *dsw, uint8_t port_id, + uint8_t queue_id __rte_unused) +{ + return dsw->ports[port_id].total_busy_cycles; +} + DSW_GEN_PORT_ACCESS_FN(inflight_credits) DSW_GEN_PORT_ACCESS_FN(pending_releases) @@ -147,6 +154,8 @@ static struct dsw_xstats_port dsw_port_xstats[] = { false }, { "port_%u_event_proc_latency", dsw_xstats_port_get_event_proc_latency, false }, + { "port_%u_busy_cycles", dsw_xstats_port_get_busy_cycles, + false }, { "port_%u_inflight_credits", dsw_xstats_port_get_inflight_credits, false }, { "port_%u_pending_releases", dsw_xstats_port_get_pending_releases, -- 2.20.1