DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Reshma Pattan <reshma.pattan@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>
Subject: [RFC] test/latencystats: loosen requirements on measured latency
Date: Fri, 28 Nov 2025 11:02:20 -0800	[thread overview]
Message-ID: <20251128190228.64278-1-stephen@networkplumber.org> (raw)

On QEMU Arm there are failures because the minimum measured latency
was zero. This is likely because the TSC counter emulation is coarse
enough that successive measurements return same value.
Modify the test assertions to allow for TSC being slow (or even
constant).

Also, fix the test to cleanup before validating results
and print the values if a failure occurs. The field name values
printing loop was an earlier debug step not needed.

Fixes: b34508b9cbcd ("test/latency: update with more checks")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_latencystats.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/app/test/test_latencystats.c b/app/test/test_latencystats.c
index 676a99d385..0907f3f5a6 100644
--- a/app/test/test_latencystats.c
+++ b/app/test/test_latencystats.c
@@ -142,7 +142,6 @@ static void test_latency_ring_free(void)
 
 static int test_latency_packet_forward(void)
 {
-	unsigned int i;
 	int ret;
 	struct rte_mbuf *pbuf[LATENCY_NUM_PACKETS] = { };
 	struct rte_mempool *mp;
@@ -184,23 +183,26 @@ static int test_latency_packet_forward(void)
 	ret = rte_latencystats_get(values, NUM_STATS);
 	TEST_ASSERT(ret == NUM_STATS, "Test failed to get results after forwarding");
 
-	for (i = 0; i < NUM_STATS; i++) {
-		uint16_t k = values[i].key;
-
-		printf("%s = %"PRIu64"\n",
-		       names[k].name, values[i].value);
-	}
+	rte_eth_dev_stop(portid);
+	test_put_mbuf_to_pool(mp, pbuf);
 
 	TEST_ASSERT(values[4].value > 0, "No samples taken");
-	TEST_ASSERT(values[0].value > 0, "Min latency should not be zero");
-	TEST_ASSERT(values[1].value > 0, "Avg latency should not be zero");
-	TEST_ASSERT(values[2].value > 0, "Max latency should not be zero");
-	TEST_ASSERT(values[0].value < values[1].value, "Min latency > Avg latency");
-	TEST_ASSERT(values[0].value < values[2].value, "Min latency > Max latency");
-	TEST_ASSERT(values[1].value < values[2].value, "Avg latency > Max latency");
 
-	rte_eth_dev_stop(portid);
-	test_put_mbuf_to_pool(mp, pbuf);
+	/*
+	 * Test maybe run in emulated environment where TSC is very coarse.
+	 * Therefore can't assume that min/max/avg not zero.
+	 * But we can check that Min <= Avg <= Max.
+	 */
+
+	TEST_ASSERT(values[0].value <= values[1].value,
+		    "Min latency %"PRIu64" > Avg latency %"PRIu64,
+		    values[0].value, values[1].value);
+	TEST_ASSERT(values[0].value <= values[2].value,
+		    "Min latency %"PRIu64" > Max latency %"PRIu64,
+		    values[0].value, values[2].value);
+	TEST_ASSERT(values[1].value <= values[2].value,
+		    "Avg latency %"PRIu64 "> Max latency %"PRIu64,
+		    values[1].value, values[2].value);
 
 	return (ret >= 0) ? TEST_SUCCESS : TEST_FAILED;
 }
-- 
2.51.0


                 reply	other threads:[~2025-11-28 19:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20251128190228.64278-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --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).