From: Dengdui Huang <huangdengdui@huawei.com>
To: <dev@dpdk.org>
Cc: <reshma.pattan@intel.com>, <lihuisong@huawei.com>,
<fengchengwen@huawei.com>, <haijie1@huawei.com>,
<liuyonglong@huawei.com>
Subject: [PATCH] app/procinfo: add xstats parameter to hide zero
Date: Fri, 24 Jan 2025 18:00:32 +0800 [thread overview]
Message-ID: <20250124100032.3497253-1-huangdengdui@huawei.com> (raw)
The number of xstats may be large, after the hide zero parameter to
hide zero only non-zero values can be displayed.
So display xstats with hide zero:
dpdk-proc-info --proc-type=secondary -- --xstats
and without hide zero:
dpdk-proc-info --proc-type=secondary -- --xstats=hide_zero
Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
---
app/proc-info/main.c | 20 ++++++++++++++------
doc/guides/tools/proc_info.rst | 7 ++++---
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index e1272164b1..cc0f71c229 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -61,6 +61,7 @@ static unsigned long enabled_port_mask;
static uint32_t enable_stats;
/* Enable xstats. */
static uint32_t enable_xstats;
+static bool xstats_hide_zero = false;
/* Enable collectd format */
static uint32_t enable_collectd_format;
/* FD to send collectd format messages to STDOUT */
@@ -162,8 +163,8 @@ proc_info_usage(const char *prgname)
" -m to display DPDK memory zones, segments and TAILQ information\n"
" -p PORTMASK: hexadecimal bitmask of ports to retrieve stats for\n"
" --stats: to display port statistics, enabled by default\n"
- " --xstats: to display extended port statistics, disabled by "
- "default\n"
+ " --xstats[=hide_zero]: to display extended port statistics, disabled by default, "
+ "support hide zero.\n"
#ifdef RTE_LIB_METRICS
" --metrics: to display derived metrics of the ports, disabled by "
"default\n"
@@ -425,7 +426,7 @@ proc_info_parse_args(int argc, char **argv)
static struct option long_option[] = {
{"stats", 0, NULL, 0},
{"stats-reset", 0, NULL, 0},
- {"xstats", 0, NULL, 0},
+ {"xstats", optional_argument, NULL, 0},
#ifdef RTE_LIB_METRICS
{"metrics", 0, NULL, 0},
#endif
@@ -476,12 +477,17 @@ proc_info_parse_args(int argc, char **argv)
case 0:
/* Print stats */
if (!strncmp(long_option[option_index].name, "stats",
- MAX_LONG_OPT_SZ))
+ MAX_LONG_OPT_SZ)) {
enable_stats = 1;
/* Print xstats */
- else if (!strncmp(long_option[option_index].name, "xstats",
- MAX_LONG_OPT_SZ))
+ } else if (!strncmp(long_option[option_index].name, "xstats",
+ MAX_LONG_OPT_SZ)) {
enable_xstats = 1;
+ if (optarg != NULL && !strncmp(optarg, "hide_zero",
+ MAX_LONG_OPT_SZ))
+ xstats_hide_zero = true;
+
+ }
#ifdef RTE_LIB_METRICS
else if (!strncmp(long_option[option_index].name,
"metrics",
@@ -850,6 +856,8 @@ nic_xstats_display(uint16_t port_id)
}
for (i = 0; i < len; i++) {
+ if (xstats_hide_zero && values[i] == 0)
+ continue;
if (enable_collectd_format) {
char counter_type[MAX_STRING_LEN];
char buf[MAX_STRING_LEN];
diff --git a/doc/guides/tools/proc_info.rst b/doc/guides/tools/proc_info.rst
index bb483afbce..e623d71785 100644
--- a/doc/guides/tools/proc_info.rst
+++ b/doc/guides/tools/proc_info.rst
@@ -17,7 +17,7 @@ The application has a number of command line options:
.. code-block:: console
- ./<build_dir>/app/dpdk-proc-info -- -m | [-p PORTMASK] [--stats | --xstats |
+ ./<build_dir>/app/dpdk-proc-info -- -m | [-p PORTMASK] [--stats | --xstats[=hide_zero] |
--stats-reset | --xstats-reset] [ --show-port | --show-tm | --show-crypto |
--show-ring[=name] | --show-mempool[=name] | --iter-mempool=name |
--show-port-private | --version | --firmware-version | --show-rss-reta |
@@ -34,9 +34,10 @@ Parameters
The stats parameter controls the printing of generic port statistics. If no
port mask is specified stats are printed for all DPDK ports.
-**--xstats**
+**--xstats[=hide_zero]**
The xstats parameter controls the printing of extended port statistics. If no
-port mask is specified xstats are printed for all DPDK ports.
+port mask is specified xstats are printed for all DPDK ports. Specifying the
+hide_zero value to display xstats with hide zero.
**--stats-reset**
The stats-reset parameter controls the resetting of generic port statistics. If
--
2.33.0
next reply other threads:[~2025-01-24 10:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 10:00 Dengdui Huang [this message]
2025-01-24 18:04 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250124100032.3497253-1-huangdengdui@huawei.com \
--to=huangdengdui@huawei.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=haijie1@huawei.com \
--cc=lihuisong@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=reshma.pattan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).