Commit 8cf2f984 authored by Matthew Wilcox's avatar Matthew Wilcox

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: default avatarMatthew Wilcox <willy@infradead.org>
parent 2956c664
...@@ -259,7 +259,6 @@ unsigned int radix_tree_gang_lookup(const struct radix_tree_root *, ...@@ -259,7 +259,6 @@ unsigned int radix_tree_gang_lookup(const struct radix_tree_root *,
unsigned int max_items); unsigned int max_items);
int radix_tree_preload(gfp_t gfp_mask); int radix_tree_preload(gfp_t gfp_mask);
int radix_tree_maybe_preload(gfp_t gfp_mask); int radix_tree_maybe_preload(gfp_t gfp_mask);
int radix_tree_maybe_preload_order(gfp_t gfp_mask, int order);
void radix_tree_init(void); void radix_tree_init(void);
void *radix_tree_tag_set(struct radix_tree_root *, void *radix_tree_tag_set(struct radix_tree_root *,
unsigned long index, unsigned int tag); unsigned long index, unsigned int tag);
......
...@@ -41,9 +41,6 @@ ...@@ -41,9 +41,6 @@
#include <linux/xarray.h> #include <linux/xarray.h>
/* Number of nodes in fully populated tree of given height */
static unsigned long height_to_maxnodes[RADIX_TREE_MAX_PATH + 1] __read_mostly;
/* /*
* Radix tree node cache. * Radix tree node cache.
*/ */
...@@ -415,51 +412,6 @@ int radix_tree_maybe_preload(gfp_t gfp_mask) ...@@ -415,51 +412,6 @@ int radix_tree_maybe_preload(gfp_t gfp_mask)
} }
EXPORT_SYMBOL(radix_tree_maybe_preload); EXPORT_SYMBOL(radix_tree_maybe_preload);
/*
* The same as function above, but preload number of nodes required to insert
* (1 << order) continuous naturally-aligned elements.
*/
int radix_tree_maybe_preload_order(gfp_t gfp_mask, int order)
{
unsigned long nr_subtrees;
int nr_nodes, subtree_height;
/* Preloading doesn't help anything with this gfp mask, skip it */
if (!gfpflags_allow_blocking(gfp_mask)) {
preempt_disable();
return 0;
}
/*
* Calculate number and height of fully populated subtrees it takes to
* store (1 << order) elements.
*/
nr_subtrees = 1 << order;
for (subtree_height = 0; nr_subtrees > RADIX_TREE_MAP_SIZE;
subtree_height++)
nr_subtrees >>= RADIX_TREE_MAP_SHIFT;
/*
* The worst case is zero height tree with a single item at index 0 and
* then inserting items starting at ULONG_MAX - (1 << order).
*
* This requires RADIX_TREE_MAX_PATH nodes to build branch from root to
* 0-index item.
*/
nr_nodes = RADIX_TREE_MAX_PATH;
/* Plus branch to fully populated subtrees. */
nr_nodes += RADIX_TREE_MAX_PATH - subtree_height;
/* Root node is shared. */
nr_nodes--;
/* Plus nodes required to build subtrees. */
nr_nodes += nr_subtrees * height_to_maxnodes[subtree_height];
return __radix_tree_preload(gfp_mask, nr_nodes);
}
static unsigned radix_tree_load_root(const struct radix_tree_root *root, static unsigned radix_tree_load_root(const struct radix_tree_root *root,
struct radix_tree_node **nodep, unsigned long *maxindex) struct radix_tree_node **nodep, unsigned long *maxindex)
{ {
...@@ -1859,31 +1811,6 @@ radix_tree_node_ctor(void *arg) ...@@ -1859,31 +1811,6 @@ radix_tree_node_ctor(void *arg)
INIT_LIST_HEAD(&node->private_list); INIT_LIST_HEAD(&node->private_list);
} }
static __init unsigned long __maxindex(unsigned int height)
{
unsigned int width = height * RADIX_TREE_MAP_SHIFT;
int shift = RADIX_TREE_INDEX_BITS - width;
if (shift < 0)
return ~0UL;
if (shift >= BITS_PER_LONG)
return 0UL;
return ~0UL >> shift;
}
static __init void radix_tree_init_maxnodes(void)
{
unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH + 1];
unsigned int i, j;
for (i = 0; i < ARRAY_SIZE(height_to_maxindex); i++)
height_to_maxindex[i] = __maxindex(i);
for (i = 0; i < ARRAY_SIZE(height_to_maxnodes); i++) {
for (j = i; j > 0; j--)
height_to_maxnodes[i] += height_to_maxindex[j - 1] + 1;
}
}
static int radix_tree_cpu_dead(unsigned int cpu) static int radix_tree_cpu_dead(unsigned int cpu)
{ {
struct radix_tree_preload *rtp; struct radix_tree_preload *rtp;
...@@ -1911,7 +1838,6 @@ void __init radix_tree_init(void) ...@@ -1911,7 +1838,6 @@ void __init radix_tree_init(void)
sizeof(struct radix_tree_node), 0, sizeof(struct radix_tree_node), 0,
SLAB_PANIC | SLAB_RECLAIM_ACCOUNT, SLAB_PANIC | SLAB_RECLAIM_ACCOUNT,
radix_tree_node_ctor); radix_tree_node_ctor);
radix_tree_init_maxnodes();
ret = cpuhp_setup_state_nocalls(CPUHP_RADIX_DEAD, "lib/radix:dead", ret = cpuhp_setup_state_nocalls(CPUHP_RADIX_DEAD, "lib/radix:dead",
NULL, radix_tree_cpu_dead); NULL, radix_tree_cpu_dead);
WARN_ON(ret < 0); WARN_ON(ret < 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment