diff options
Diffstat (limited to 'tools/testing/radix-tree/iteration_check.c')
-rw-r--r-- | tools/testing/radix-tree/iteration_check.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/testing/radix-tree/iteration_check.c b/tools/testing/radix-tree/iteration_check.c index 9adb8e7415a6..11d570c3fc83 100644 --- a/tools/testing/radix-tree/iteration_check.c +++ b/tools/testing/radix-tree/iteration_check.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #define TAG 0 | 20 | #define TAG 0 |
21 | static pthread_mutex_t tree_lock = PTHREAD_MUTEX_INITIALIZER; | 21 | static pthread_mutex_t tree_lock = PTHREAD_MUTEX_INITIALIZER; |
22 | static pthread_t threads[NUM_THREADS]; | 22 | static pthread_t threads[NUM_THREADS]; |
23 | static unsigned int seeds[3]; | ||
23 | RADIX_TREE(tree, GFP_KERNEL); | 24 | RADIX_TREE(tree, GFP_KERNEL); |
24 | bool test_complete; | 25 | bool test_complete; |
25 | 26 | ||
@@ -71,7 +72,7 @@ static void *tagged_iteration_fn(void *arg) | |||
71 | continue; | 72 | continue; |
72 | } | 73 | } |
73 | 74 | ||
74 | if (rand() % 50 == 0) | 75 | if (rand_r(&seeds[0]) % 50 == 0) |
75 | slot = radix_tree_iter_next(&iter); | 76 | slot = radix_tree_iter_next(&iter); |
76 | } | 77 | } |
77 | rcu_read_unlock(); | 78 | rcu_read_unlock(); |
@@ -111,7 +112,7 @@ static void *untagged_iteration_fn(void *arg) | |||
111 | continue; | 112 | continue; |
112 | } | 113 | } |
113 | 114 | ||
114 | if (rand() % 50 == 0) | 115 | if (rand_r(&seeds[1]) % 50 == 0) |
115 | slot = radix_tree_iter_next(&iter); | 116 | slot = radix_tree_iter_next(&iter); |
116 | } | 117 | } |
117 | rcu_read_unlock(); | 118 | rcu_read_unlock(); |
@@ -129,7 +130,7 @@ static void *remove_entries_fn(void *arg) | |||
129 | while (!test_complete) { | 130 | while (!test_complete) { |
130 | int pgoff; | 131 | int pgoff; |
131 | 132 | ||
132 | pgoff = rand() % 100; | 133 | pgoff = rand_r(&seeds[2]) % 100; |
133 | 134 | ||
134 | pthread_mutex_lock(&tree_lock); | 135 | pthread_mutex_lock(&tree_lock); |
135 | item_delete(&tree, pgoff); | 136 | item_delete(&tree, pgoff); |
@@ -146,9 +147,11 @@ void iteration_test(void) | |||
146 | 147 | ||
147 | printf("Running iteration tests for 10 seconds\n"); | 148 | printf("Running iteration tests for 10 seconds\n"); |
148 | 149 | ||
149 | srand(time(0)); | ||
150 | test_complete = false; | 150 | test_complete = false; |
151 | 151 | ||
152 | for (i = 0; i < 3; i++) | ||
153 | seeds[i] = rand(); | ||
154 | |||
152 | if (pthread_create(&threads[0], NULL, tagged_iteration_fn, NULL)) { | 155 | if (pthread_create(&threads[0], NULL, tagged_iteration_fn, NULL)) { |
153 | perror("pthread_create"); | 156 | perror("pthread_create"); |
154 | exit(1); | 157 | exit(1); |