summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthew Wilcox <willy@linux.intel.com>2016-05-20 20:01:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-20 20:58:30 -0400
commit57578c2ea2cb2e0d362a9212ac83cf90221d4883 (patch)
tree75d21adcd94ea063abe57c3e9f97076694183f7d /lib
parent6c4bd68a2962c03423a226d949caf64216d013cc (diff)
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: Matthew Wilcox <willy@linux.intel.com> Reviewed-by: Ross 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig3
-rw-r--r--lib/radix-tree.c26
2 files changed, 21 insertions, 8 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index 61d55bd0ed89..d79909dc01ec 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -362,6 +362,9 @@ config INTERVAL_TREE
362 362
363 for more information. 363 for more information.
364 364
365config RADIX_TREE_MULTIORDER
366 bool
367
365config ASSOCIATIVE_ARRAY 368config ASSOCIATIVE_ARRAY
366 bool 369 bool
367 help 370 help
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 1624c4117961..799f341977d0 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -484,6 +484,7 @@ int __radix_tree_create(struct radix_tree_root *root, unsigned long index,
484 slot = node->slots[offset]; 484 slot = node->slots[offset];
485 } 485 }
486 486
487#ifdef CONFIG_RADIX_TREE_MULTIORDER
487 /* Insert pointers to the canonical entry */ 488 /* Insert pointers to the canonical entry */
488 if ((shift - order) > 0) { 489 if ((shift - order) > 0) {
489 int i, n = 1 << (shift - order); 490 int i, n = 1 << (shift - order);
@@ -499,6 +500,7 @@ int __radix_tree_create(struct radix_tree_root *root, unsigned long index,
499 node->count++; 500 node->count++;
500 } 501 }
501 } 502 }
503#endif
502 504
503 if (nodep) 505 if (nodep)
504 *nodep = node; 506 *nodep = node;
@@ -1469,6 +1471,20 @@ bool __radix_tree_delete_node(struct radix_tree_root *root,
1469 return deleted; 1471 return deleted;
1470} 1472}
1471 1473
1474static inline void delete_sibling_entries(struct radix_tree_node *node,
1475 void *ptr, unsigned offset)
1476{
1477#ifdef CONFIG_RADIX_TREE_MULTIORDER
1478 int i;
1479 for (i = 1; offset + i < RADIX_TREE_MAP_SIZE; i++) {
1480 if (node->slots[offset + i] != ptr)
1481 break;
1482 node->slots[offset + i] = NULL;
1483 node->count--;
1484 }
1485#endif
1486}
1487
1472/** 1488/**
1473 * radix_tree_delete_item - delete an item from a radix tree 1489 * radix_tree_delete_item - delete an item from a radix tree
1474 * @root: radix tree root 1490 * @root: radix tree root
@@ -1484,7 +1500,7 @@ void *radix_tree_delete_item(struct radix_tree_root *root,
1484 unsigned long index, void *item) 1500 unsigned long index, void *item)
1485{ 1501{
1486 struct radix_tree_node *node; 1502 struct radix_tree_node *node;
1487 unsigned int offset, i; 1503 unsigned int offset;
1488 void **slot; 1504 void **slot;
1489 void *entry; 1505 void *entry;
1490 int tag; 1506 int tag;
@@ -1513,13 +1529,7 @@ void *radix_tree_delete_item(struct radix_tree_root *root,
1513 radix_tree_tag_clear(root, index, tag); 1529 radix_tree_tag_clear(root, index, tag);
1514 } 1530 }
1515 1531
1516 /* Delete any sibling slots pointing to this slot */ 1532 delete_sibling_entries(node, ptr_to_indirect(slot), offset);
1517 for (i = 1; offset + i < RADIX_TREE_MAP_SIZE; i++) {
1518 if (node->slots[offset + i] != ptr_to_indirect(slot))
1519 break;
1520 node->slots[offset + i] = NULL;
1521 node->count--;
1522 }
1523 node->slots[offset] = NULL; 1533 node->slots[offset] = NULL;
1524 node->count--; 1534 node->count--;
1525 1535