summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2008-05-09 16:48:07 +0000
committeralc <alc@FreeBSD.org>2008-05-09 16:48:07 +0000
commit9e8bccea75b18f9e024b4a00b6e010b6989a1b1f (patch)
tree9e10f9fea0330c515b91c8dfaf76e3285c597600 /sys/amd64
parent4f251e2f8c1c1a9602bf0b09f62682eeffc1892d (diff)
downloadFreeBSD-src-9e8bccea75b18f9e024b4a00b6e010b6989a1b1f.zip
FreeBSD-src-9e8bccea75b18f9e024b4a00b6e010b6989a1b1f.tar.gz
Introduce pmap_align_superpage(). It increases the starting virtual
address of the given mapping if a different alignment might result in more superpage mappings.
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/pmap.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index fbfaa35..dcd6b2a9 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -4469,3 +4469,26 @@ pmap_addr_hint(vm_object_t obj, vm_offset_t addr, vm_size_t size)
addr = (addr + (NBPDR - 1)) & ~(NBPDR - 1);
return addr;
}
+
+/*
+ * Increase the starting virtual address of the given mapping if a
+ * different alignment might result in more superpage mappings.
+ */
+void
+pmap_align_superpage(vm_object_t object, vm_ooffset_t offset,
+ vm_offset_t *addr, vm_size_t size)
+{
+ vm_offset_t superpage_offset;
+
+ if (object != NULL && (object->flags & OBJ_COLORED) != 0)
+ offset += ptoa(object->pg_color);
+ superpage_offset = offset & PDRMASK;
+ if (size < superpage_offset ||
+ size - superpage_offset < NBPDR ||
+ (*addr & PDRMASK) == superpage_offset)
+ return;
+ if ((*addr & PDRMASK) < superpage_offset)
+ *addr = (*addr & ~PDRMASK) + superpage_offset;
+ else
+ *addr = ((*addr + PDRMASK) & ~PDRMASK) + superpage_offset;
+}
OpenPOWER on IntegriCloud