From owner-p4-projects@FreeBSD.ORG Mon Apr 3 19:42:55 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9126616A424; Mon, 3 Apr 2006 19:42:55 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5352C16A41F for ; Mon, 3 Apr 2006 19:42:55 +0000 (UTC) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 15F4443D48 for ; Mon, 3 Apr 2006 19:42:55 +0000 (GMT) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k33JgsNq044328 for ; Mon, 3 Apr 2006 19:42:54 GMT (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k33JgsbY044325 for perforce@freebsd.org; Mon, 3 Apr 2006 19:42:54 GMT (envelope-from peter@freebsd.org) Date: Mon, 3 Apr 2006 19:42:54 GMT Message-Id: <200604031942.k33JgsbY044325@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Cc: Subject: PERFORCE change 94552 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Apr 2006 19:42:55 -0000 http://perforce.freebsd.org/chv.cgi?CH=94552 Change 94552 by peter@peter_daintree on 2006/04/03 19:41:53 macro-fy the stats instead of adding #ifdefs to make them optional. Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/pmap.c#147 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/pmap.c#147 (text+ko) ==== @@ -158,6 +158,13 @@ #define PMAP_INLINE #endif +#define PV_STATS +#ifdef PV_STATS +#define PV_STAT(x) do { x ; } while (0) +#else +#define PV_STAT(x) do { } while (0) +#endif + struct pmap kernel_pmap_store; vm_paddr_t avail_start; /* PA of first available physical page */ @@ -1453,6 +1460,7 @@ static uint64_t pc_freemask[3] = { PC_FREE0, PC_FREE1, PC_FREE2 }; +#ifdef PV_STATS static int pc_chunk_count, pc_chunk_allocs, pc_chunk_frees; SYSCTL_INT(_vm_pmap, OID_AUTO, pc_chunk_count, CTLFLAG_RD, &pc_chunk_count, 0, @@ -1479,6 +1487,8 @@ "Current number times pmap_collect called on inactive queue"); SYSCTL_INT(_vm_pmap, OID_AUTO, pmap_collect_active, CTLFLAG_RD, &pmap_collect_active, 0, "Current number times pmap_collect called on active queue"); +#endif + /* * We are in a serious low memory condition. Resort to * drastic measures to free some pages so we can allocate @@ -1544,9 +1554,9 @@ struct pv_chunk *pc; int idx, field, bit; - pv_entry_frees++; - pv_entry_spare++; - pv_entry_count--; + PV_STAT(pv_entry_frees++); + PV_STAT(pv_entry_spare++); + PV_STAT(pv_entry_count--); pc = pv_to_chunk(pv); idx = pv - &pc->pc_pventry[0]; field = idx / 64; @@ -1558,9 +1568,9 @@ if (pc->pc_map[0] != PC_FREE0 || pc->pc_map[1] != PC_FREE1 || pc->pc_map[2] != PC_FREE2) return; - pv_entry_spare -= _NPCPV; - pc_chunk_count--; - pc_chunk_frees++; + PV_STAT(pv_entry_spare -= _NPCPV); + PV_STAT(pc_chunk_count--); + PV_STAT(pc_chunk_frees++); /* entire chunk is free, return it */ TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pc)); @@ -1586,8 +1596,8 @@ PMAP_LOCK_ASSERT(pmap, MA_OWNED); mtx_assert(&vm_page_queue_mtx, MA_OWNED); - pv_entry_allocs++; - pv_entry_count++; + PV_STAT(pv_entry_allocs++); + PV_STAT(pv_entry_count++); if (pv_entry_count > pv_entry_high_water) pagedaemon_wakeup(); pc = TAILQ_FIRST(&pmap->pm_pvchunk); @@ -1607,7 +1617,7 @@ TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list); } - pv_entry_spare--; + PV_STAT(pv_entry_spare--); return (pv); } } @@ -1623,19 +1633,21 @@ printf("Approaching the limit on PV entries, consider " "increasing sysctl vm.pmap.shpgperproc or " "vm.pmap.pv_entry_max\n"); - pmap_collect_inactive++; + PV_STAT(pmap_collect_inactive++); pmap_collect(pmap, &vm_page_queues[PQ_INACTIVE]); - m = vm_page_alloc(NULL, colour, VM_ALLOC_SYSTEM | VM_ALLOC_NOOBJ); + m = vm_page_alloc(NULL, colour, + VM_ALLOC_SYSTEM | VM_ALLOC_NOOBJ); if (m == NULL) { - pmap_collect_active++; + PV_STAT(pmap_collect_active++); pmap_collect(pmap, &vm_page_queues[PQ_ACTIVE]); - m = vm_page_alloc(NULL, colour, VM_ALLOC_SYSTEM | VM_ALLOC_NOOBJ); + m = vm_page_alloc(NULL, colour, + VM_ALLOC_SYSTEM | VM_ALLOC_NOOBJ); if (m == NULL) panic("get_pv_entry: increase vm.pmap.shpgperproc"); } } - pc_chunk_count++; - pc_chunk_allocs++; + PV_STAT(pc_chunk_count++); + PV_STAT(pc_chunk_allocs++); colour++; pc = (void *)PHYS_TO_DMAP(m->phys_addr); pc->pc_pmap = pmap; @@ -1644,7 +1656,7 @@ pc->pc_map[2] = PC_FREE2; pv = &pc->pc_pventry[0]; TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list); - pv_entry_spare += _NPCPV - 1; + PV_STAT(pv_entry_spare += _NPCPV - 1); return (pv); } @@ -2699,7 +2711,7 @@ struct pv_chunk *pc, *npc; int field, idx; int64_t bit; - uint64_t inuse; + uint64_t inuse, bitmask; int allfree; if (pmap != vmspace_pmap(curthread->td_proc->p_vmspace)) { @@ -2719,9 +2731,10 @@ inuse = (~(pc->pc_map[field])) & pc_freemask[field]; while (inuse != 0) { bit = bsfq(inuse); + bitmask = 1UL << bit; idx = field * 64 + bit; pv = &pc->pc_pventry[idx]; - inuse &= ~(1UL << bit); + inuse &= ~bitmask; pte = vtopte(pv->pv_va); tpte = *pte; @@ -2762,10 +2775,10 @@ vm_page_dirty(m); /* Mark free */ - pv_entry_frees++; - pv_entry_spare++; - pv_entry_count--; - pc->pc_map[field] |= 1ul << bit; + PV_STAT(pv_entry_frees++); + PV_STAT(pv_entry_spare++); + PV_STAT(pv_entry_count--); + pc->pc_map[field] |= bitmask; m->md.pv_list_count--; TAILQ_REMOVE(&m->md.pv_list, pv, pv_list); if (TAILQ_EMPTY(&m->md.pv_list)) @@ -2775,9 +2788,9 @@ } } if (allfree) { - pv_entry_spare -= _NPCPV; - pc_chunk_count--; - pc_chunk_frees++; + PV_STAT(pv_entry_spare -= _NPCPV); + PV_STAT(pc_chunk_count--); + PV_STAT(pc_chunk_frees++); TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pc)); vm_page_lock_queues();