All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] test_rhashtable: Add missing rcu_read_lock()
@ 2018-03-08 11:54 Paul Blakey
  2018-03-08 15:58 ` Herbert Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Blakey @ 2018-03-08 11:54 UTC (permalink / raw)
  To: Thomas Graf, Herbert Xu, David Miller; +Cc: netdev, Paul Blakey

Suppress "suspicious rcu_dereference_protected() usage!" on duplicate
insertion test.

Fixes: 499ac3b60f65 ('test_rhashtable: add test case for rhl_table with duplicate objects')
Signed-off-by: Paul Blakey <paulb@mellanox.com>
---
 lib/test_rhashtable.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c
index f4000c1..727d3ec 100644
--- a/lib/test_rhashtable.c
+++ b/lib/test_rhashtable.c
@@ -498,14 +498,16 @@ static unsigned int __init print_ht(struct rhltable *rhlt)
 	char buff[512] = "";
 	unsigned int i, cnt = 0;
 
+	rcu_read_lock();
+
 	ht = &rhlt->ht;
-	tbl = rht_dereference(ht->tbl, ht);
+	tbl = rht_dereference_rcu(ht->tbl, ht);
 	for (i = 0; i < tbl->size; i++) {
 		struct rhash_head *pos, *next;
 		struct test_obj_rhl *p;
 
-		pos = rht_dereference(tbl->buckets[i], ht);
-		next = !rht_is_a_nulls(pos) ? rht_dereference(pos->next, ht) : NULL;
+		pos = rht_dereference_rcu(tbl->buckets[i], ht);
+		next = !rht_is_a_nulls(pos) ? rht_dereference_rcu(pos->next, ht) : NULL;
 
 		if (!rht_is_a_nulls(pos)) {
 			sprintf(buff, "%s\nbucket[%d] -> ", buff, i);
@@ -516,7 +518,7 @@ static unsigned int __init print_ht(struct rhltable *rhlt)
 			sprintf(buff, "%s[[", buff);
 			do {
 				pos = &list->rhead;
-				list = rht_dereference(list->next, ht);
+				list = rht_dereference_rcu(list->next, ht);
 				p = rht_obj(ht, pos);
 
 				sprintf(buff, "%s val %d (tid=%d)%s", buff, p->value.id, p->value.tid,
@@ -526,13 +528,15 @@ static unsigned int __init print_ht(struct rhltable *rhlt)
 
 			pos = next,
 			next = !rht_is_a_nulls(pos) ?
-				rht_dereference(pos->next, ht) : NULL;
+				rht_dereference_rcu(pos->next, ht) : NULL;
 
 			sprintf(buff, "%s]]%s", buff, !rht_is_a_nulls(pos) ? " -> " : "");
 		}
 	}
 	printk(KERN_ERR "\n---- ht: ----%s\n-------------\n", buff);
 
+	rcu_read_unlock();
+
 	return cnt;
 }
 
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-09 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-08 11:54 [PATCH net] test_rhashtable: Add missing rcu_read_lock() Paul Blakey
2018-03-08 15:58 ` Herbert Xu
2018-03-08 17:10   ` Paul Blakey
2018-03-09 15:04     ` Herbert Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.