From: Kamil Vojanec <vojanec@cesnet.cz>
To: dev@dpdk.org
Cc: viktorin@cesnet.cz, Kamil Vojanec <vojanec@cesnet.cz>,
Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Subject: [RFC] table: report victim replace stats in LRU tables
Date: Fri, 16 Aug 2024 13:58:48 +0200 [thread overview]
Message-ID: <20240816115848.432547-1-vojanec@cesnet.cz> (raw)
LRU caches replace records when requested table bucket is full. There
is, however, no information about this happenning in either the return
value or the statistics. This commit introduces a counter for such
cases.
Signed-off-by: Kamil Vojanec <vojanec@cesnet.cz>
---
lib/table/rte_table.h | 1 +
lib/table/rte_table_hash_key16.c | 4 ++++
lib/table/rte_table_hash_key32.c | 4 ++++
lib/table/rte_table_hash_key8.c | 4 ++++
lib/table/rte_table_hash_lru.c | 4 ++++
5 files changed, 17 insertions(+)
diff --git a/lib/table/rte_table.h b/lib/table/rte_table.h
index 9a5faf0e32..e097e25868 100644
--- a/lib/table/rte_table.h
+++ b/lib/table/rte_table.h
@@ -33,6 +33,7 @@ struct rte_mbuf;
struct rte_table_stats {
uint64_t n_pkts_in;
uint64_t n_pkts_lookup_miss;
+ uint64_t n_pkts_insert_victims;
};
/**
diff --git a/lib/table/rte_table_hash_key16.c b/lib/table/rte_table_hash_key16.c
index 67b77c16a0..f97d9c1266 100644
--- a/lib/table/rte_table_hash_key16.c
+++ b/lib/table/rte_table_hash_key16.c
@@ -27,11 +27,14 @@
table->stats.n_pkts_in += val
#define RTE_TABLE_HASH_KEY16_STATS_PKTS_LOOKUP_MISS(table, val) \
table->stats.n_pkts_lookup_miss += val
+#define RTE_TABLE_HASH_KEY16_STATS_PKTS_INSERT_VICTIMS_ADD(table, val) \
+ table->stats.n_pkts_insert_victims += val
#else
#define RTE_TABLE_HASH_KEY16_STATS_PKTS_IN_ADD(table, val)
#define RTE_TABLE_HASH_KEY16_STATS_PKTS_LOOKUP_MISS(table, val)
+#define RTE_TABLE_HASH_KEY16_STATS_PKTS_INSERT_VICTIMS_ADD(table, val)
#endif
@@ -304,6 +307,7 @@ rte_table_hash_entry_add_key16_lru(
}
/* Bucket full: replace LRU entry */
+ RTE_TABLE_HASH_KEY16_STATS_PKTS_INSERT_VICTIMS_ADD(f, 1);
pos = lru_pos(bucket);
bucket->signature[pos] = signature;
keycpy(&bucket->key[pos], key, f->key_mask);
diff --git a/lib/table/rte_table_hash_key32.c b/lib/table/rte_table_hash_key32.c
index 1aa86c6a49..37ad87bb85 100644
--- a/lib/table/rte_table_hash_key32.c
+++ b/lib/table/rte_table_hash_key32.c
@@ -27,11 +27,14 @@
table->stats.n_pkts_in += val
#define RTE_TABLE_HASH_KEY32_STATS_PKTS_LOOKUP_MISS(table, val) \
table->stats.n_pkts_lookup_miss += val
+#define RTE_TABLE_HASH_KEY32_STATS_PKTS_INSERT_VICTIMS_ADD(table, val) \
+ table->stats.n_pkts_insert_victims += val
#else
#define RTE_TABLE_HASH_KEY32_STATS_PKTS_IN_ADD(table, val)
#define RTE_TABLE_HASH_KEY32_STATS_PKTS_LOOKUP_MISS(table, val)
+#define RTE_TABLE_HASH_KEY32_STATS_PKTS_INSERT_VICTIMS_ADD(table, val)
#endif
@@ -312,6 +315,7 @@ rte_table_hash_entry_add_key32_lru(
}
/* Bucket full: replace LRU entry */
+ RTE_TABLE_HASH_KEY32_STATS_PKTS_INSERT_VICTIMS_ADD(f, 1);
pos = lru_pos(bucket);
bucket->signature[pos] = signature;
keycpy(&bucket->key[pos], key, f->key_mask);
diff --git a/lib/table/rte_table_hash_key8.c b/lib/table/rte_table_hash_key8.c
index c8d72b333d..c5722f3709 100644
--- a/lib/table/rte_table_hash_key8.c
+++ b/lib/table/rte_table_hash_key8.c
@@ -25,11 +25,14 @@
table->stats.n_pkts_in += val
#define RTE_TABLE_HASH_KEY8_STATS_PKTS_LOOKUP_MISS(table, val) \
table->stats.n_pkts_lookup_miss += val
+#define RTE_TABLE_HASH_KEY8_STATS_PKTS_INSERT_VICTIMS_ADD(table, val) \
+ table->stats.n_pkts_insert_victims += val
#else
#define RTE_TABLE_HASH_KEY8_STATS_PKTS_IN_ADD(table, val)
#define RTE_TABLE_HASH_KEY8_STATS_PKTS_LOOKUP_MISS(table, val)
+#define RTE_TABLE_HASH_KEY8_STATS_PKTS_INSERT_VICTIMS_ADD(table, val)
#endif
@@ -292,6 +295,7 @@ rte_table_hash_entry_add_key8_lru(
}
/* Bucket full: replace LRU entry */
+ RTE_TABLE_HASH_KEY8_STATS_PKTS_INSERT_VICTIMS_ADD(f, 1);
pos = lru_pos(bucket);
keycpy(&bucket->key[pos], key, &f->key_mask);
memcpy(&bucket->data[pos * f->entry_size], entry, f->entry_size);
diff --git a/lib/table/rte_table_hash_lru.c b/lib/table/rte_table_hash_lru.c
index 801e48f5ba..bcf9c34f8e 100644
--- a/lib/table/rte_table_hash_lru.c
+++ b/lib/table/rte_table_hash_lru.c
@@ -23,11 +23,14 @@
table->stats.n_pkts_in += val
#define RTE_TABLE_HASH_LRU_STATS_PKTS_LOOKUP_MISS(table, val) \
table->stats.n_pkts_lookup_miss += val
+#define RTE_TABLE_HASH_LRU_STATS_PKTS_INSERT_VICTIMS_ADD(table, val) \
+ table->stats.n_pkts_insert_victims += val
#else
#define RTE_TABLE_HASH_LRU_STATS_PKTS_IN_ADD(table, val)
#define RTE_TABLE_HASH_LRU_STATS_PKTS_LOOKUP_MISS(table, val)
+#define RTE_TABLE_HASH_LRU_STATS_PKTS_INSERT_VICTIMS_ADD(table, val)
#endif
@@ -340,6 +343,7 @@ rte_table_hash_lru_entry_add(void *table, void *key, void *entry,
/* Bucket full */
{
+ RTE_TABLE_HASH_LRU_STATS_PKTS_INSERT_VICTIMS_ADD(t, 1);
uint64_t pos = lru_pos(bkt);
uint32_t bkt_key_index = bkt->key_pos[pos];
uint8_t *bkt_key = &t->key_mem[bkt_key_index <<
--
2.43.5
next reply other threads:[~2024-08-16 11:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-16 11:58 Kamil Vojanec [this message]
2024-08-19 5:23 ` Kamil Vojanec
2024-10-12 2:57 ` Stephen Hemminger
2024-10-13 1:19 ` 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=20240816115848.432547-1-vojanec@cesnet.cz \
--to=vojanec@cesnet.cz \
--cc=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
--cc=viktorin@cesnet.cz \
/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).