aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2016-12-14 18:08:52 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-14 19:04:10 -0500
commit478922e2b0f41567e4a530771bfb3f693f857d45 (patch)
tree61a6204f2983f8b864a82b4f255127897df351cb /tools
parent148deab223b23734069abcacb5c7118b0e7deadc (diff)
radix-tree: delete radix_tree_locate_item()
This rather complicated function can be better implemented as an iterator. It has only one caller, so move the functionality to the only place that needs it. Update the test suite to follow the same pattern. Link: http://lkml.kernel.org/r/1480369871-5271-56-git-send-email-mawilcox@linuxonhyperv.com Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Acked-by: Konstantin Khlebnikov <koct9i@gmail.com> Tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.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')
-rw-r--r--tools/testing/radix-tree/main.c8
-rw-r--r--tools/testing/radix-tree/test.c22
-rw-r--r--tools/testing/radix-tree/test.h2
3 files changed, 28 insertions, 4 deletions
diff --git a/tools/testing/radix-tree/main.c b/tools/testing/radix-tree/main.c
index 76d9c95aa487..a028dae8a043 100644
--- a/tools/testing/radix-tree/main.c
+++ b/tools/testing/radix-tree/main.c
@@ -239,7 +239,7 @@ static void __locate_check(struct radix_tree_root *tree, unsigned long index,
239 239
240 item_insert_order(tree, index, order); 240 item_insert_order(tree, index, order);
241 item = item_lookup(tree, index); 241 item = item_lookup(tree, index);
242 index2 = radix_tree_locate_item(tree, item); 242 index2 = find_item(tree, item);
243 if (index != index2) { 243 if (index != index2) {
244 printf("index %ld order %d inserted; found %ld\n", 244 printf("index %ld order %d inserted; found %ld\n",
245 index, order, index2); 245 index, order, index2);
@@ -273,17 +273,17 @@ static void locate_check(void)
273 index += (1UL << order)) { 273 index += (1UL << order)) {
274 __locate_check(&tree, index + offset, order); 274 __locate_check(&tree, index + offset, order);
275 } 275 }
276 if (radix_tree_locate_item(&tree, &tree) != -1) 276 if (find_item(&tree, &tree) != -1)
277 abort(); 277 abort();
278 278
279 item_kill_tree(&tree); 279 item_kill_tree(&tree);
280 } 280 }
281 } 281 }
282 282
283 if (radix_tree_locate_item(&tree, &tree) != -1) 283 if (find_item(&tree, &tree) != -1)
284 abort(); 284 abort();
285 __locate_check(&tree, -1, 0); 285 __locate_check(&tree, -1, 0);
286 if (radix_tree_locate_item(&tree, &tree) != -1) 286 if (find_item(&tree, &tree) != -1)
287 abort(); 287 abort();
288 item_kill_tree(&tree); 288 item_kill_tree(&tree);
289} 289}
diff --git a/tools/testing/radix-tree/test.c b/tools/testing/radix-tree/test.c
index 0de548939a2e..88bf57f7175e 100644
--- a/tools/testing/radix-tree/test.c
+++ b/tools/testing/radix-tree/test.c
@@ -151,6 +151,28 @@ void item_full_scan(struct radix_tree_root *root, unsigned long start,
151 assert(nfound == 0); 151 assert(nfound == 0);
152} 152}
153 153
154/* Use the same pattern as find_swap_entry() in mm/shmem.c */
155unsigned long find_item(struct radix_tree_root *root, void *item)
156{
157 struct radix_tree_iter iter;
158 void **slot;
159 unsigned long found = -1;
160 unsigned long checked = 0;
161
162 radix_tree_for_each_slot(slot, root, &iter, 0) {
163 if (*slot == item) {
164 found = iter.index;
165 break;
166 }
167 checked++;
168 if ((checked % 4) != 0)
169 continue;
170 slot = radix_tree_iter_resume(slot, &iter);
171 }
172
173 return found;
174}
175
154static int verify_node(struct radix_tree_node *slot, unsigned int tag, 176static int verify_node(struct radix_tree_node *slot, unsigned int tag,
155 int tagged) 177 int tagged)
156{ 178{
diff --git a/tools/testing/radix-tree/test.h b/tools/testing/radix-tree/test.h
index 617416ec3c5e..3d9d1d30da22 100644
--- a/tools/testing/radix-tree/test.h
+++ b/tools/testing/radix-tree/test.h
@@ -25,6 +25,8 @@ void item_full_scan(struct radix_tree_root *root, unsigned long start,
25 unsigned long nr, int chunk); 25 unsigned long nr, int chunk);
26void item_kill_tree(struct radix_tree_root *root); 26void item_kill_tree(struct radix_tree_root *root);
27 27
28unsigned long find_item(struct radix_tree_root *, void *item);
29
28void tag_check(void); 30void tag_check(void);
29void multiorder_checks(void); 31void multiorder_checks(void);
30void iteration_test(void); 32void iteration_test(void);