From patchwork Fri Dec 4 07:51:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hideyuki Yamashita X-Patchwork-Id: 84750 X-Patchwork-Delegate: ferruh.yigit@amd.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 BF3DCA04B0; Fri, 4 Dec 2020 08:52:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D5A7AC9C6; Fri, 4 Dec 2020 08:51:58 +0100 (CET) Received: from dish-sg.nttdocomo.co.jp (dish-sg.nttdocomo.co.jp [202.19.227.74]) by dpdk.org (Postfix) with ESMTP id 140D5C9C2 for ; Fri, 4 Dec 2020 08:51:57 +0100 (CET) X-dD-Source: Outbound Received: from zssg-mailmd106.ddreams.local (zssg-mailmd900.ddreams.local [10.160.172.63]) by zssg-mailou103.ddreams.local (Postfix) with ESMTP id 499D5120120; Fri, 4 Dec 2020 16:51:55 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (zssg-mailmf900.ddreams.local [10.160.172.84]) by zssg-mailmd106.ddreams.local (dDREAMS) with ESMTP id <0QKT00QAC1UJL140@dDREAMS>; Fri, 04 Dec 2020 16:51:55 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by zssg-mailmf101.ddreams.local (Postfix) with ESMTP id 1A9757E6036; Fri, 4 Dec 2020 16:51:55 +0900 (JST) Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 17F058E6060; Fri, 4 Dec 2020 16:51:55 +0900 (JST) Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id 155F38E605C; Fri, 4 Dec 2020 16:51:55 +0900 (JST) X-IMSS-HAND-OFF-DIRECTIVE: localhost:10026 Received: from zssg-mailmf101.ddreams.local (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C856C8E605A; Fri, 4 Dec 2020 16:51:54 +0900 (JST) Received: from davinci.ntt-tx.co.jp (unknown [10.160.183.139]) by zssg-mailmf101.ddreams.local (Postfix) with ESMTP; Fri, 4 Dec 2020 16:51:54 +0900 (JST) From: Hideyuki Yamashita To: Maryam Tahhan , Reshma Pattan Cc: dev@dpdk.org, Hideyuki Yamashita , Hideyuki Yamashita Date: Fri, 04 Dec 2020 16:51:06 +0900 Message-id: <20201204075109.14694-3-yamashita.hideyuki@ntt-tx.co.jp> X-Mailer: git-send-email 2.28.0 In-reply-to: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> References: <20201204075109.14694-1-yamashita.hideyuki@ntt-tx.co.jp> MIME-version: 1.0 Content-transfer-encoding: 8bit X-TM-AS-GCONF: 00 Subject: [dpdk-dev] [PATCH 2/5] app/proc-info: add to use apistats 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 patch modifies to use apistats by proc-info app. - change on main.c to call apistats functions - change on Makefile to include experimental API Signed-off-by: Hideyuki Yamashita --- app/proc-info/main.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index d743209..d384b13 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -37,6 +37,7 @@ #include #include #include +#include /* Maximum long option length for option parsing. */ #define MAX_LONG_OPT_SZ 64 @@ -93,6 +94,8 @@ static char *mempool_name; /**< Enable iter mempool. */ static uint32_t enable_iter_mempool; static char *mempool_iter_name; +/**< Enable api stats. */ +static uint32_t enable_apistats; /**< display usage */ static void @@ -109,6 +112,7 @@ proc_info_usage(const char *prgname) " --xstats-name NAME: to display single xstat id by NAME\n" " --xstats-ids IDLIST: to display xstat values by id. " "The argument is comma-separated list of xstat ids to print out.\n" + " --apistats: to display api statistics, disabled by default\n" " --stats-reset: to reset port statistics\n" " --xstats-reset: to reset port extended statistics\n" " --collectd-format: to print statistics to STDOUT in expected by collectd format\n" @@ -218,6 +222,7 @@ proc_info_parse_args(int argc, char **argv) {"xstats-name", required_argument, NULL, 1}, {"collectd-format", 0, NULL, 0}, {"xstats-ids", 1, NULL, 1}, + {"apistats", 0, NULL, 0}, {"host-id", 0, NULL, 0}, {"show-port", 0, NULL, 0}, {"show-tm", 0, NULL, 0}, @@ -266,6 +271,9 @@ proc_info_parse_args(int argc, char **argv) else if (!strncmp(long_option[option_index].name, "xstats-reset", MAX_LONG_OPT_SZ)) reset_xstats = 1; + else if (!strncmp(long_option[option_index].name, "apistats", + MAX_LONG_OPT_SZ)) + enable_apistats = 1; else if (!strncmp(long_option[option_index].name, "show-port", MAX_LONG_OPT_SZ)) enable_shw_port = 1; @@ -1349,6 +1357,40 @@ iter_mempool(char *name) } } +static void +display_apistats(void) +{ + static const char *api_stats_border = "########################"; + uint16_t i; + struct rte_apistats t0_count, t1_count; + memcpy(&t0_count, rte_apicounts, sizeof(struct rte_apistats)); + sleep(1); + memcpy(&t1_count, rte_apicounts, sizeof(struct rte_apistats)); + for (i = 0; i < RTE_MAX_LCORE; i++) { + if (t1_count.lcoreid_list[i] != 0) { + uint64_t rx_count_delta = t1_count.rx_burst_counts[i] + - t0_count.rx_burst_counts[i]; + uint64_t tx_count_delta = t1_count.tx_burst_counts[i] + - t0_count.tx_burst_counts[i]; + printf("\n %s api statistics for lcoreid: %d %s\n", + api_stats_border, i, api_stats_border); + printf(" rx_burst_count: %13"PRIu64"" + " rx_burst_count_delta: %13"PRIu64"\n", + t1_count.rx_burst_counts[i], + rx_count_delta); + printf(" tx_burst_count: %13"PRIu64"" + " tx_burst_count_delta: %13"PRIu64"\n", + t1_count.tx_burst_counts[i], + tx_count_delta); + printf(" tx/rx_rate: %3.2f\n", + (rx_count_delta) ? (double)tx_count_delta + / rx_count_delta : 0.0); + printf(" %s################################%s\n", + api_stats_border, api_stats_border); + } + } +} + int main(int argc, char **argv) { @@ -1389,6 +1431,8 @@ main(int argc, char **argv) if (!rte_eal_primary_proc_alive(NULL)) rte_exit(EXIT_FAILURE, "No primary DPDK process is running.\n"); + rte_apistats_init(); + /* parse app arguments */ ret = proc_info_parse_args(argc, argv); if (ret < 0) @@ -1454,6 +1498,8 @@ main(int argc, char **argv) show_mempool(mempool_name); if (enable_iter_mempool) iter_mempool(mempool_iter_name); + if (enable_apistats) + display_apistats(); RTE_ETH_FOREACH_DEV(i) rte_eth_dev_close(i);