Commit 57578c2e authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Linus Torvalds

raxix-tree: introduce CONFIG_RADIX_TREE_MULTIORDER

I've been receiving increasingly concerned notes from 0day about how
much my recent changes have been bloating the radix tree.  Make it
happier by only including multiorder support if
CONFIG_TRANSPARENT_HUGEPAGES is set.

This is an independent Kconfig option, so other radix tree users can
also set it if they have a need.
Signed-off-by: default avatarMatthew Wilcox <willy@linux.intel.com>
Reviewed-by: default avatarRoss Zwisler <ross.zwisler@linux.intel.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Kirill Shutemov <kirill.shutemov@linux.intel.com>
Cc: Jan Kara <jack@suse.com>
Cc: Neil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6c4bd68a
...@@ -362,6 +362,9 @@ config INTERVAL_TREE ...@@ -362,6 +362,9 @@ config INTERVAL_TREE
for more information. for more information.
config RADIX_TREE_MULTIORDER
bool
config ASSOCIATIVE_ARRAY config ASSOCIATIVE_ARRAY
bool bool
help help
......
...@@ -484,6 +484,7 @@ int __radix_tree_create(struct radix_tree_root *root, unsigned long index, ...@@ -484,6 +484,7 @@ int __radix_tree_create(struct radix_tree_root *root, unsigned long index,
slot = node->slots[offset]; slot = node->slots[offset];
} }
#ifdef CONFIG_RADIX_TREE_MULTIORDER
/* Insert pointers to the canonical entry */ /* Insert pointers to the canonical entry */
if ((shift - order) > 0) { if ((shift - order) > 0) {
int i, n = 1 << (shift - order); int i, n = 1 << (shift - order);
...@@ -499,6 +500,7 @@ int __radix_tree_create(struct radix_tree_root *root, unsigned long index, ...@@ -499,6 +500,7 @@ int __radix_tree_create(struct radix_tree_root *root, unsigned long index,
node->count++; node->count++;
} }
} }
#endif
if (nodep) if (nodep)
*nodep = node; *nodep = node;
...@@ -1469,6 +1471,20 @@ bool __radix_tree_delete_node(struct radix_tree_root *root, ...@@ -1469,6 +1471,20 @@ bool __radix_tree_delete_node(struct radix_tree_root *root,
return deleted; return deleted;
} }
static inline void delete_sibling_entries(struct radix_tree_node *node,
void *ptr, unsigned offset)
{
#ifdef CONFIG_RADIX_TREE_MULTIORDER
int i;
for (i = 1; offset + i < RADIX_TREE_MAP_SIZE; i++) {
if (node->slots[offset + i] != ptr)
break;
node->slots[offset + i] = NULL;
node->count--;
}
#endif
}
/** /**
* radix_tree_delete_item - delete an item from a radix tree * radix_tree_delete_item - delete an item from a radix tree
* @root: radix tree root * @root: radix tree root
...@@ -1484,7 +1500,7 @@ void *radix_tree_delete_item(struct radix_tree_root *root, ...@@ -1484,7 +1500,7 @@ void *radix_tree_delete_item(struct radix_tree_root *root,
unsigned long index, void *item) unsigned long index, void *item)
{ {
struct radix_tree_node *node; struct radix_tree_node *node;
unsigned int offset, i; unsigned int offset;
void **slot; void **slot;
void *entry; void *entry;
int tag; int tag;
...@@ -1513,13 +1529,7 @@ void *radix_tree_delete_item(struct radix_tree_root *root, ...@@ -1513,13 +1529,7 @@ void *radix_tree_delete_item(struct radix_tree_root *root,
radix_tree_tag_clear(root, index, tag); radix_tree_tag_clear(root, index, tag);
} }
/* Delete any sibling slots pointing to this slot */ delete_sibling_entries(node, ptr_to_indirect(slot), offset);
for (i = 1; offset + i < RADIX_TREE_MAP_SIZE; i++) {
if (node->slots[offset + i] != ptr_to_indirect(slot))
break;
node->slots[offset + i] = NULL;
node->count--;
}
node->slots[offset] = NULL; node->slots[offset] = NULL;
node->count--; node->count--;
......
...@@ -404,6 +404,7 @@ config TRANSPARENT_HUGEPAGE ...@@ -404,6 +404,7 @@ config TRANSPARENT_HUGEPAGE
bool "Transparent Hugepage Support" bool "Transparent Hugepage Support"
depends on HAVE_ARCH_TRANSPARENT_HUGEPAGE depends on HAVE_ARCH_TRANSPARENT_HUGEPAGE
select COMPACTION select COMPACTION
select RADIX_TREE_MULTIORDER
help help
Transparent Hugepages allows the kernel to use huge pages and Transparent Hugepages allows the kernel to use huge pages and
huge tlb transparently to the applications whenever possible. huge tlb transparently to the applications whenever possible.
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "../../include/linux/compiler.h" #include "../../include/linux/compiler.h"
#define CONFIG_RADIX_TREE_MULTIORDER
#define CONFIG_SHMEM #define CONFIG_SHMEM
#define CONFIG_SWAP #define CONFIG_SWAP
......
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