Skip to content

Commit

Permalink
[PATCH] radix-tree: direct data
Browse files Browse the repository at this point in the history
The ability to have height 0 radix trees (a direct pointer to the data item
rather than going through a full node->slot) quietly disappeared with
old-2.6-bkcvs commit ffee171812d51652f9ba284302d9e5c5cc14bdfd.  On 64-bit
machines this causes nearly 600 bytes to be used for every <= 4K file in
pagecache.

Re-introduce this feature, root tags stored in spare ->gfp_mask bits.

Simplify radix_tree_delete's complex tag clearing arrangement (which would
become even more complex) by just falling back to tag clearing functions
(the pagecache radix-tree never uses this path anyway, so the icache
savings will mean it's actually a speedup).

On my 4GB G5, this saves 8MB RAM per kernel kernel source+object tree in
pagecache.

Pagecache lookup, insertion, and removal speed for small files will also be
improved.

This makes RCU radix tree harder, but it's worth it.

Signed-off-by: Nick Piggin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Nick Piggin authored and Linus Torvalds committed Jun 23, 2006
1 parent 929f972 commit 612d6c1
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 83 deletions.
5 changes: 3 additions & 2 deletions include/linux/radix-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include <linux/preempt.h>
#include <linux/types.h>

#define RADIX_TREE_MAX_TAGS 2

/* root tags are stored in gfp_mask, shifted by __GFP_BITS_SHIFT */
struct radix_tree_root {
unsigned int height;
gfp_t gfp_mask;
Expand All @@ -45,8 +48,6 @@ do { \
(root)->rnode = NULL; \
} while (0)

#define RADIX_TREE_MAX_TAGS 2

int radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long);
Expand Down
Loading

0 comments on commit 612d6c1

Please sign in to comment.