diff options
author | Matthew Wilcox <willy@infradead.org> | 2016-12-14 18:08:02 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-12-14 19:04:09 -0500 |
commit | 847d357635ce4c63b8901ab81333586a0f115fa5 (patch) | |
tree | 512d5cb1f6aa8f44a07dbfe8e501297e5b8aebb7 /tools/testing/radix-tree | |
parent | 31023cd66468359790beb046b6808fe0444672a2 (diff) |
radix tree test suite: track preempt_count
Rather than simply NOP out preempt_enable() and preempt_disable(), keep
track of preempt_count and display it regularly in case either the test
suite or the code under test is forgetting to balance the enables &
disables. Only found a test-case that was forgetting to re-enable
preemption, but it's a possibility worth checking.
Link: http://lkml.kernel.org/r/1480369871-5271-39-git-send-email-mawilcox@linuxonhyperv.com
Signed-off-by: Matthew Wilcox <willy@infradead.org>
Tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'tools/testing/radix-tree')
-rw-r--r-- | tools/testing/radix-tree/linux.c | 1 | ||||
-rw-r--r-- | tools/testing/radix-tree/linux/preempt.h | 6 | ||||
-rw-r--r-- | tools/testing/radix-tree/main.c | 30 |
3 files changed, 24 insertions, 13 deletions
diff --git a/tools/testing/radix-tree/linux.c b/tools/testing/radix-tree/linux.c index 3cfb04e98e2f..1f32a16a3848 100644 --- a/tools/testing/radix-tree/linux.c +++ b/tools/testing/radix-tree/linux.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <urcu/uatomic.h> | 9 | #include <urcu/uatomic.h> |
10 | 10 | ||
11 | int nr_allocated; | 11 | int nr_allocated; |
12 | int preempt_count; | ||
12 | 13 | ||
13 | void *mempool_alloc(mempool_t *pool, int gfp_mask) | 14 | void *mempool_alloc(mempool_t *pool, int gfp_mask) |
14 | { | 15 | { |
diff --git a/tools/testing/radix-tree/linux/preempt.h b/tools/testing/radix-tree/linux/preempt.h index 6210672e3baa..65c04c226965 100644 --- a/tools/testing/radix-tree/linux/preempt.h +++ b/tools/testing/radix-tree/linux/preempt.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* */ | 1 | extern int preempt_count; |
2 | 2 | ||
3 | #define preempt_disable() do { } while (0) | 3 | #define preempt_disable() uatomic_inc(&preempt_count) |
4 | #define preempt_enable() do { } while (0) | 4 | #define preempt_enable() uatomic_dec(&preempt_count) |
diff --git a/tools/testing/radix-tree/main.c b/tools/testing/radix-tree/main.c index daa9010693e8..64ffe67605d4 100644 --- a/tools/testing/radix-tree/main.c +++ b/tools/testing/radix-tree/main.c | |||
@@ -293,27 +293,36 @@ static void single_thread_tests(bool long_run) | |||
293 | { | 293 | { |
294 | int i; | 294 | int i; |
295 | 295 | ||
296 | printf("starting single_thread_tests: %d allocated\n", nr_allocated); | 296 | printf("starting single_thread_tests: %d allocated, preempt %d\n", |
297 | nr_allocated, preempt_count); | ||
297 | multiorder_checks(); | 298 | multiorder_checks(); |
298 | printf("after multiorder_check: %d allocated\n", nr_allocated); | 299 | printf("after multiorder_check: %d allocated, preempt %d\n", |
300 | nr_allocated, preempt_count); | ||
299 | locate_check(); | 301 | locate_check(); |
300 | printf("after locate_check: %d allocated\n", nr_allocated); | 302 | printf("after locate_check: %d allocated, preempt %d\n", |
303 | nr_allocated, preempt_count); | ||
301 | tag_check(); | 304 | tag_check(); |
302 | printf("after tag_check: %d allocated\n", nr_allocated); | 305 | printf("after tag_check: %d allocated, preempt %d\n", |
306 | nr_allocated, preempt_count); | ||
303 | gang_check(); | 307 | gang_check(); |
304 | printf("after gang_check: %d allocated\n", nr_allocated); | 308 | printf("after gang_check: %d allocated, preempt %d\n", |
309 | nr_allocated, preempt_count); | ||
305 | add_and_check(); | 310 | add_and_check(); |
306 | printf("after add_and_check: %d allocated\n", nr_allocated); | 311 | printf("after add_and_check: %d allocated, preempt %d\n", |
312 | nr_allocated, preempt_count); | ||
307 | dynamic_height_check(); | 313 | dynamic_height_check(); |
308 | printf("after dynamic_height_check: %d allocated\n", nr_allocated); | 314 | printf("after dynamic_height_check: %d allocated, preempt %d\n", |
315 | nr_allocated, preempt_count); | ||
309 | big_gang_check(long_run); | 316 | big_gang_check(long_run); |
310 | printf("after big_gang_check: %d allocated\n", nr_allocated); | 317 | printf("after big_gang_check: %d allocated, preempt %d\n", |
318 | nr_allocated, preempt_count); | ||
311 | for (i = 0; i < (long_run ? 2000 : 3); i++) { | 319 | for (i = 0; i < (long_run ? 2000 : 3); i++) { |
312 | copy_tag_check(); | 320 | copy_tag_check(); |
313 | printf("%d ", i); | 321 | printf("%d ", i); |
314 | fflush(stdout); | 322 | fflush(stdout); |
315 | } | 323 | } |
316 | printf("after copy_tag_check: %d allocated\n", nr_allocated); | 324 | printf("after copy_tag_check: %d allocated, preempt %d\n", |
325 | nr_allocated, preempt_count); | ||
317 | } | 326 | } |
318 | 327 | ||
319 | int main(int argc, char **argv) | 328 | int main(int argc, char **argv) |
@@ -336,7 +345,8 @@ int main(int argc, char **argv) | |||
336 | single_thread_tests(long_run); | 345 | single_thread_tests(long_run); |
337 | 346 | ||
338 | sleep(1); | 347 | sleep(1); |
339 | printf("after sleep(1): %d allocated\n", nr_allocated); | 348 | printf("after sleep(1): %d allocated, preempt %d\n", |
349 | nr_allocated, preempt_count); | ||
340 | rcu_unregister_thread(); | 350 | rcu_unregister_thread(); |
341 | 351 | ||
342 | exit(0); | 352 | exit(0); |