aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@infradead.org>2018-04-09 16:24:45 -0400
committerMatthew Wilcox <willy@infradead.org>2018-10-21 10:46:44 -0400
commit1cf56f9d670b88b2e947a7ccdb8ba32e6477915d (patch)
tree3d16b4ccb8ed09ee7a61f0aa50481eccb54a5057 /lib
parenta28334862993b5c6a8766f6963ee69048403817c (diff)
radix tree: Remove radix_tree_update_node_t
The only user of this functionality was the workingset code, and it's now been converted to the XArray. Remove __radix_tree_delete_node() entirely as it was also only used by the workingset code. Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/idr.c2
-rw-r--r--lib/radix-tree.c42
2 files changed, 9 insertions, 35 deletions
diff --git a/lib/idr.c b/lib/idr.c
index 3c20ad9b0463..cb1db9b8d3f6 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -297,7 +297,7 @@ void *idr_replace(struct idr *idr, void *ptr, unsigned long id)
297 if (!slot || radix_tree_tag_get(&idr->idr_rt, id, IDR_FREE)) 297 if (!slot || radix_tree_tag_get(&idr->idr_rt, id, IDR_FREE))
298 return ERR_PTR(-ENOENT); 298 return ERR_PTR(-ENOENT);
299 299
300 __radix_tree_replace(&idr->idr_rt, node, slot, ptr, NULL); 300 __radix_tree_replace(&idr->idr_rt, node, slot, ptr);
301 301
302 return entry; 302 return entry;
303} 303}
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 2f9c0e45eeb7..c4c252185734 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -562,8 +562,7 @@ out:
562 * radix_tree_shrink - shrink radix tree to minimum height 562 * radix_tree_shrink - shrink radix tree to minimum height
563 * @root radix tree root 563 * @root radix tree root
564 */ 564 */
565static inline bool radix_tree_shrink(struct radix_tree_root *root, 565static inline bool radix_tree_shrink(struct radix_tree_root *root)
566 radix_tree_update_node_t update_node)
567{ 566{
568 bool shrunk = false; 567 bool shrunk = false;
569 568
@@ -631,8 +630,6 @@ static inline bool radix_tree_shrink(struct radix_tree_root *root,
631 node->count = 0; 630 node->count = 0;
632 if (!radix_tree_is_internal_node(child)) { 631 if (!radix_tree_is_internal_node(child)) {
633 node->slots[0] = (void __rcu *)RADIX_TREE_RETRY; 632 node->slots[0] = (void __rcu *)RADIX_TREE_RETRY;
634 if (update_node)
635 update_node(node);
636 } 633 }
637 634
638 WARN_ON_ONCE(!list_empty(&node->private_list)); 635 WARN_ON_ONCE(!list_empty(&node->private_list));
@@ -644,8 +641,7 @@ static inline bool radix_tree_shrink(struct radix_tree_root *root,
644} 641}
645 642
646static bool delete_node(struct radix_tree_root *root, 643static bool delete_node(struct radix_tree_root *root,
647 struct radix_tree_node *node, 644 struct radix_tree_node *node)
648 radix_tree_update_node_t update_node)
649{ 645{
650 bool deleted = false; 646 bool deleted = false;
651 647
@@ -655,7 +651,7 @@ static bool delete_node(struct radix_tree_root *root,
655 if (node->count) { 651 if (node->count) {
656 if (node_to_entry(node) == 652 if (node_to_entry(node) ==
657 rcu_dereference_raw(root->xa_head)) 653 rcu_dereference_raw(root->xa_head))
658 deleted |= radix_tree_shrink(root, update_node); 654 deleted |= radix_tree_shrink(root);
659 return deleted; 655 return deleted;
660 } 656 }
661 657
@@ -1059,15 +1055,13 @@ static int calculate_count(struct radix_tree_root *root,
1059 * @node: pointer to tree node 1055 * @node: pointer to tree node
1060 * @slot: pointer to slot in @node 1056 * @slot: pointer to slot in @node
1061 * @item: new item to store in the slot. 1057 * @item: new item to store in the slot.
1062 * @update_node: callback for changing leaf nodes
1063 * 1058 *
1064 * For use with __radix_tree_lookup(). Caller must hold tree write locked 1059 * For use with __radix_tree_lookup(). Caller must hold tree write locked
1065 * across slot lookup and replacement. 1060 * across slot lookup and replacement.
1066 */ 1061 */
1067void __radix_tree_replace(struct radix_tree_root *root, 1062void __radix_tree_replace(struct radix_tree_root *root,
1068 struct radix_tree_node *node, 1063 struct radix_tree_node *node,
1069 void __rcu **slot, void *item, 1064 void __rcu **slot, void *item)
1070 radix_tree_update_node_t update_node)
1071{ 1065{
1072 void *old = rcu_dereference_raw(*slot); 1066 void *old = rcu_dereference_raw(*slot);
1073 int values = !!xa_is_value(item) - !!xa_is_value(old); 1067 int values = !!xa_is_value(item) - !!xa_is_value(old);
@@ -1085,10 +1079,7 @@ void __radix_tree_replace(struct radix_tree_root *root,
1085 if (!node) 1079 if (!node)
1086 return; 1080 return;
1087 1081
1088 if (update_node) 1082 delete_node(root, node);
1089 update_node(node);
1090
1091 delete_node(root, node, update_node);
1092} 1083}
1093 1084
1094/** 1085/**
@@ -1110,7 +1101,7 @@ void __radix_tree_replace(struct radix_tree_root *root,
1110void radix_tree_replace_slot(struct radix_tree_root *root, 1101void radix_tree_replace_slot(struct radix_tree_root *root,
1111 void __rcu **slot, void *item) 1102 void __rcu **slot, void *item)
1112{ 1103{
1113 __radix_tree_replace(root, NULL, slot, item, NULL); 1104 __radix_tree_replace(root, NULL, slot, item);
1114} 1105}
1115EXPORT_SYMBOL(radix_tree_replace_slot); 1106EXPORT_SYMBOL(radix_tree_replace_slot);
1116 1107
@@ -1127,7 +1118,7 @@ void radix_tree_iter_replace(struct radix_tree_root *root,
1127 const struct radix_tree_iter *iter, 1118 const struct radix_tree_iter *iter,
1128 void __rcu **slot, void *item) 1119 void __rcu **slot, void *item)
1129{ 1120{
1130 __radix_tree_replace(root, iter->node, slot, item, NULL); 1121 __radix_tree_replace(root, iter->node, slot, item);
1131} 1122}
1132 1123
1133#ifdef CONFIG_RADIX_TREE_MULTIORDER 1124#ifdef CONFIG_RADIX_TREE_MULTIORDER
@@ -1807,23 +1798,6 @@ radix_tree_gang_lookup_tag_slot(const struct radix_tree_root *root,
1807} 1798}
1808EXPORT_SYMBOL(radix_tree_gang_lookup_tag_slot); 1799EXPORT_SYMBOL(radix_tree_gang_lookup_tag_slot);
1809 1800
1810/**
1811 * __radix_tree_delete_node - try to free node after clearing a slot
1812 * @root: radix tree root
1813 * @node: node containing @index
1814 * @update_node: callback for changing leaf nodes
1815 *
1816 * After clearing the slot at @index in @node from radix tree
1817 * rooted at @root, call this function to attempt freeing the
1818 * node and shrinking the tree.
1819 */
1820void __radix_tree_delete_node(struct radix_tree_root *root,
1821 struct radix_tree_node *node,
1822 radix_tree_update_node_t update_node)
1823{
1824 delete_node(root, node, update_node);
1825}
1826
1827static bool __radix_tree_delete(struct radix_tree_root *root, 1801static bool __radix_tree_delete(struct radix_tree_root *root,
1828 struct radix_tree_node *node, void __rcu **slot) 1802 struct radix_tree_node *node, void __rcu **slot)
1829{ 1803{
@@ -1839,7 +1813,7 @@ static bool __radix_tree_delete(struct radix_tree_root *root,
1839 node_tag_clear(root, node, tag, offset); 1813 node_tag_clear(root, node, tag, offset);
1840 1814
1841 replace_slot(slot, NULL, node, -1, values); 1815 replace_slot(slot, NULL, node, -1, values);
1842 return node && delete_node(root, node, NULL); 1816 return node && delete_node(root, node);
1843} 1817}
1844 1818
1845/** 1819/**