Skip to content

Commit

Permalink
idr test suite: Take RCU read lock in idr_find_test_1
Browse files Browse the repository at this point in the history
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: Chris von Recklinghausen <[email protected]>
Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
  • Loading branch information
Matthew Wilcox (Oracle) committed Apr 1, 2021
1 parent 1bb4bd2 commit 7035864
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/testing/radix-tree/idr-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
anchor_id + 1, GFP_KERNEL) != anchor_id);

rcu_read_lock();
do {
int id = 0;
void *entry = idr_get_next(&find_idr, &id);
rcu_read_unlock();
BUG_ON(entry != xa_mk_value(id));
rcu_read_lock();
} while (time(NULL) < start + 11);
rcu_read_unlock();

pthread_join(throbber, NULL);

Expand Down

0 comments on commit 7035864

Please sign in to comment.