aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/mm/pat_rbtree.c
diff options
context:
space:
mode:
authorMichel Lespinasse <walken@google.com>2012-10-08 19:31:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-09 03:22:38 -0400
commit3908836aa77e3621aaf2101f2920e01d7c8460d6 (patch)
tree3e8f5b619f9e093d9d53180bb6f496319ddeb946 /arch/x86/mm/pat_rbtree.c
parent9d9e6f9703bbd642f3f2f807e6aaa642a4cbcec9 (diff)
rbtree: add RB_DECLARE_CALLBACKS() macro
As proposed by Peter Zijlstra, this makes it easier to define the augmented rbtree callbacks. Signed-off-by: Michel Lespinasse <walken@google.com> Cc: Rik van Riel <riel@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/x86/mm/pat_rbtree.c')
-rw-r--r--arch/x86/mm/pat_rbtree.c37
1 files changed, 2 insertions, 35 deletions
diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
index 7e1515bd4770..4d116959075d 100644
--- a/arch/x86/mm/pat_rbtree.c
+++ b/arch/x86/mm/pat_rbtree.c
@@ -69,41 +69,8 @@ static u64 compute_subtree_max_end(struct memtype *data)
69 return max_end; 69 return max_end;
70} 70}
71 71
72/* Update 'subtree_max_end' for node and its parents */ 72RB_DECLARE_CALLBACKS(static, memtype_rb_augment_cb, struct memtype, rb,
73static void memtype_rb_propagate_cb(struct rb_node *node, struct rb_node *stop) 73 u64, subtree_max_end, compute_subtree_max_end)
74{
75 while (node != stop) {
76 struct memtype *data = container_of(node, struct memtype, rb);
77 u64 subtree_max_end = compute_subtree_max_end(data);
78 if (data->subtree_max_end == subtree_max_end)
79 break;
80 data->subtree_max_end = subtree_max_end;
81 node = rb_parent(&data->rb);
82 }
83}
84
85static void memtype_rb_copy_cb(struct rb_node *old, struct rb_node *new)
86{
87 struct memtype *old_data = container_of(old, struct memtype, rb);
88 struct memtype *new_data = container_of(new, struct memtype, rb);
89
90 new_data->subtree_max_end = old_data->subtree_max_end;
91}
92
93/* Update 'subtree_max_end' after tree rotation. old and new are the
94 * former and current subtree roots */
95static void memtype_rb_rotate_cb(struct rb_node *old, struct rb_node *new)
96{
97 struct memtype *old_data = container_of(old, struct memtype, rb);
98 struct memtype *new_data = container_of(new, struct memtype, rb);
99
100 new_data->subtree_max_end = old_data->subtree_max_end;
101 old_data->subtree_max_end = compute_subtree_max_end(old_data);
102}
103
104static const struct rb_augment_callbacks memtype_rb_augment_cb = {
105 memtype_rb_propagate_cb, memtype_rb_copy_cb, memtype_rb_rotate_cb
106};
107 74
108/* Find the first (lowest start addr) overlapping range from rb tree */ 75/* Find the first (lowest start addr) overlapping range from rb tree */
109static struct memtype *memtype_rb_lowest_match(struct rb_root *root, 76static struct memtype *memtype_rb_lowest_match(struct rb_root *root,