Page MenuHomeFreeBSD

D17249.id48273.diff
No OneTemporary

D17249.id48273.diff

Index: sys/kern/subr_vmem.c
===================================================================
--- sys/kern/subr_vmem.c
+++ sys/kern/subr_vmem.c
@@ -244,9 +244,6 @@
static struct vmem transient_arena_storage;
/* kernel and kmem arenas are aliased for backwards KPI compat. */
vmem_t *kernel_arena = &kernel_arena_storage;
-#if VM_NRESERVLEVEL > 0
-vmem_t *kernel_rwx_arena = NULL;
-#endif
vmem_t *kmem_arena = &kernel_arena_storage;
vmem_t *buffer_arena = &buffer_arena_storage;
vmem_t *transient_arena = &transient_arena_storage;
Index: sys/vm/vm_kern.h
===================================================================
--- sys/vm/vm_kern.h
+++ sys/vm/vm_kern.h
@@ -70,7 +70,6 @@
extern vm_map_t exec_map;
extern vm_map_t pipe_map;
extern struct vmem *kernel_arena;
-extern struct vmem *kernel_rwx_arena;
extern struct vmem *kmem_arena;
extern struct vmem *buffer_arena;
extern struct vmem *transient_arena;
Index: sys/vm/vm_kern.c
===================================================================
--- sys/vm/vm_kern.c
+++ sys/vm/vm_kern.c
@@ -669,7 +669,7 @@
}
/*
- * Import kva into the kernel arena.
+ * Import KVA from the kernel map into the kernel arena.
*/
static int
kva_import(void *unused, vmem_size_t size, int flags, vmem_addr_t *addrp)
@@ -691,22 +691,20 @@
return (0);
}
-#if VM_NRESERVLEVEL > 0
/*
- * Import a superpage from the normal kernel arena into the special
- * arena for allocations with different permissions.
+ * Import KVA from a parent arena into a per-domain arena. Imports must be
+ * KVA_QUANTUM-aligned and a multiple of KVA_QUANTUM in size.
*/
static int
-kernel_rwx_alloc(void *arena, vmem_size_t size, int flags, vmem_addr_t *addrp)
+kva_import_domain(void *arena, vmem_size_t size, int flags, vmem_addr_t *addrp)
{
KASSERT((size % KVA_QUANTUM) == 0,
- ("kernel_rwx_alloc: Size %jd is not a multiple of %d",
+ ("kva_import_domain: Size %jd is not a multiple of %d",
(intmax_t)size, (int)KVA_QUANTUM));
return (vmem_xalloc(arena, size, KVA_QUANTUM, 0, 0, VMEM_ADDR_MIN,
VMEM_ADDR_MAX, flags, addrp));
}
-#endif
/*
* kmem_init:
@@ -744,30 +742,30 @@
vmem_init(kernel_arena, "kernel arena", 0, 0, PAGE_SIZE, 0, 0);
vmem_set_import(kernel_arena, kva_import, NULL, NULL, KVA_QUANTUM);
-#if VM_NRESERVLEVEL > 0
- /*
- * In an architecture with superpages, maintain a separate arena
- * for allocations with permissions that differ from the "standard"
- * read/write permissions used for memory in the kernel_arena.
- */
- kernel_rwx_arena = vmem_create("kernel rwx arena", 0, 0, PAGE_SIZE,
- 0, M_WAITOK);
- vmem_set_import(kernel_rwx_arena, kernel_rwx_alloc,
- (vmem_release_t *)vmem_xfree, kernel_arena, KVA_QUANTUM);
-#endif
-
for (domain = 0; domain < vm_ndomains; domain++) {
+ /*
+ * Initialize the per-domain arenas. These are used to color
+ * the KVA space in a way that ensures that virtual large pages
+ * are backed by memory from the same physical domain, which
+ * maximizes the potential for superpage promotion.
+ */
vm_dom[domain].vmd_kernel_arena = vmem_create(
"kernel arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK);
vmem_set_import(vm_dom[domain].vmd_kernel_arena,
- (vmem_import_t *)vmem_alloc, NULL, kernel_arena,
- KVA_QUANTUM);
+ kva_import_domain, NULL, kernel_arena, KVA_QUANTUM);
+
+ /*
+ * In architectures with superpages, maintain separate arenas
+ * for allocations with permissions that differ from the
+ * "standard" read/write permissions used for kernel memory,
+ * so as not to inhibit superpage promotion.
+ */
#if VM_NRESERVLEVEL > 0
vm_dom[domain].vmd_kernel_rwx_arena = vmem_create(
"kernel rwx arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK);
vmem_set_import(vm_dom[domain].vmd_kernel_rwx_arena,
- kernel_rwx_alloc, (vmem_release_t *)vmem_xfree,
- vm_dom[domain].vmd_kernel_arena, KVA_QUANTUM);
+ kva_import_domain, (vmem_release_t *)vmem_xfree,
+ kernel_arena, KVA_QUANTUM);
#endif
}
}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 26, 8:56 AM (11 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15603073
Default Alt Text
D17249.id48273.diff (3 KB)

Event Timeline