diff options
author | Matthew Wilcox <willy@infradead.org> | 2018-04-09 16:52:21 -0400 |
---|---|---|
committer | Matthew Wilcox <willy@infradead.org> | 2018-10-21 10:46:45 -0400 |
commit | adb9d9c4ccb1ff0bf1d376e65f36aa5573c75c1a (patch) | |
tree | 3d95a5cfd046858380eea28aba8042ba545067b1 | |
parent | 8cf2f98411e3a0865026a1061af637161b16d32b (diff) |
radix tree: Remove radix_tree_clear_tags
The page cache was the only user of this interface and it has now
been converted to the XArray. Transform the test into a test of
xas_init_marks().
Signed-off-by: Matthew Wilcox <willy@infradead.org>
-rw-r--r-- | include/linux/radix-tree.h | 2 | ||||
-rw-r--r-- | lib/radix-tree.c | 13 | ||||
-rw-r--r-- | lib/test_xarray.c | 40 | ||||
-rw-r--r-- | tools/testing/radix-tree/tag_check.c | 29 |
4 files changed, 40 insertions, 44 deletions
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h index 664d50c5c2ff..7b009af3bb1e 100644 --- a/include/linux/radix-tree.h +++ b/include/linux/radix-tree.h | |||
@@ -252,8 +252,6 @@ void radix_tree_iter_delete(struct radix_tree_root *, | |||
252 | struct radix_tree_iter *iter, void __rcu **slot); | 252 | struct radix_tree_iter *iter, void __rcu **slot); |
253 | void *radix_tree_delete_item(struct radix_tree_root *, unsigned long, void *); | 253 | void *radix_tree_delete_item(struct radix_tree_root *, unsigned long, void *); |
254 | void *radix_tree_delete(struct radix_tree_root *, unsigned long); | 254 | void *radix_tree_delete(struct radix_tree_root *, unsigned long); |
255 | void radix_tree_clear_tags(struct radix_tree_root *, struct radix_tree_node *, | ||
256 | void __rcu **slot); | ||
257 | unsigned int radix_tree_gang_lookup(const struct radix_tree_root *, | 255 | unsigned int radix_tree_gang_lookup(const struct radix_tree_root *, |
258 | void **results, unsigned long first_index, | 256 | void **results, unsigned long first_index, |
259 | unsigned int max_items); | 257 | unsigned int max_items); |
diff --git a/lib/radix-tree.c b/lib/radix-tree.c index b57ddc3dbbbd..e92f2b6ae9c5 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c | |||
@@ -1670,19 +1670,6 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index) | |||
1670 | } | 1670 | } |
1671 | EXPORT_SYMBOL(radix_tree_delete); | 1671 | EXPORT_SYMBOL(radix_tree_delete); |
1672 | 1672 | ||
1673 | void radix_tree_clear_tags(struct radix_tree_root *root, | ||
1674 | struct radix_tree_node *node, | ||
1675 | void __rcu **slot) | ||
1676 | { | ||
1677 | if (node) { | ||
1678 | unsigned int tag, offset = get_slot_offset(node, slot); | ||
1679 | for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) | ||
1680 | node_tag_clear(root, node, tag, offset); | ||
1681 | } else { | ||
1682 | root_tag_clear_all(root); | ||
1683 | } | ||
1684 | } | ||
1685 | |||
1686 | /** | 1673 | /** |
1687 | * radix_tree_tagged - test whether any items in the tree are tagged | 1674 | * radix_tree_tagged - test whether any items in the tree are tagged |
1688 | * @root: radix tree root | 1675 | * @root: radix tree root |
diff --git a/lib/test_xarray.c b/lib/test_xarray.c index 815daffdd8c9..ca86141641cb 100644 --- a/lib/test_xarray.c +++ b/lib/test_xarray.c | |||
@@ -213,12 +213,52 @@ static noinline void check_xa_mark_1(struct xarray *xa, unsigned long index) | |||
213 | XA_BUG_ON(xa, !xa_empty(xa)); | 213 | XA_BUG_ON(xa, !xa_empty(xa)); |
214 | } | 214 | } |
215 | 215 | ||
216 | static noinline void check_xa_mark_2(struct xarray *xa) | ||
217 | { | ||
218 | XA_STATE(xas, xa, 0); | ||
219 | unsigned long index; | ||
220 | unsigned int count = 0; | ||
221 | void *entry; | ||
222 | |||
223 | xa_store_index(xa, 0, GFP_KERNEL); | ||
224 | xa_set_mark(xa, 0, XA_MARK_0); | ||
225 | xas_lock(&xas); | ||
226 | xas_load(&xas); | ||
227 | xas_init_marks(&xas); | ||
228 | xas_unlock(&xas); | ||
229 | XA_BUG_ON(xa, !xa_get_mark(xa, 0, XA_MARK_0) == 0); | ||
230 | |||
231 | for (index = 3500; index < 4500; index++) { | ||
232 | xa_store_index(xa, index, GFP_KERNEL); | ||
233 | xa_set_mark(xa, index, XA_MARK_0); | ||
234 | } | ||
235 | |||
236 | xas_reset(&xas); | ||
237 | rcu_read_lock(); | ||
238 | xas_for_each_marked(&xas, entry, ULONG_MAX, XA_MARK_0) | ||
239 | count++; | ||
240 | rcu_read_unlock(); | ||
241 | XA_BUG_ON(xa, count != 1000); | ||
242 | |||
243 | xas_lock(&xas); | ||
244 | xas_for_each(&xas, entry, ULONG_MAX) { | ||
245 | xas_init_marks(&xas); | ||
246 | XA_BUG_ON(xa, !xa_get_mark(xa, xas.xa_index, XA_MARK_0)); | ||
247 | XA_BUG_ON(xa, !xas_get_mark(&xas, XA_MARK_0)); | ||
248 | } | ||
249 | xas_unlock(&xas); | ||
250 | |||
251 | xa_destroy(xa); | ||
252 | } | ||
253 | |||
216 | static noinline void check_xa_mark(struct xarray *xa) | 254 | static noinline void check_xa_mark(struct xarray *xa) |
217 | { | 255 | { |
218 | unsigned long index; | 256 | unsigned long index; |
219 | 257 | ||
220 | for (index = 0; index < 16384; index += 4) | 258 | for (index = 0; index < 16384; index += 4) |
221 | check_xa_mark_1(xa, index); | 259 | check_xa_mark_1(xa, index); |
260 | |||
261 | check_xa_mark_2(xa); | ||
222 | } | 262 | } |
223 | 263 | ||
224 | static noinline void check_xa_shrink(struct xarray *xa) | 264 | static noinline void check_xa_shrink(struct xarray *xa) |
diff --git a/tools/testing/radix-tree/tag_check.c b/tools/testing/radix-tree/tag_check.c index 543181e4847b..56a42f1c5ab0 100644 --- a/tools/testing/radix-tree/tag_check.c +++ b/tools/testing/radix-tree/tag_check.c | |||
@@ -331,34 +331,6 @@ static void single_check(void) | |||
331 | item_kill_tree(&tree); | 331 | item_kill_tree(&tree); |
332 | } | 332 | } |
333 | 333 | ||
334 | void radix_tree_clear_tags_test(void) | ||
335 | { | ||
336 | unsigned long index; | ||
337 | struct radix_tree_node *node; | ||
338 | struct radix_tree_iter iter; | ||
339 | void **slot; | ||
340 | |||
341 | RADIX_TREE(tree, GFP_KERNEL); | ||
342 | |||
343 | item_insert(&tree, 0); | ||
344 | item_tag_set(&tree, 0, 0); | ||
345 | __radix_tree_lookup(&tree, 0, &node, &slot); | ||
346 | radix_tree_clear_tags(&tree, node, slot); | ||
347 | assert(item_tag_get(&tree, 0, 0) == 0); | ||
348 | |||
349 | for (index = 0; index < 1000; index++) { | ||
350 | item_insert(&tree, index); | ||
351 | item_tag_set(&tree, index, 0); | ||
352 | } | ||
353 | |||
354 | radix_tree_for_each_slot(slot, &tree, &iter, 0) { | ||
355 | radix_tree_clear_tags(&tree, iter.node, slot); | ||
356 | assert(item_tag_get(&tree, iter.index, 0) == 0); | ||
357 | } | ||
358 | |||
359 | item_kill_tree(&tree); | ||
360 | } | ||
361 | |||
362 | void tag_check(void) | 334 | void tag_check(void) |
363 | { | 335 | { |
364 | single_check(); | 336 | single_check(); |
@@ -376,5 +348,4 @@ void tag_check(void) | |||
376 | thrash_tags(); | 348 | thrash_tags(); |
377 | rcu_barrier(); | 349 | rcu_barrier(); |
378 | printv(2, "after thrash_tags: %d allocated\n", nr_allocated); | 350 | printv(2, "after thrash_tags: %d allocated\n", nr_allocated); |
379 | radix_tree_clear_tags_test(); | ||
380 | } | 351 | } |