DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] examples/link_status_interrupt: fix stats refresh rate
@ 2022-05-30  9:37 Raja Zidane
  2022-06-26 21:22 ` Thomas Monjalon
  2022-07-07  8:22 ` [PATCH v2] " Omar Awaysa
  0 siblings, 2 replies; 4+ messages in thread
From: Raja Zidane @ 2022-05-30  9:37 UTC (permalink / raw)
  To: dev; +Cc: matan, stable

TIMER_MILLISECOND is defined as the number of cpu cycles per millisecond,
current definition is correct for cores with frequency of 2GHZ, for cores
with different frequency, it caused different periods between refresh,
(i.e. the definition is about 14ms on ARM cores).

Use dpdk API to get CPU frequency, to define TIMER_MILLISECOND.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Raja Zidane <rzidane@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
 examples/link_status_interrupt/main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c
index 551f0524da..eb7a74d37c 100644
--- a/examples/link_status_interrupt/main.c
+++ b/examples/link_status_interrupt/main.c
@@ -101,9 +101,10 @@ struct lsi_port_statistics {
 struct lsi_port_statistics port_statistics[RTE_MAX_ETHPORTS];
 
 /* A tsc-based timer responsible for triggering statistics printout */
-#define TIMER_MILLISECOND 2000000ULL /* around 1ms at 2 Ghz */
+#define TIMER_MILLISECOND (rte_get_tsc_hz() / 1000)
 #define MAX_TIMER_PERIOD 86400 /* 1 day max */
-static int64_t timer_period = 10 * TIMER_MILLISECOND * 1000; /* default period is 10 seconds */
+#define DEFAULT_TIMER_PERIOD 10UL /* default period is 10 seconds */
+static int64_t timer_period;
 
 /* Print out statistics on packets dropped */
 static void
@@ -371,6 +372,7 @@ lsi_parse_args(int argc, char **argv)
 	};
 
 	argvopt = argv;
+	timer_period = DEFAULT_TIMER_PERIOD;
 
 	while ((opt = getopt_long(argc, argvopt, "p:q:T:",
 				  lgopts, &option_index)) != EOF) {
-- 
2.21.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-08 14:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-30  9:37 [PATCH] examples/link_status_interrupt: fix stats refresh rate Raja Zidane
2022-06-26 21:22 ` Thomas Monjalon
2022-07-07  8:22 ` [PATCH v2] " Omar Awaysa
2022-07-08 14:47   ` Thomas Monjalon

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).