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 30DBCA04F2; Thu, 5 Dec 2019 18:35:10 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 490F51BFB0; Thu, 5 Dec 2019 18:34:22 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 632001BF97 for ; Thu, 5 Dec 2019 18:34:16 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2019 09:34:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,282,1571727600"; d="scan'208";a="223711870" Received: from silpixa00399953.ir.intel.com (HELO silpixa00399953.ger.corp.intel.com) ([10.237.222.53]) by orsmga002.jf.intel.com with ESMTP; 05 Dec 2019 09:34:14 -0800 From: Ciara Power To: dev@dpdk.org Cc: Ciara Power , Bruce Richardson Date: Thu, 5 Dec 2019 17:31:28 +0000 Message-Id: <20191205173128.64543-7-ciara.power@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191205173128.64543-1-ciara.power@intel.com> References: <20191205173128.64543-1-ciara.power@intel.com> Subject: [dpdk-dev] [RFC 6/6] examples/l3fwd-power: enable use of process-info 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" The l3fwd-power example app now registers a stats command with process_info, and provides a callback function to handle formatting the power stats. Using the process-info library in this app replaces the previous method of making l3fwd-power stats available in the metrics library, for use with telemetry. Signed-off-by: Bruce Richardson Signed-off-by: Ciara Power --- examples/l3fwd-power/main.c | 83 +++++++++++-------------------------- 1 file changed, 25 insertions(+), 58 deletions(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index d049d8a5d..939b3dd88 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include "perf_core.h" #include "main.h" @@ -131,7 +131,7 @@ #define EMPTY_POLL_MED_THRESHOLD 350000UL #define EMPTY_POLL_HGH_THRESHOLD 580000UL - +#define NUM_TELSTATS RTE_DIM(telstats_strings) static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT; static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT; @@ -154,11 +154,6 @@ volatile bool quit_signal; static struct ep_params *ep_params; static struct ep_policy policy; static long ep_med_edpi, ep_hgh_edpi; -/* timer to update telemetry every 500ms */ -static struct rte_timer telemetry_timer; - -/* stats index returned by metrics lib */ -int telstats_index; struct telstats_name { char name[RTE_ETH_XSTATS_NAME_SIZE]; @@ -187,9 +182,6 @@ enum busy_rate { #define MIN_CYCLES 1500000ULL #define MAX_CYCLES 22000000ULL -/* (500ms) */ -#define TELEMETRY_INTERVALS_PER_SEC 2 - static int parse_ptype; /**< Parse packet type using rx callback, and */ /**< disabled by default */ @@ -2087,17 +2079,21 @@ init_power_library(void) } return ret; } -static void -update_telemetry(__attribute__((unused)) struct rte_timer *tim, - __attribute__((unused)) void *arg) + +static int +handle_app_stats(const char *cmd __rte_unused, + const char *params __rte_unused, + char *buffer, int buf_len) { unsigned int lcore_id = rte_lcore_id(); struct lcore_conf *qconf; uint64_t app_eps = 0, app_fps = 0, app_br = 0; - uint64_t values[3] = {0}; - int ret; + uint64_t values[NUM_TELSTATS]; + int ret, used = 0; + uint32_t i; uint64_t count = 0; + used = strlcpy(buffer, "{", buf_len); RTE_LCORE_FOREACH_SLAVE(lcore_id) { qconf = &lcore_conf[lcore_id]; if (qconf->n_rx_queue == 0) @@ -2114,32 +2110,21 @@ update_telemetry(__attribute__((unused)) struct rte_timer *tim, values[0] = app_eps/count; values[1] = app_fps/count; values[2] = app_br/count; - } else { - values[0] = 0; - values[1] = 0; - values[2] = 0; + } else + memset(values, 0, sizeof(uint64_t) * NUM_TELSTATS); + + for (i = 0; i < NUM_TELSTATS; i++) { + ret = snprintf(buffer + used, buf_len - used, "\"%s\":%"PRIu64",", + telstats_strings[i].name, values[i]); + if (ret + used >= buf_len) + break; + used += ret; } - ret = rte_metrics_update_values(RTE_METRICS_GLOBAL, telstats_index, - values, RTE_DIM(values)); - if (ret < 0) - RTE_LOG(WARNING, POWER, "failed to update metrcis\n"); + buffer[used - 1] = '}'; + return used; } -static void -telemetry_setup_timer(void) -{ - int lcore_id = rte_lcore_id(); - uint64_t hz = rte_get_timer_hz(); - uint64_t ticks; - ticks = hz / TELEMETRY_INTERVALS_PER_SEC; - rte_timer_reset_sync(&telemetry_timer, - ticks, - PERIODICAL, - lcore_id, - update_telemetry, - NULL); -} static void empty_poll_setup_timer(void) { @@ -2176,8 +2161,6 @@ launch_timer(unsigned int lcore_id) if (app_mode == APP_MODE_EMPTY_POLL) empty_poll_setup_timer(); - else - telemetry_setup_timer(); cycles_10ms = rte_get_timer_hz() / 100; @@ -2196,7 +2179,6 @@ launch_timer(unsigned int lcore_id) return 0; } - int main(int argc, char **argv) { @@ -2212,8 +2194,6 @@ main(int argc, char **argv) uint32_t dev_rxq_num, dev_txq_num; uint8_t nb_rx_queue, queue, socketid; uint16_t portid; - uint8_t num_telstats = RTE_DIM(telstats_strings); - const char *ptr_strings[num_telstats]; /* catch SIGINT and restore cpufreq governor to ondemand */ signal(SIGINT, signal_exit_now); @@ -2507,29 +2487,16 @@ main(int argc, char **argv) rte_eal_mp_remote_launch(main_empty_poll_loop, NULL, SKIP_MASTER); } else { - unsigned int i; - - /* Init metrics library */ - rte_metrics_init(rte_socket_id()); - /** Register stats with metrics library */ - for (i = 0; i < num_telstats; i++) - ptr_strings[i] = telstats_strings[i].name; - - ret = rte_metrics_reg_names(ptr_strings, num_telstats); - if (ret >= 0) - telstats_index = ret; - else - rte_exit(EXIT_FAILURE, "failed to register metrics names"); - RTE_LCORE_FOREACH_SLAVE(lcore_id) { rte_spinlock_init(&stats[lcore_id].telemetry_lock); } - rte_timer_init(&telemetry_timer); + rte_process_info_register("/l3fwd-power:stats", + handle_app_stats); rte_eal_mp_remote_launch(main_telemetry_loop, NULL, SKIP_MASTER); } - if (app_mode == APP_MODE_EMPTY_POLL || app_mode == APP_MODE_TELEMETRY) + if (app_mode == APP_MODE_EMPTY_POLL) launch_timer(rte_lcore_id()); RTE_LCORE_FOREACH_SLAVE(lcore_id) { -- 2.17.1