Skip to contentSkip to conversation

x86/pat changes for v2.6.35

GIT PULL Ingo Molnar 1 participant 1 message May 17, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest x86-pat-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git x86-pat-for-linus

out-of-topic modifications in x86-pat-for-linus:
------------------------------------------------
include/linux/rbtree.h # 17d9ddc: rbtree: Add support for augmented
lib/rbtree.c # 17d9ddc: rbtree: Add support for augmented

Thanks,

Ingo

------------------>
Pallipadi, Venkatesh (3):
rbtree: Add support for augmented rbtrees
x86, pat: Migrate to rbtree only backend for pat memtype management x86, pat: In rbt_memtype_check_insert(), update new->type only if valid

Robin Holt (1):
x86, pat: Update the page flags for memtype atomically instead of using memtype_lock

[email protected] (1):
x86, pat: Preparatory changes in pat.c for bigger rbtree change

 Documentation/rbtree.txt          |   58 ++++++++
 arch/x86/include/asm/cacheflush.h |   44 ++++---
 arch/x86/mm/Makefile              |    1 +
 arch/x86/mm/pat.c                 |  239 +++-----------------------------
 arch/x86/mm/pat_internal.h        |   46 ++++++
 arch/x86/mm/pat_rbtree.c          |  273 +++++++++++++++++++++++++++++++++++++
 include/linux/rbtree.h            |    5 +-
 lib/rbtree.c                      |   48 ++++++-
 8 files changed, 470 insertions(+), 244 deletions(-)
 create mode 100644 arch/x86/mm/pat_internal.h
 create mode 100644 arch/x86/mm/pat_rbtree.c
Documentation/rbtree.txt +58 -0
index aae8355..221f38b 100644
@@ -190,3 +190,61 @@ Example:
   for (node = rb_first(&mytree); node; node = rb_next(node))
 	printk("key=%s\n", rb_entry(node, struct mytype, node)->keystring);
 
+Support for Augmented rbtrees
+-----------------------------
+
+Augmented rbtree is an rbtree with "some" additional data stored in each node.
+This data can be used to augment some new functionality to rbtree.
+Augmented rbtree is an optional feature built on top of basic rbtree
+infrastructure. rbtree user who wants this feature will have an augment
+callback function in rb_root initialized.
+
+This callback function will be called from rbtree core routines whenever
+a node has a change in one or both of its children. It is the responsibility
+of the callback function to recalculate the additional data that is in the
+rb node using new children information. Note that if this new additional
+data affects the parent node's additional data, then callback function has
+to handle it and do the recursive updates.
+
+
+Interval tree is an example of augmented rb tree. Reference -
+"Introduction to Algorithms" by Cormen, Leiserson, Rivest and Stein.
+More details about interval trees:
+
+Classical rbtree has a single key and it cannot be directly used to store
+interval ranges like [lo:hi] and do a quick lookup for any overlap with a new
+lo:hi or to find whether there is an exact match for a new lo:hi.
+
+However, rbtree can be augmented to store such interval ranges in a structured
+way making it possible to do efficient lookup and exact match.
+
+This "extra information" stored in each node is the maximum hi
+(max_hi) value among all the nodes that are its descendents. This
+information can be maintained at each node just be looking at the node
+and its immediate children. And this will be used in O(log n) lookup
+for lowest match (lowest start address among all possible matches)
+with something like:
+
+find_lowest_match(lo, hi, node)
+{
+	lowest_match = NULL;
+	while (node) {
+		if (max_hi(node->left) > lo) {
+			// Lowest overlap if any must be on left side
+			node = node->left;
+		} else if (overlap(lo, hi, node)) {
+			lowest_match = node;
+			break;
+		} else if (lo > node->lo) {
+			// Lowest overlap if any must be on right side
+			node = node->right;
+		} else {
+			break;
+		}
+	}
+	return lowest_match;
+}
+
+Finding exact match will be to first find lowest match and then to follow
+successor nodes looking for exact match, until the start of a node is beyond
+the hi value we are looking for.
arch/x86/include/asm/cacheflush.h +25 -19

75 lines not on this page · raw message

arch/x86/mm/Makefile +1 -0
index 06630d2..a4c7683 100644
@@ -6,6 +6,7 @@ nostackp := $(call cc-option, -fno-stack-protector)
 CFLAGS_physaddr.o		:= $(nostackp)
 CFLAGS_setup_nx.o		:= $(nostackp)
 
+obj-$(CONFIG_X86_PAT)		+= pat_rbtree.o
 obj-$(CONFIG_SMP)		+= tlb.o
 
 obj-$(CONFIG_X86_32)		+= pgtable_32.o iomap_32.o
arch/x86/mm/pat.c +19 -220

350 lines not on this page · raw message

arch/x86/mm/pat_internal.h new file +46 -0

46 lines not on this page · raw message

arch/x86/mm/pat_rbtree.c new file +273 -0

273 lines not on this page · raw message

include/linux/rbtree.h +4 -1
index 9c29541..8e33a25 100644
@@ -110,6 +110,7 @@ struct rb_node
 struct rb_root
 {
 	struct rb_node *rb_node;
+	void (*augment_cb)(struct rb_node *node);
 };
 
 
@@ -129,7 +130,9 @@ static inline void rb_set_color(struct rb_node *rb, int color)
 	rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
 }
 
-#define RB_ROOT	(struct rb_root) { NULL, }
+#define RB_ROOT	(struct rb_root) { NULL, NULL, }
+#define RB_AUGMENT_ROOT(x)	(struct rb_root) { NULL, x}
+
 #define	rb_entry(ptr, type, member) container_of(ptr, type, member)
 
 #define RB_EMPTY_ROOT(root)	((root)->rb_node == NULL)
lib/rbtree.c +44 -4

103 lines not on this page · raw message