[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230609151332.263152-3-pctammela@mojatatu.com>
Date: Fri, 9 Jun 2023 12:13:30 -0300
From: Pedro Tammela <pctammela@...atatu.com>
To: netdev@...r.kernel.org
Cc: tgraf@...g.ch,
herbert@...dor.apana.org.au,
davem@...emloft.net,
dsahern@...nel.org,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
Pedro Tammela <pctammela@...atatu.com>
Subject: [RFC PATCH net-next 2/4] rhashtable: use new length helpers
Use the new length helpers instead of open coding the length read
Signed-off-by: Pedro Tammela <pctammela@...atatu.com>
---
lib/rhashtable.c | 2 +-
lib/test_rhashtable.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 6ae2ba8e06a2..1f8ca27af853 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -390,7 +390,7 @@ static int rhashtable_rehash_alloc(struct rhashtable *ht,
static int rhashtable_shrink(struct rhashtable *ht)
{
struct bucket_table *old_tbl = rht_dereference(ht->tbl, ht);
- unsigned int nelems = atomic_read(&ht->nelems);
+ unsigned int nelems = rhashtable_len(ht);
unsigned int size = 0;
if (nelems)
diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
index c20f6cb4bf55..5853b83d9ad1 100644
--- a/lib/test_rhashtable.c
+++ b/lib/test_rhashtable.c
@@ -199,9 +199,9 @@ static void test_bucket_stats(struct rhashtable *ht, unsigned int entries)
rhashtable_walk_exit(&hti);
pr_info(" Traversal complete: counted=%u, nelems=%u, entries=%d, table-jumps=%u\n",
- total, atomic_read(&ht->nelems), entries, chain_len);
+ total, rhashtable_len(ht), entries, chain_len);
- if (total != atomic_read(&ht->nelems) || total != entries)
+ if (total != rhashtable_len(ht) || total != entries)
pr_warn("Test failed: Total count mismatch ^^^");
}
--
2.39.2
Powered by blists - more mailing lists