Skip to content

Commit 847d357

Browse files
Matthew Wilcoxtorvalds
authored andcommitted
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>
1 parent 31023cd commit 847d357

3 files changed

Lines changed: 24 additions & 13 deletions

File tree

‎tools/testing/radix-tree/linux.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <urcu/uatomic.h>
1010

1111
int nr_allocated;
12+
int preempt_count;
1213

1314
void *mempool_alloc(mempool_t *pool, int gfp_mask)
1415
{
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* */
1+
extern int preempt_count;
22

3-
#define preempt_disable() do { } while (0)
4-
#define preempt_enable() do { } while (0)
3+
#define preempt_disable() uatomic_inc(&preempt_count)
4+
#define preempt_enable() uatomic_dec(&preempt_count)

‎tools/testing/radix-tree/main.c‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -293,27 +293,36 @@ static void single_thread_tests(bool long_run)
293293
{
294294
int i;
295295

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);
297298
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);
299301
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);
301304
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);
303307
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);
305310
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);
307313
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);
309316
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);
311319
for (i = 0; i < (long_run ? 2000 : 3); i++) {
312320
copy_tag_check();
313321
printf("%d ", i);
314322
fflush(stdout);
315323
}
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);
317326
}
318327

319328
int main(int argc, char **argv)
@@ -336,7 +345,8 @@ int main(int argc, char **argv)
336345
single_thread_tests(long_run);
337346

338347
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);
340350
rcu_unregister_thread();
341351

342352
exit(0);

0 commit comments

Comments
 (0)