PERFORCE change 94552 for review
Peter Wemm
peter at FreeBSD.org
Mon Apr 3 19:42:55 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=94552
Change 94552 by peter at 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();
More information about the p4-projects
mailing list