radix tree test suite: Register the main thread with the RCU library
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Wed, 31 Mar 2021 18:59:19 +0000 (14:59 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 1 Apr 2021 11:41:30 +0000 (07:41 -0400)
Several test runners register individual worker threads with the
RCU library, but neglect to register the main thread, which can lead
to objects being freed while the main thread is in what appears to be
an RCU critical section.

Reported-by: Chris von Recklinghausen <crecklin@redhat.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
tools/testing/radix-tree/idr-test.c
tools/testing/radix-tree/multiorder.c
tools/testing/radix-tree/xarray.c

index 3b796dd5e5772e828f43f6aee46752c8b6b2e3da..44ceff95a9b3063fd604aaf41d6370a4107cd540 100644 (file)
@@ -577,6 +577,7 @@ void ida_tests(void)
 
 int __weak main(void)
 {
+       rcu_register_thread();
        radix_tree_init();
        idr_checks();
        ida_tests();
@@ -584,5 +585,6 @@ int __weak main(void)
        rcu_barrier();
        if (nr_allocated)
                printf("nr_allocated = %d\n", nr_allocated);
+       rcu_unregister_thread();
        return 0;
 }
index 9eae0fb5a67d1ef746e859958eb247df18a01f21..e00520cc63498d3f670dd8a5677d728f9ca19760 100644 (file)
@@ -224,7 +224,9 @@ void multiorder_checks(void)
 
 int __weak main(void)
 {
+       rcu_register_thread();
        radix_tree_init();
        multiorder_checks();
+       rcu_unregister_thread();
        return 0;
 }
index e61e43efe463cdb0aae7d6efb08066a5d93f59be..f20e12cbbfd407dfaa7ff81ef6e735cb3ae93fbe 100644 (file)
@@ -25,11 +25,13 @@ void xarray_tests(void)
 
 int __weak main(void)
 {
+       rcu_register_thread();
        radix_tree_init();
        xarray_tests();
        radix_tree_cpu_dead(1);
        rcu_barrier();
        if (nr_allocated)
                printf("nr_allocated = %d\n", nr_allocated);
+       rcu_unregister_thread();
        return 0;
 }