idr test suite: Take RCU read lock in idr_find_test_1

When run on a single CPU, this test would frequently access already-freed
memory.  Due to timing, this bug never showed up on multi-CPU tests.
Reported-by: default avatarChris von Recklinghausen <crecklin@redhat.com>
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
parent 1bb4bd26
...@@ -306,11 +306,15 @@ void idr_find_test_1(int anchor_id, int throbber_id) ...@@ -306,11 +306,15 @@ void idr_find_test_1(int anchor_id, int throbber_id)
BUG_ON(idr_alloc(&find_idr, xa_mk_value(anchor_id), anchor_id, BUG_ON(idr_alloc(&find_idr, xa_mk_value(anchor_id), anchor_id,
anchor_id + 1, GFP_KERNEL) != anchor_id); anchor_id + 1, GFP_KERNEL) != anchor_id);
rcu_read_lock();
do { do {
int id = 0; int id = 0;
void *entry = idr_get_next(&find_idr, &id); void *entry = idr_get_next(&find_idr, &id);
rcu_read_unlock();
BUG_ON(entry != xa_mk_value(id)); BUG_ON(entry != xa_mk_value(id));
rcu_read_lock();
} while (time(NULL) < start + 11); } while (time(NULL) < start + 11);
rcu_read_unlock();
pthread_join(throbber, NULL); pthread_join(throbber, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment