From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9839345812; Mon, 19 Aug 2024 07:23:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D4FE34028A; Mon, 19 Aug 2024 07:23:45 +0200 (CEST) Received: from office2.cesnet.cz (office2.cesnet.cz [78.128.248.237]) by mails.dpdk.org (Postfix) with ESMTP id D574C40267 for ; Mon, 19 Aug 2024 07:23:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2-2020; t=1724045023; bh=m3FNOqorMGxEzsQR+umWyZ1vsjVIo3xIeBN3hggn5Ao=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KOAuWBQCi1dc4oHTN2ZpcFMnCOWXjXNJs24f+8ggVLnBGTpbOHBk/G2SFmKZug5be u/lQ0nCtr/UawSVE8i8EjV0zyevbA95P5flzXMJha5hamtSdchR5LEVWhBw/v3Jr4p JMdoPjdz88vlIjS90IIQ6ulEKAY59i6uDcRR+GuQbWgCuELNscBxJHgu1/jQUzGjy2 9/a8xnQVCnkVBBBOPp2SCY8/32kY+6xDeNOMpyKEjImy9dJ1/FZBSa7yL8alIPyKeh rkABjQVF1QlX8o7N07UeTmmXpZfXxHh5jZlXFw6EhjVBnkG030GYBkDOY/z5H6rdS5 kB87A8W4CCv4w== Received: from dpdk-test7.liberouter.org (rt-tmc-kou.liberouter.org [195.113.172.126]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by office2.cesnet.cz (Postfix) with ESMTPSA id F277C1180080; Mon, 19 Aug 2024 07:23:41 +0200 (CEST) From: Kamil Vojanec To: dev@dpdk.org Cc: Kamil Vojanec , Cristian Dumitrescu Subject: [RFC] table: report victim replace stats in LRU tables Date: Mon, 19 Aug 2024 07:23:30 +0200 Message-ID: <20240819052330.46122-1-vojanec@cesnet.cz> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20240816115848.432547-1-vojanec@cesnet.cz> References: <20240816115848.432547-1-vojanec@cesnet.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org LRU caches replace records when requested table bucket is full. There is, however, no information about this happening in either the return value or the statistics. This commit introduces a counter for such cases. Signed-off-by: Kamil Vojanec --- 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..bebaec8f71 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..29ef61249b 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..187acb5e24 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..f4d07bc4e0 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