From df89a6a2db9a7c4f55bec166dd3308c47654bd0b Mon Sep 17 00:00:00 2001 From: attilio Date: Thu, 1 Mar 2012 00:54:08 +0000 Subject: [PATCH] - Exclude vm_radix_shrink() from the interface but retain the code still as it can be useful. - Make most of the interface private as it is unnecessary public right now. This will help in making nodes changing with arch and still avoid namespace pollution. --- sys/vm/vm_radix.c | 25 +++++++++++++++++++++++++ sys/vm/vm_radix.h | 26 +++----------------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c index 3afffbffed2..e54eda1de8f 100644 --- a/sys/vm/vm_radix.c +++ b/sys/vm/vm_radix.c @@ -54,9 +54,32 @@ #include +#define VM_RADIX_WIDTH 5 +#define VM_RADIX_COUNT (1 << VM_RADIX_WIDTH) +#define VM_RADIX_MASK (VM_RADIX_COUNT - 1) +#define VM_RADIX_MAXVAL ((vm_pindex_t)-1) +#define VM_RADIX_LIMIT howmany((sizeof(vm_pindex_t) * NBBY), VM_RADIX_WIDTH) + +/* Flag bits stored in node pointers. */ +#define VM_RADIX_FLAGS 0x3 + +/* Bits of height in root. */ +#define VM_RADIX_HEIGHT 0xf + +/* Calculates maximum value for a tree of height h. */ +#define VM_RADIX_MAX(h) \ + ((h) == VM_RADIX_LIMIT ? VM_RADIX_MAXVAL : \ + (((vm_pindex_t)1 << ((h) * VM_RADIX_WIDTH)) - 1)) + +CTASSERT(VM_RADIX_HEIGHT >= VM_RADIX_LIMIT); CTASSERT(sizeof(struct vm_radix_node) < PAGE_SIZE); CTASSERT((sizeof(u_int) * NBBY) >= VM_RADIX_LIMIT); +struct vm_radix_node { + void *rn_child[VM_RADIX_COUNT]; /* Child nodes. */ + volatile uint32_t rn_count; /* Valid children. */ +}; + static uma_zone_t vm_radix_node_zone; #ifndef UMA_MD_SMALL_ALLOC @@ -789,6 +812,7 @@ vm_radix_reclaim_allnodes(struct vm_radix *rtree) rtree->rt_root = 0; } +#ifdef notyet /* * Attempts to reduce the height of the tree. */ @@ -818,3 +842,4 @@ vm_radix_shrink(struct vm_radix *rtree) } vm_radix_setroot(rtree, root, level); } +#endif diff --git a/sys/vm/vm_radix.h b/sys/vm/vm_radix.h index 30f23ef3230..8c1e77010e0 100644 --- a/sys/vm/vm_radix.h +++ b/sys/vm/vm_radix.h @@ -29,27 +29,11 @@ #ifndef _VM_RADIX_H_ #define _VM_RADIX_H_ -#include - -/* Default values of the tree parameters */ -#define VM_RADIX_WIDTH 5 -#define VM_RADIX_COUNT (1 << VM_RADIX_WIDTH) -#define VM_RADIX_MASK (VM_RADIX_COUNT - 1) -#define VM_RADIX_MAXVAL ((vm_pindex_t)-1) -#define VM_RADIX_LIMIT howmany((sizeof(vm_pindex_t) * NBBY), VM_RADIX_WIDTH) -#define VM_RADIX_FLAGS 0x3 /* Flag bits stored in node pointers. */ #define VM_RADIX_BLACK 0x1 /* Black node. (leaf only) */ #define VM_RADIX_RED 0x2 /* Red node. (leaf only) */ #define VM_RADIX_ANY (VM_RADIX_RED | VM_RADIX_BLACK) -#define VM_RADIX_EMPTY 0x1 /* Empty hint. (internal only) */ -#define VM_RADIX_HEIGHT 0xf /* Bits of height in root */ #define VM_RADIX_STACK 8 /* Nodes to store on stack. */ -/* Calculates maximum value for a tree of height h. */ -#define VM_RADIX_MAX(h) \ - ((h) == VM_RADIX_LIMIT ? VM_RADIX_MAXVAL : \ - (((vm_pindex_t)1 << ((h) * VM_RADIX_WIDTH)) - 1)) - /* * Radix tree root. The height and pointer are set together to permit * coherent lookups while the root is modified. @@ -59,20 +43,16 @@ struct vm_radix { }; #ifdef _KERNEL -CTASSERT(VM_RADIX_HEIGHT >= VM_RADIX_LIMIT); - -struct vm_radix_node { - void *rn_child[VM_RADIX_COUNT]; /* Child nodes. */ - volatile uint32_t rn_count; /* Valid children. */ -}; +/* + * Initialize the radix tree subsystem. + */ void vm_radix_init(void); /* * Functions which only work with black nodes. (object lock) */ int vm_radix_insert(struct vm_radix *, vm_pindex_t, void *); -void vm_radix_shrink(struct vm_radix *); /* * Functions which work on specified colors. (object, vm_page_queue_free locks) -- 2.45.2