[dpdk-dev] table: fix hash_ext stats update

Message ID 1489218086-4250-1-git-send-email-gureedo@gmail.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch warning coding style issues

Commit Message

Aleksey Katargin March 11, 2017, 7:41 a.m. UTC
  Fixed stats double update.

Signed-off-by: Aleksey Katargin <gureedo@gmail.com>
---
 lib/librte_table/rte_table_hash_ext.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
  

Comments

Cristian Dumitrescu March 31, 2017, 5:53 p.m. UTC | #1
> -----Original Message-----
> From: Aleksey Katargin [mailto:gureedo@gmail.com]
> Sent: Saturday, March 11, 2017 7:41 AM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org
> Subject: [PATCH] table: fix hash_ext stats update
> 
> Fixed stats double update.
> 
> Signed-off-by: Aleksey Katargin <gureedo@gmail.com>
> ---

Thanks, Aleksey! BTW the " rte_table_hash_lru.c " suffers from the same symptoms, so a patch to fix this one would also be highly appreciated :)

Ack-ed by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
  
Thomas Monjalon April 20, 2017, 11:30 p.m. UTC | #2
> > Fixed stats double update.
> > 
> > Signed-off-by: Aleksey Katargin <gureedo@gmail.com>
> > ---
> 
> Thanks, Aleksey! BTW the " rte_table_hash_lru.c " suffers from the same
> symptoms, so a patch to fix this one would also be highly appreciated :)
> 
> Ack-ed by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_table/rte_table_hash_ext.c b/lib/librte_table/rte_table_hash_ext.c
index e283a3d..353f930 100644
--- a/lib/librte_table/rte_table_hash_ext.c
+++ b/lib/librte_table/rte_table_hash_ext.c
@@ -444,7 +444,6 @@  static int rte_table_hash_ext_lookup_unoptimized(
 	uint64_t pkts_mask_out = 0;
 
 	__rte_unused uint32_t n_pkts_in = __builtin_popcountll(pkts_mask);
-	RTE_TABLE_HASH_EXT_STATS_PKTS_IN_ADD(t, n_pkts_in);
 
 	for ( ; pkts_mask; ) {
 		struct bucket *bkt0, *bkt;
@@ -490,7 +489,6 @@  static int rte_table_hash_ext_lookup_unoptimized(
 	}
 
 	*lookup_hit_mask = pkts_mask_out;
-	RTE_TABLE_HASH_EXT_STATS_PKTS_LOOKUP_MISS(t, n_pkts_in - __builtin_popcountll(pkts_mask_out));
 	return 0;
 }
 
@@ -874,9 +872,12 @@  static int rte_table_hash_ext_lookup(
 	RTE_TABLE_HASH_EXT_STATS_PKTS_IN_ADD(t, n_pkts_in);
 
 	/* Cannot run the pipeline with less than 7 packets */
-	if (__builtin_popcountll(pkts_mask) < 7)
-		return rte_table_hash_ext_lookup_unoptimized(table, pkts,
+	if (__builtin_popcountll(pkts_mask) < 7) {
+		status = rte_table_hash_ext_lookup_unoptimized(table, pkts,
 			pkts_mask, lookup_hit_mask, entries, 0);
+		RTE_TABLE_HASH_EXT_STATS_PKTS_LOOKUP_MISS(t, n_pkts_in - __builtin_popcountll(*lookup_hit_mask));
+		return status;
+	}
 
 	/* Pipeline stage 0 */
 	lookup2_stage0(t, g, pkts, pkts_mask, pkt00_index, pkt01_index);
@@ -1007,9 +1008,12 @@  static int rte_table_hash_ext_lookup_dosig(
 	RTE_TABLE_HASH_EXT_STATS_PKTS_IN_ADD(t, n_pkts_in);
 
 	/* Cannot run the pipeline with less than 7 packets */
-	if (__builtin_popcountll(pkts_mask) < 7)
-		return rte_table_hash_ext_lookup_unoptimized(table, pkts,
+	if (__builtin_popcountll(pkts_mask) < 7) {
+		status = rte_table_hash_ext_lookup_unoptimized(table, pkts,
 			pkts_mask, lookup_hit_mask, entries, 1);
+		RTE_TABLE_HASH_EXT_STATS_PKTS_LOOKUP_MISS(t, n_pkts_in - __builtin_popcountll(*lookup_hit_mask));
+		return status;
+	}
 
 	/* Pipeline stage 0 */
 	lookup2_stage0(t, g, pkts, pkts_mask, pkt00_index, pkt01_index);