aboutsummaryrefslogtreecommitdiffstats
path: root/lib/radix-tree.c
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@infradead.org>2018-05-19 16:47:47 -0400
committerMatthew Wilcox <willy@infradead.org>2018-10-21 10:46:45 -0400
commit8cf2f98411e3a0865026a1061af637161b16d32b (patch)
treeed49f09ff29328f2567f27fac978ca62e8993375 /lib/radix-tree.c
parent2956c6644bfd9aab9f6b21a12e1bd75876d9dd73 (diff)
radix tree: Remove radix_tree_maybe_preload_order
This function was only used by the page cache which is now converted to the XArray. Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'lib/radix-tree.c')
-rw-r--r--lib/radix-tree.c74
1 files changed, 0 insertions, 74 deletions
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index c52e0bef5264..b57ddc3dbbbd 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -41,9 +41,6 @@
41#include <linux/xarray.h> 41#include <linux/xarray.h>
42 42
43 43
44/* Number of nodes in fully populated tree of given height */
45static unsigned long height_to_maxnodes[RADIX_TREE_MAX_PATH + 1] __read_mostly;
46
47/* 44/*
48 * Radix tree node cache. 45 * Radix tree node cache.
49 */ 46 */
@@ -415,51 +412,6 @@ int radix_tree_maybe_preload(gfp_t gfp_mask)
415} 412}
416EXPORT_SYMBOL(radix_tree_maybe_preload); 413EXPORT_SYMBOL(radix_tree_maybe_preload);
417 414
418/*
419 * The same as function above, but preload number of nodes required to insert
420 * (1 << order) continuous naturally-aligned elements.
421 */
422int radix_tree_maybe_preload_order(gfp_t gfp_mask, int order)
423{
424 unsigned long nr_subtrees;
425 int nr_nodes, subtree_height;
426
427 /* Preloading doesn't help anything with this gfp mask, skip it */
428 if (!gfpflags_allow_blocking(gfp_mask)) {
429 preempt_disable();
430 return 0;
431 }
432
433 /*
434 * Calculate number and height of fully populated subtrees it takes to
435 * store (1 << order) elements.
436 */
437 nr_subtrees = 1 << order;
438 for (subtree_height = 0; nr_subtrees > RADIX_TREE_MAP_SIZE;
439 subtree_height++)
440 nr_subtrees >>= RADIX_TREE_MAP_SHIFT;
441
442 /*
443 * The worst case is zero height tree with a single item at index 0 and
444 * then inserting items starting at ULONG_MAX - (1 << order).
445 *
446 * This requires RADIX_TREE_MAX_PATH nodes to build branch from root to
447 * 0-index item.
448 */
449 nr_nodes = RADIX_TREE_MAX_PATH;
450
451 /* Plus branch to fully populated subtrees. */
452 nr_nodes += RADIX_TREE_MAX_PATH - subtree_height;
453
454 /* Root node is shared. */
455 nr_nodes--;
456
457 /* Plus nodes required to build subtrees. */
458 nr_nodes += nr_subtrees * height_to_maxnodes[subtree_height];
459
460 return __radix_tree_preload(gfp_mask, nr_nodes);
461}
462
463static unsigned radix_tree_load_root(const struct radix_tree_root *root, 415static unsigned radix_tree_load_root(const struct radix_tree_root *root,
464 struct radix_tree_node **nodep, unsigned long *maxindex) 416 struct radix_tree_node **nodep, unsigned long *maxindex)
465{ 417{
@@ -1859,31 +1811,6 @@ radix_tree_node_ctor(void *arg)
1859 INIT_LIST_HEAD(&node->private_list); 1811 INIT_LIST_HEAD(&node->private_list);
1860} 1812}
1861 1813
1862static __init unsigned long __maxindex(unsigned int height)
1863{
1864 unsigned int width = height * RADIX_TREE_MAP_SHIFT;
1865 int shift = RADIX_TREE_INDEX_BITS - width;
1866
1867 if (shift < 0)
1868 return ~0UL;
1869 if (shift >= BITS_PER_LONG)
1870 return 0UL;
1871 return ~0UL >> shift;
1872}
1873
1874static __init void radix_tree_init_maxnodes(void)
1875{
1876 unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH + 1];
1877 unsigned int i, j;
1878
1879 for (i = 0; i < ARRAY_SIZE(height_to_maxindex); i++)
1880 height_to_maxindex[i] = __maxindex(i);
1881 for (i = 0; i < ARRAY_SIZE(height_to_maxnodes); i++) {
1882 for (j = i; j > 0; j--)
1883 height_to_maxnodes[i] += height_to_maxindex[j - 1] + 1;
1884 }
1885}
1886
1887static int radix_tree_cpu_dead(unsigned int cpu) 1814static int radix_tree_cpu_dead(unsigned int cpu)
1888{ 1815{
1889 struct radix_tree_preload *rtp; 1816 struct radix_tree_preload *rtp;
@@ -1911,7 +1838,6 @@ void __init radix_tree_init(void)
1911 sizeof(struct radix_tree_node), 0, 1838 sizeof(struct radix_tree_node), 0,
1912 SLAB_PANIC | SLAB_RECLAIM_ACCOUNT, 1839 SLAB_PANIC | SLAB_RECLAIM_ACCOUNT,
1913 radix_tree_node_ctor); 1840 radix_tree_node_ctor);
1914 radix_tree_init_maxnodes();
1915 ret = cpuhp_setup_state_nocalls(CPUHP_RADIX_DEAD, "lib/radix:dead", 1841 ret = cpuhp_setup_state_nocalls(CPUHP_RADIX_DEAD, "lib/radix:dead",
1916 NULL, radix_tree_cpu_dead); 1842 NULL, radix_tree_cpu_dead);
1917 WARN_ON(ret < 0); 1843 WARN_ON(ret < 0);