Soft Patch Panel
 help / color / Atom feed
From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 3/9] shared: rename struct for ring latency stats
Date: Thu, 12 Sep 2019 19:48:18 +0900
Message-ID: <20190912104824.21519-4-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190912104824.21519-1-yasufum.o@gmail.com>

From: Yasufumi Ogawa <yasufum.o@gmail.com>

Struct `spp_ringlatencystats_ring_latency_stats` is for containing stats
as a histgram like data. It is only used in `latency_stats.c` and its
header locally, so no need to such a long name. This update is to rename
it to `ring_latency_stats_t`.

This update also includes revising name of vars and comments.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 .../secondary/spp_worker_th/latency_stats.c   | 28 ++++++++-----------
 .../secondary/spp_worker_th/latency_stats.h   | 22 +++++++++------
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/latency_stats.c b/src/shared/secondary/spp_worker_th/latency_stats.c
index 036a360..0a5e5a7 100644
--- a/src/shared/secondary/spp_worker_th/latency_stats.c
+++ b/src/shared/secondary/spp_worker_th/latency_stats.c
@@ -27,10 +27,9 @@
 
 /** ring latency statistics information */
 struct ring_latency_stats_info {
-	uint64_t timer_tsc;     /**< sampling interval counter */
-	uint64_t prev_tsc;      /**< previous time */
-	struct spp_ringlatencystats_ring_latency_stats stats;
-				/**< ring latency statistics list */
+	uint64_t timer_tsc;  /**< sampling interval */
+	uint64_t prev_tsc;   /**< previous time */
+	struct ring_latency_stats_t stats;  /**< list of stats */
 };
 
 /** sampling interval */
@@ -133,16 +132,13 @@ sppwk_calc_ring_latency(int ring_id,
 		if (likely(pkts[i]->timestamp == 0))
 			continue;
 
-		/* when mbuf::timestamp is not zero */
-		/* calculate latency */
+		/* calc latency if mbuf `timestamp` is non-zero. */
 		latency = (uint64_t)floor((now - pkts[i]->timestamp) /
 				cycles_per_ns());
-		if (likely(latency < SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT-1))
-			stats_info->stats.slot[latency]++;
+		if (likely(latency < TOTAL_LATENCY_ENT-1))
+			stats_info->stats.distr[latency]++;
 		else
-			stats_info->stats.slot[
-					SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT
-					-1]++;
+			stats_info->stats.distr[TOTAL_LATENCY_ENT-1]++;
 	}
 }
 
@@ -154,12 +150,12 @@ spp_ringlatencystats_get_count(void)
 
 void
 spp_ringlatencystats_get_stats(int ring_id,
-		struct spp_ringlatencystats_ring_latency_stats *stats)
+		struct ring_latency_stats_t *stats)
 {
 	struct ring_latency_stats_info *stats_info = &g_stats_info[ring_id];
 
 	rte_memcpy(stats, &stats_info->stats,
-			sizeof(struct spp_ringlatencystats_ring_latency_stats));
+			sizeof(struct ring_latency_stats_t));
 }
 
 /* Print statistics of time for packet processing in ring interface */
@@ -172,7 +168,7 @@ print_ring_latency_stats(struct iface_info *if_info)
 	printf("%s%s", clr, topLeft);
 
 	int ring_cnt, stats_cnt;
-	struct spp_ringlatencystats_ring_latency_stats stats[RTE_MAX_ETHPORTS];
+	struct ring_latency_stats_t stats[RTE_MAX_ETHPORTS];
 	memset(&stats, 0x00, sizeof(stats));
 
 	printf("RING Latency\n");
@@ -186,14 +182,14 @@ print_ring_latency_stats(struct iface_info *if_info)
 	}
 	printf("\n");
 
-	for (stats_cnt = 0; stats_cnt < SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT;
+	for (stats_cnt = 0; stats_cnt < TOTAL_LATENCY_ENT;
 			stats_cnt++) {
 		printf("%3dns", stats_cnt);
 		for (ring_cnt = 0; ring_cnt < RTE_MAX_ETHPORTS; ring_cnt++) {
 			if (if_info->ring[ring_cnt].iface_type == UNDEF)
 				continue;
 
-			printf(", 0x%-16lx", stats[ring_cnt].slot[stats_cnt]);
+			printf(", 0x%-16lx", stats[ring_cnt].distr[stats_cnt]);
 		}
 		printf("\n");
 	}
diff --git a/src/shared/secondary/spp_worker_th/latency_stats.h b/src/shared/secondary/spp_worker_th/latency_stats.h
index 4a7abb4..de9ee5d 100644
--- a/src/shared/secondary/spp_worker_th/latency_stats.h
+++ b/src/shared/secondary/spp_worker_th/latency_stats.h
@@ -9,19 +9,25 @@
  * @file
  * SPP RING latency statistics
  *
- * Measure the latency through ring-PMD.
+ * Util functions for measuring latency of ring-PMD.
  */
 
 #include <rte_mbuf.h>
 #include "cmd_utils.h"
 
-/** number of slots to save latency. 0ns~99ns and 100ns over */
-#define SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT 101
+/**
+ * Statistics of latency of ring is counted with histgram like data structure.
+ * To count frequency of each of time in nano sec, this data is implemented as
+ * an array in which frequency counts of 1-100[ns] are contained. If the
+ * latency is larger than 100[ns], it is added to the last entry. It means
+ * this array has 101 entries, 100 entries for 1-100[ns] and 1 entry for over
+ * 100[ns].
+ */
+#define TOTAL_LATENCY_ENT 101
 
-/** ring latency statistics */
-struct spp_ringlatencystats_ring_latency_stats {
-	/** slots to save latency */
-	uint64_t slot[SPP_RINGLATENCYSTATS_STATS_SLOT_COUNT];
+/** statistics of latency of ring */
+struct ring_latency_stats_t {
+	uint64_t distr[TOTAL_LATENCY_ENT]; /* distribution of time */
 };
 
 
@@ -88,7 +94,7 @@ int spp_ringlatencystats_get_count(void);
  *  The statistics values.
  */
 void spp_ringlatencystats_get_stats(int ring_id,
-		struct spp_ringlatencystats_ring_latency_stats *stats);
+		struct ring_latency_stats_t *stats);
 
 /* Print statistics of time for packet processing in ring interface */
 void print_ring_latency_stats(struct iface_info *if_info);
-- 
2.17.1


  parent reply index

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-12 10:48 [spp] [PATCH 0/9] Refactor ringlatencystats yasufum.o
2019-09-12 10:48 ` [spp] [PATCH 1/9] shared: rename file ringlatencystats to be short yasufum.o
2019-09-12 10:48 ` [spp] [PATCH 2/9] shared: rename func for calc latency of ring yasufum.o
2019-09-12 10:48 ` yasufum.o [this message]
2019-09-12 10:48 ` [spp] [PATCH 4/9] shared: rename func for init latency stats yasufum.o
2019-09-12 10:48 ` [spp] [PATCH 5/9] shared: renaem util funcs of ring latency yasufum.o
2019-09-12 10:48 ` [spp] [PATCH 6/9] spp_vf: revise util func for status command yasufum.o
2019-09-12 10:48 ` [spp] [PATCH 7/9] spp_mirror: " yasufum.o
2019-09-12 10:48 ` [spp] [PATCH 8/9] spp_pcap: " yasufum.o
2019-09-12 10:48 ` [spp] [PATCH 9/9] shared: add TODO to fix bug in latency stats yasufum.o

Reply instructions:

You may reply publically 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=20190912104824.21519-4-yasufum.o@gmail.com \
    --to=yasufum.o@gmail.com \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /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

Soft Patch Panel

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ http://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/ public-inbox