Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

radix tree test suite: Test radix_tree_replace_slot() for multiorder entries

When we replace a multiorder entry, check that all indices reflect the
new value.

Also, compile the test suite with -O2, which shows other problems with
the code due to some dodgy pointer operations in the radix tree code.

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Matthew Wilcox and committed by
Linus Torvalds
62fd5258 9c0e28a7

+13 -5
+1 -1
tools/testing/radix-tree/Makefile
··· 1 1 2 - CFLAGS += -I. -g -Wall -D_LGPL_SOURCE 2 + CFLAGS += -I. -g -O2 -Wall -D_LGPL_SOURCE 3 3 LDFLAGS += -lpthread -lurcu 4 4 TARGETS = main 5 5 OFILES = main.o radix-tree.o linux.o test.o tag_check.o find_next_bit.o \
+12 -4
tools/testing/radix-tree/multiorder.c
··· 124 124 unsigned long i; 125 125 unsigned long min = index & ~((1UL << order) - 1); 126 126 unsigned long max = min + (1UL << order); 127 + void **slot; 128 + struct item *item2 = item_create(min); 127 129 RADIX_TREE(tree, GFP_KERNEL); 128 130 129 131 printf("Multiorder index %ld, order %d\n", index, order); ··· 141 139 item_check_absent(&tree, i); 142 140 for (i = max; i < 2*max; i++) 143 141 item_check_absent(&tree, i); 142 + for (i = min; i < max; i++) 143 + assert(radix_tree_insert(&tree, i, item2) == -EEXIST); 144 + 145 + slot = radix_tree_lookup_slot(&tree, index); 146 + free(*slot); 147 + radix_tree_replace_slot(slot, item2); 144 148 for (i = min; i < max; i++) { 145 - static void *entry = (void *) 146 - (0xA0 | RADIX_TREE_EXCEPTIONAL_ENTRY); 147 - assert(radix_tree_insert(&tree, i, entry) == -EEXIST); 149 + struct item *item = item_lookup(&tree, i); 150 + assert(item != 0); 151 + assert(item->index == min); 148 152 } 149 153 150 - assert(item_delete(&tree, index) != 0); 154 + assert(item_delete(&tree, min) != 0); 151 155 152 156 for (i = 0; i < 2*max; i++) 153 157 item_check_absent(&tree, i);