[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
poolpage diff to test
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: poolpage diff to test
- From: Ted Unangst <tedu_(_at_)_zeitbombe_(_dot_)_org>
- Date: Thu, 3 Jun 2004 20:49:15 -0400 (EDT)
this is a diff which avoids some uvm/pool hokiness on certain
architectures. it also renames the mega-ugly PMAP_MAP_POOLPAGE.
test it by running making a new kernel, rebooting, and running make build
on either an alpha, hppa, powerpc, or vax.
Index: arch/alpha/include/pmap.h
===================================================================
RCS file: /home/tedu/cvs/src/sys/arch/alpha/include/pmap.h,v
retrieving revision 1.16
diff -u -r1.16 pmap.h
--- arch/alpha/include/pmap.h 20 May 2004 09:20:41 -0000 1.16
+++ arch/alpha/include/pmap.h 2 Jun 2004 14:18:18 -0000
@@ -201,8 +201,8 @@
/*
* Alternate mapping hooks for pool pages. Avoids thrashing the TLB.
*/
-#define PMAP_MAP_POOLPAGE(pg) ALPHA_PHYS_TO_K0SEG(VM_PAGE_TO_PHYS(pg))
-#define PMAP_UNMAP_POOLPAGE(va) PHYS_TO_VM_PAGE(ALPHA_K0SEG_TO_PHYS((va)))
+#define pmap_map_direct(pg) ALPHA_PHYS_TO_K0SEG(VM_PAGE_TO_PHYS(pg))
+#define pmap_unmap_direct(va) PHYS_TO_VM_PAGE(ALPHA_K0SEG_TO_PHYS((va)))
paddr_t vtophys(vaddr_t);
Index: arch/hppa/hppa/pmap.c
===================================================================
RCS file: /home/tedu/cvs/src/sys/arch/hppa/hppa/pmap.c,v
retrieving revision 1.111
diff -u -r1.111 pmap.c
--- arch/hppa/hppa/pmap.c 27 May 2004 21:04:07 -0000 1.111
+++ arch/hppa/hppa/pmap.c 2 Jun 2004 14:20:18 -0000
@@ -99,34 +99,6 @@
u_int hppa_prot[8];
-/*
- * workaround until the uvm_km_getpage can be used this early.
- */
-void *hppa_pool_page_alloc(struct pool *, int);
-void hppa_pool_page_free(struct pool *, void *);
-
-void *
-hppa_pool_page_alloc(struct pool *pp, int flags)
-{
- boolean_t waitok = (flags & PR_WAITOK) ? TRUE : FALSE;
-
- return ((void *)uvm_km_alloc_poolpage1(kmem_map, uvmexp.kmem_object,
- waitok));
-}
-
-void
-hppa_pool_page_free(struct pool *pp, void *v)
-{
-
- uvm_km_free_poolpage1(kmem_map, (vaddr_t)v);
-}
-
-struct pool_allocator hppa_pool_allocator = {
- hppa_pool_page_alloc, hppa_pool_page_free, 0,
-};
-
-
-
#define pmap_sid(pmap, va) \
(((va & 0xc0000000) != 0xc0000000)? pmap->pmap_space : HPPA_SID_KERNEL)
@@ -616,7 +588,7 @@
pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, 0, 0, "pmappl",
&pool_allocator_nointr);
pool_init(&pmap_pv_pool, sizeof(struct pv_entry), 0, 0, 0, "pmappv",
- &hppa_pool_allocator);
+ NULL);
pmap_initialized = 1;
Index: arch/hppa/include/pmap.h
===================================================================
RCS file: /home/tedu/cvs/src/sys/arch/hppa/include/pmap.h,v
retrieving revision 1.30
diff -u -r1.30 pmap.h
--- arch/hppa/include/pmap.h 20 May 2004 09:20:42 -0000 1.30
+++ arch/hppa/include/pmap.h 2 Jun 2004 14:18:29 -0000
@@ -83,8 +83,8 @@
/*
* pool quickmaps
*/
-#define PMAP_MAP_POOLPAGE(pg) ((vaddr_t)VM_PAGE_TO_PHYS(pg))
-#define PMAP_UNMAP_POOLPAGE(va) PHYS_TO_VM_PAGE((paddr_t)(va))
+#define pmap_map_direct(pg) ((vaddr_t)VM_PAGE_TO_PHYS(pg))
+#define pmap_unmap_direct(va) PHYS_TO_VM_PAGE((paddr_t)(va))
/*
* according to the parisc manual aliased va's should be
Index: arch/powerpc/include/pmap.h
===================================================================
RCS file: /home/tedu/cvs/src/sys/arch/powerpc/include/pmap.h,v
retrieving revision 1.35
diff -u -r1.35 pmap.h
--- arch/powerpc/include/pmap.h 20 May 2004 09:20:42 -0000 1.35
+++ arch/powerpc/include/pmap.h 2 Jun 2004 14:18:51 -0000
@@ -119,8 +119,8 @@
* Really simple. 0x0->0x80000000 contain 1->1 mappings of the physical
* memory. - XXX
*/
-#define PMAP_MAP_POOLPAGE(pg) ((vaddr_t)VM_PAGE_TO_PHYS(pg))
-#define PMAP_UNMAP_POOLPAGE(va) PHYS_TO_VM_PAGE((paddr_t)va)
+#define pmap_map_direct(pg) ((vaddr_t)VM_PAGE_TO_PHYS(pg))
+#define pmap_unmap_direct(va) PHYS_TO_VM_PAGE((paddr_t)va)
void pmap_bootstrap(u_int kernelstart, u_int kernelend);
Index: arch/vax/include/pmap.h
===================================================================
RCS file: /home/tedu/cvs/src/sys/arch/vax/include/pmap.h,v
retrieving revision 1.21
diff -u -r1.21 pmap.h
--- arch/vax/include/pmap.h 20 May 2004 09:20:42 -0000 1.21
+++ arch/vax/include/pmap.h 2 Jun 2004 14:19:17 -0000
@@ -108,8 +108,8 @@
* Real nice (fast) routines to get the virtual address of a physical page
* (and vice versa).
*/
-#define PMAP_MAP_POOLPAGE(pg) (VM_PAGE_TO_PHYS(pg) | KERNBASE)
-#define PMAP_UNMAP_POOLPAGE(va) PHYS_TO_VM_PAGE((va) & ~KERNBASE)
+#define pmap_map_direct(pg) (VM_PAGE_TO_PHYS(pg) | KERNBASE)
+#define pmap_unmap_direct(va) PHYS_TO_VM_PAGE((va) & ~KERNBASE)
#define PMAP_STEAL_MEMORY
Index: uvm/uvm_km.c
===================================================================
RCS file: /cvs/src/sys/uvm/uvm_km.c,v
retrieving revision 1.40
diff -u -r1.40 uvm_km.c
--- uvm/uvm_km.c 31 May 2004 22:53:49 -0000 1.40
+++ uvm/uvm_km.c 2 Jun 2004 21:26:51 -0000
@@ -814,8 +814,8 @@
}
/* Sanity; must specify both or none. */
-#if (defined(PMAP_MAP_POOLPAGE) || defined(PMAP_UNMAP_POOLPAGE)) && \
- (!defined(PMAP_MAP_POOLPAGE) || !defined(PMAP_UNMAP_POOLPAGE))
+#if (defined(pmap_map_direct) || defined(pmap_unmap_direct)) && \
+ (!defined(pmap_map_direct) || !defined(pmap_unmap_direct))
#error Must specify MAP and UNMAP together.
#endif
@@ -832,7 +832,7 @@
struct uvm_object *obj;
boolean_t waitok;
{
-#if defined(PMAP_MAP_POOLPAGE)
+#if defined(pmap_map_direct)
struct vm_page *pg;
vaddr_t va;
@@ -845,7 +845,7 @@
} else
return (0);
}
- va = PMAP_MAP_POOLPAGE(pg);
+ va = pmap_map_direct(pg);
if (__predict_false(va == 0))
uvm_pagefree(pg);
return (va);
@@ -867,7 +867,7 @@
va = uvm_km_kmemalloc(map, obj, PAGE_SIZE, waitok ? 0 : UVM_KMF_NOWAIT);
splx(s);
return (va);
-#endif /* PMAP_MAP_POOLPAGE */
+#endif /* pmap_map_direct */
}
/*
@@ -882,8 +882,8 @@
vm_map_t map;
vaddr_t addr;
{
-#if defined(PMAP_UNMAP_POOLPAGE)
- uvm_pagefree(PMAP_UNMAP_POOLPAGE(addr));
+#if defined(pmap_unmap_direct)
+ uvm_pagefree(pmap_unmap_direct(addr));
#else
int s;
@@ -900,11 +900,39 @@
s = splvm();
uvm_km_free(map, addr, PAGE_SIZE);
splx(s);
-#endif /* PMAP_UNMAP_POOLPAGE */
+#endif /* pmap_unmap_direct */
}
+#if defined(pmap_map_direct)
/*
- * uvm_km_page allocator
+ * uvm_km_page allocator, pmap_map_direct arch
+ * On architectures with machine memory direct mapped into a portion
+ * of KVM, we have very little work to do. Just get a physical page,
+ * and find and return its VA. We use the poolpage functions for this.
+ */
+void
+uvm_km_page_init(void)
+{
+ /* nothing */
+}
+
+void *
+uvm_km_getpage(boolean waitok)
+{
+
+ return ((void *)uvm_km_alloc_poolpage1(NULL, NULL, waitok));
+}
+
+void *
+uvm_km_putpage(void *v)
+{
+
+ uvm_km_free_poolpage1(NULL, (vaddr_t)v);
+}
+
+#else
+/*
+ * uvm_km_page allocator, non pmap_map_direct archs
* This is a special allocator that uses a reserve of free pages
* to fulfill requests. It is fast and interrupt safe, but can only
* return page sized regions. Its primary use is as a backend for pool.
@@ -937,23 +965,7 @@
for (i = 0; i < uvm_km_pages_lowat * 4; i++) {
-#if defined(PMAP_MAP_POOLPAGE)
- struct vm_page *pg;
- vaddr_t va;
-
- pg = uvm_pagealloc(NULL, 0, NULL, 0);
- if (__predict_false(pg == NULL))
- break;
-
- va = PMAP_MAP_POOLPAGE(pg);
- if (__predict_false(va == 0)) {
- uvm_pagefree(pg);
- break;
- }
- page = (void *)va;
-#else
page = (void *)uvm_km_alloc(kernel_map, PAGE_SIZE);
-#endif
page->next = uvm_km_pages_head;
uvm_km_pages_head = page;
}
@@ -985,22 +997,7 @@
tsleep(&uvm_km_pages_head, PVM, "kmalloc", 0);
want = 16;
for (i = 0; i < want; i++) {
-#if defined(PMAP_MAP_POOLPAGE)
- struct vm_page *pg;
- vaddr_t va;
-
- pg = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_USERESERVE);
- if (__predict_false(pg == NULL))
- break;
- va = PMAP_MAP_POOLPAGE(pg);
- if (__predict_false(va == 0)) {
- uvm_pagefree(pg);
- break;
- }
- page = (void *)va;
-#else
page = (void *)uvm_km_alloc(kernel_map, PAGE_SIZE);
-#endif
if (i == 0)
head = tail = page;
page->next = head;
@@ -1056,3 +1053,4 @@
uvm_km_pages_free++;
splx(s);
}
+#endif
--
we fear that pop-culture
is the only kind of culture we're ever going to have
Visit your host, monkey.org