1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * iteration_check_2.c: Check that deleting a tagged entry doesn't cause
4 * an RCU walker to finish early.
5 * Copyright (c) 2020 Oracle
11 static volatile bool test_complete;
13 static void *iterator(void *arg)
15 XA_STATE(xas, arg, 0);
18 rcu_register_thread();
20 while (!test_complete) {
23 xas_for_each_marked(&xas, entry, ULONG_MAX, XA_MARK_0)
26 assert(xas.xa_index >= 100);
29 rcu_unregister_thread();
33 static void *throbber(void *arg)
35 struct xarray *xa = arg;
37 rcu_register_thread();
39 while (!test_complete) {
42 for (i = 0; i < 100; i++) {
43 xa_store(xa, i, xa_mk_value(i), GFP_KERNEL);
44 xa_set_mark(xa, i, XA_MARK_0);
46 for (i = 0; i < 100; i++)
50 rcu_unregister_thread();
54 void iteration_test2(unsigned test_duration)
60 printv(1, "Running iteration test 2 for %d seconds\n", test_duration);
62 test_complete = false;
64 xa_store(&array, 100, xa_mk_value(100), GFP_KERNEL);
65 xa_set_mark(&array, 100, XA_MARK_0);
67 if (pthread_create(&threads[0], NULL, iterator, &array)) {
68 perror("create iterator thread");
71 if (pthread_create(&threads[1], NULL, throbber, &array)) {
72 perror("create throbber thread");
79 for (i = 0; i < 2; i++) {
80 if (pthread_join(threads[i], NULL)) {
81 perror("pthread_join");