]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
radix tree test suite: track preempt_count
authorMatthew Wilcox <willy@infradead.org>
Wed, 14 Dec 2016 23:08:02 +0000 (15:08 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 15 Dec 2016 00:04:09 +0000 (16:04 -0800)
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>
tools/testing/radix-tree/linux.c
tools/testing/radix-tree/linux/preempt.h
tools/testing/radix-tree/main.c

index 3cfb04e98e2f3eaea845fc25bc7aa132ee52f945..1f32a16a3848c7bc4f30eae6613191e06a0322d3 100644 (file)
@@ -9,6 +9,7 @@
 #include <urcu/uatomic.h>
 
 int nr_allocated;
+int preempt_count;
 
 void *mempool_alloc(mempool_t *pool, int gfp_mask)
 {
index 6210672e3baa5c1d2b01075b5ef68e46be975463..65c04c226965d9a0816f889103f42a24957f3fc8 100644 (file)
@@ -1,4 +1,4 @@
-/* */
+extern int preempt_count;
 
-#define preempt_disable() do { } while (0)
-#define preempt_enable() do { } while (0)
+#define preempt_disable()      uatomic_inc(&preempt_count)
+#define preempt_enable()       uatomic_dec(&preempt_count)
index daa9010693e8374148a57481285f7fbc457a1356..64ffe67605d46b48c97a6718bf2ddbdb35164aec 100644 (file)
@@ -293,27 +293,36 @@ static void single_thread_tests(bool long_run)
 {
        int i;
 
-       printf("starting single_thread_tests: %d allocated\n", nr_allocated);
+       printf("starting single_thread_tests: %d allocated, preempt %d\n",
+               nr_allocated, preempt_count);
        multiorder_checks();
-       printf("after multiorder_check: %d allocated\n", nr_allocated);
+       printf("after multiorder_check: %d allocated, preempt %d\n",
+               nr_allocated, preempt_count);
        locate_check();
-       printf("after locate_check: %d allocated\n", nr_allocated);
+       printf("after locate_check: %d allocated, preempt %d\n",
+               nr_allocated, preempt_count);
        tag_check();
-       printf("after tag_check: %d allocated\n", nr_allocated);
+       printf("after tag_check: %d allocated, preempt %d\n",
+               nr_allocated, preempt_count);
        gang_check();
-       printf("after gang_check: %d allocated\n", nr_allocated);
+       printf("after gang_check: %d allocated, preempt %d\n",
+               nr_allocated, preempt_count);
        add_and_check();
-       printf("after add_and_check: %d allocated\n", nr_allocated);
+       printf("after add_and_check: %d allocated, preempt %d\n",
+               nr_allocated, preempt_count);
        dynamic_height_check();
-       printf("after dynamic_height_check: %d allocated\n", nr_allocated);
+       printf("after dynamic_height_check: %d allocated, preempt %d\n",
+               nr_allocated, preempt_count);
        big_gang_check(long_run);
-       printf("after big_gang_check: %d allocated\n", nr_allocated);
+       printf("after big_gang_check: %d allocated, preempt %d\n",
+               nr_allocated, preempt_count);
        for (i = 0; i < (long_run ? 2000 : 3); i++) {
                copy_tag_check();
                printf("%d ", i);
                fflush(stdout);
        }
-       printf("after copy_tag_check: %d allocated\n", nr_allocated);
+       printf("after copy_tag_check: %d allocated, preempt %d\n",
+               nr_allocated, preempt_count);
 }
 
 int main(int argc, char **argv)
@@ -336,7 +345,8 @@ int main(int argc, char **argv)
        single_thread_tests(long_run);
 
        sleep(1);
-       printf("after sleep(1): %d allocated\n", nr_allocated);
+       printf("after sleep(1): %d allocated, preempt %d\n",
+               nr_allocated, preempt_count);
        rcu_unregister_thread();
 
        exit(0);