diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2006-01-16 13:11:07 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2006-01-16 13:11:07 +0000 |
commit | 5131c0036d7d2582fd928abfc656b6d78ed8ee77 (patch) | |
tree | 595e370ffbb6941147bfc4909165ee72a7d5d2e1 /sys | |
parent | 9b4a98039e4ac75a8c894e1d66b6d2b78096c3c9 (diff) |
add another uvm histroy for physpage alloc/free and propagate a debugging pgfree check into pglist; no functional change for normal kernels; make histories uncommon
Diffstat (limited to 'sys')
-rw-r--r-- | sys/uvm/uvm.h | 10 | ||||
-rw-r--r-- | sys/uvm/uvm_device.c | 6 | ||||
-rw-r--r-- | sys/uvm/uvm_map.c | 8 | ||||
-rw-r--r-- | sys/uvm/uvm_page.c | 33 | ||||
-rw-r--r-- | sys/uvm/uvm_pglist.c | 14 | ||||
-rw-r--r-- | sys/uvm/uvm_stat.h | 3 |
6 files changed, 63 insertions, 11 deletions
diff --git a/sys/uvm/uvm.h b/sys/uvm/uvm.h index 0901aef1d91..13b59571443 100644 --- a/sys/uvm/uvm.h +++ b/sys/uvm/uvm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm.h,v 1.17 2003/03/29 01:13:57 mickey Exp $ */ +/* $OpenBSD: uvm.h,v 1.18 2006/01/16 13:11:05 mickey Exp $ */ /* $NetBSD: uvm.h,v 1.24 2000/11/27 08:40:02 chs Exp $ */ /* @@ -148,9 +148,11 @@ extern struct uvm uvm; /* * historys */ - -UVMHIST_DECL(maphist); -UVMHIST_DECL(pdhist); +#ifdef UVMHIST +extern UVMHIST_DECL(maphist); +extern UVMHIST_DECL(pdhist); +extern UVMHIST_DECL(pghist); +#endif /* * UVM_UNLOCK_AND_WAIT: atomic unlock+wait... wrapper around the diff --git a/sys/uvm/uvm_device.c b/sys/uvm/uvm_device.c index c0a3529068c..89fd553831d 100644 --- a/sys/uvm/uvm_device.c +++ b/sys/uvm/uvm_device.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_device.c,v 1.24 2004/02/23 06:19:32 drahn Exp $ */ +/* $OpenBSD: uvm_device.c,v 1.25 2006/01/16 13:11:05 mickey Exp $ */ /* $NetBSD: uvm_device.c,v 1.30 2000/11/25 06:27:59 chs Exp $ */ /* @@ -444,8 +444,8 @@ udv_fault(ufi, vaddr, pps, npages, centeridx, fault_type, access_type, flags) paddr = pmap_phys_address(mdpgno); mapprot = ufi->entry->protection; UVMHIST_LOG(maphist, - " MAPPING: device: pm=0x%x, va=0x%x, pa=0x%lx, at=%d", - ufi->orig_map->pmap, curr_va, paddr, mapprot); + " MAPPING: device: pm=0x%x, va=0x%x, pa=0x%llx, at=%d", + ufi->orig_map->pmap, curr_va, (long long)paddr, mapprot); if (pmap_enter(ufi->orig_map->pmap, curr_va, paddr, mapprot, PMAP_CANFAIL | mapprot) != 0) { /* diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 6040a4f6657..bb52ff789ff 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.c,v 1.76 2006/01/02 15:05:45 tom Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.77 2006/01/16 13:11:05 mickey Exp $ */ /* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */ /* @@ -102,6 +102,12 @@ struct uvm_cnt uvm_mlk_call, uvm_mlk_hint; const char vmmapbsy[] = "vmmapbsy"; /* + * Da history books + */ +UVMHIST_DECL(maphist); +UVMHIST_DECL(pdhist); + +/* * pool for vmspace structures. */ diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c index f7716dcfe9e..1562afe2347 100644 --- a/sys/uvm/uvm_page.c +++ b/sys/uvm/uvm_page.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.c,v 1.50 2004/12/26 21:22:14 miod Exp $ */ +/* $OpenBSD: uvm_page.c,v 1.51 2006/01/16 13:11:05 mickey Exp $ */ /* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */ /* @@ -126,6 +126,11 @@ static vaddr_t virtual_space_end; static struct pglist uvm_bootbucket; /* + * History + */ +UVMHIST_DECL(pghist); + +/* * local prototypes */ @@ -151,6 +156,7 @@ uvm_pageinsert(pg) { struct pglist *buck; int s; + UVMHIST_FUNC("uvm_pageinsert"); UVMHIST_CALLED(pghist); KASSERT((pg->flags & PG_TABLED) == 0); buck = &uvm.page_hash[uvm_pagehash(pg->uobject,pg->offset)]; @@ -178,6 +184,7 @@ uvm_pageremove(pg) { struct pglist *buck; int s; + UVMHIST_FUNC("uvm_pageremove"); UVMHIST_CALLED(pghist); KASSERT(pg->flags & PG_TABLED); buck = &uvm.page_hash[uvm_pagehash(pg->uobject,pg->offset)]; @@ -216,6 +223,13 @@ uvm_page_init(kvm_startp, kvm_endp) vm_page_t pagearray; int lcv, i; paddr_t paddr; +#if defined(UVMHIST) + static struct uvm_history_ent pghistbuf[100]; +#endif + + UVMHIST_FUNC("uvm_page_init"); + UVMHIST_INIT_STATIC(pghist, pghistbuf); + UVMHIST_CALLED(pghist); /* * init the page queues and page queue locks @@ -489,6 +503,7 @@ uvm_page_physget_freelist(paddrp, freelist) int freelist; { int lcv, x; + UVMHIST_FUNC("uvm_page_physget_freelist"); UVMHIST_CALLED(pghist); /* pass 1: try allocating from a matching end */ #if (VM_PHYSSEG_STRAT == VM_PSTRAT_BIGFIRST) || \ @@ -582,6 +597,7 @@ uvm_page_physget(paddrp) paddr_t *paddrp; { int i; + UVMHIST_FUNC("uvm_page_physget"); UVMHIST_CALLED(pghist); /* try in the order of freelist preference */ for (i = 0; i < VM_NFREELIST; i++) @@ -896,6 +912,7 @@ uvm_pagealloc_strat(obj, off, anon, flags, strat, free_list) struct pglist *freeq; struct pgfreelist *pgfl; boolean_t use_reserve; + UVMHIST_FUNC("uvm_pagealloc_strat"); UVMHIST_CALLED(pghist); KASSERT(obj == NULL || anon == NULL); KASSERT(off == trunc_page(off)); @@ -951,6 +968,9 @@ uvm_pagealloc_strat(obj, off, anon, flags, strat, free_list) try2 = PGFL_ZEROS; } + UVMHIST_LOG(pghist, "obj=%p off=%llx anon=%x flags=%x", + obj, off, flags, anon); + UVMHIST_LOG(pghist, "strat=%d free_list=%d", strat, free_list, 0, 0); again: switch (strat) { case UVM_PGA_STRAT_NORMAL: @@ -1047,10 +1067,13 @@ uvm_pagealloc_strat(obj, off, anon, flags, strat, free_list) pmap_zero_page(pg); } + UVMHIST_LOG(pghist, "allocated pg %p/%llx", pg, + (long long)VM_PAGE_TO_PHYS(pg), 0, 0); return(pg); fail: uvm_unlock_fpageq(s); + UVMHIST_LOG(pghist, "failed!", 0, 0, 0, 0); return (NULL); } @@ -1066,6 +1089,9 @@ uvm_pagerealloc(pg, newobj, newoff) struct uvm_object *newobj; voff_t newoff; { + + UVMHIST_FUNC("uvm_pagerealloc"); UVMHIST_CALLED(pghist); + /* * remove it from the old object */ @@ -1103,6 +1129,7 @@ uvm_pagefree(pg) { int s; int saved_loan_count = pg->loan_count; + UVMHIST_FUNC("uvm_pagefree"); UVMHIST_CALLED(pghist); #ifdef DEBUG if (pg->uobject == (void *)0xdeadbeef && @@ -1111,6 +1138,9 @@ uvm_pagefree(pg) } #endif + UVMHIST_LOG(pghist, "freeing pg %p/%llx", pg, + (long long)VM_PAGE_TO_PHYS(pg), 0, 0); + /* * if the page was an object page (and thus "TABLED"), remove it * from the object. @@ -1309,6 +1339,7 @@ uvm_pageidlezero() struct vm_page *pg; struct pgfreelist *pgfl; int free_list, s; + UVMHIST_FUNC("uvm_pageidlezero"); UVMHIST_CALLED(pghist); do { s = uvm_lock_fpageq(); diff --git a/sys/uvm/uvm_pglist.c b/sys/uvm/uvm_pglist.c index 82eb440a133..42ad231fb38 100644 --- a/sys/uvm/uvm_pglist.c +++ b/sys/uvm/uvm_pglist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pglist.c,v 1.14 2002/10/07 18:35:52 mickey Exp $ */ +/* $OpenBSD: uvm_pglist.c,v 1.15 2006/01/16 13:11:06 mickey Exp $ */ /* $NetBSD: uvm_pglist.c,v 1.13 2001/02/18 21:19:08 chs Exp $ */ /*- @@ -98,6 +98,7 @@ uvm_pglistalloc(size, low, high, alignment, boundary, rlist, nsegs, waitok) #ifdef DEBUG vm_page_t tp; #endif + UVMHIST_FUNC("uvm_pglistalloc"); UVMHIST_CALLED(pghist); KASSERT((alignment & (alignment - 1)) == 0); KASSERT((boundary & (boundary - 1)) == 0); @@ -255,6 +256,7 @@ uvm_pglistfree(list) { vm_page_t m; int s; + UVMHIST_FUNC("uvm_pglistfree"); UVMHIST_CALLED(pghist); /* * Block all memory allocation and lock the free list. @@ -264,6 +266,16 @@ uvm_pglistfree(list) while ((m = TAILQ_FIRST(list)) != NULL) { KASSERT((m->pqflags & (PQ_ACTIVE|PQ_INACTIVE)) == 0); TAILQ_REMOVE(list, m, pageq); +#ifdef DEBUG + if (m->uobject == (void *)0xdeadbeef && + m->uanon == (void *)0xdeadbeef) { + panic("uvm_pagefree: freeing free page %p", m); + } + + m->uobject = (void *)0xdeadbeef; + m->offset = 0xdeadbeef; + m->uanon = (void *)0xdeadbeef; +#endif m->pqflags = PQ_FREE; TAILQ_INSERT_TAIL(&uvm.page_free[ uvm_page_lookup_freelist(m)].pgfl_queues[PGFL_UNKNOWN], diff --git a/sys/uvm/uvm_stat.h b/sys/uvm/uvm_stat.h index b4b49928a2d..7aecd0de5b5 100644 --- a/sys/uvm/uvm_stat.h +++ b/sys/uvm/uvm_stat.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_stat.h,v 1.13 2002/03/14 01:27:19 millert Exp $ */ +/* $OpenBSD: uvm_stat.h,v 1.14 2006/01/16 13:11:06 mickey Exp $ */ /* $NetBSD: uvm_stat.h,v 1.19 2001/02/04 10:55:58 mrg Exp $ */ /* @@ -132,6 +132,7 @@ LIST_HEAD(uvm_history_head, uvm_history); #define UVMHIST_MAPHIST 0x00000001 /* maphist */ #define UVMHIST_PDHIST 0x00000002 /* pdhist */ #define UVMHIST_UBCHIST 0x00000004 /* ubchist */ +#define UVMHIST_PGHIST 0x00000008 /* pghist */ #ifdef _KERNEL |