PERFORCE change 93334 for review
Peter Wemm
peter at FreeBSD.org
Wed Mar 15 02:32:51 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=93334
Change 93334 by peter at peter_melody on 2006/03/15 02:31:50
Instead of iterating through the loop 160 times, use a while
loop to examine each of the three bitmaps and the cpu's built
in bsfq instruction (like ffs()). This is why I wanted to
kill the sva/eva option, because the bit scan instructions do
not have an easy way of skipping or ignoring bits.
Affected files ...
.. //depot/projects/hammer/sys/amd64/amd64/pmap.c#142 edit
Differences ...
==== //depot/projects/hammer/sys/amd64/amd64/pmap.c#142 (text+ko) ====
@@ -1451,6 +1451,8 @@
#define PC_FREE1 0xfffffffffffffffful
#define PC_FREE2 0x000000fffffffffful
+static uint64_t pc_freemask[3] = { PC_FREE0, PC_FREE1, PC_FREE2 };
+
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,
@@ -2692,6 +2694,7 @@
struct pv_chunk *pc, *npc;
int field, idx;
int64_t bit;
+ uint64_t inuse;
if (pmap != vmspace_pmap(curthread->td_proc->p_vmspace)) {
printf("warning: pmap_remove_pages called with non-current pmap\n");
@@ -2706,10 +2709,10 @@
* the for loop. Since we free as we go, we won't have
* to skip unfreeable ones that sva/eva might have allowed.
*/
- for (idx = 0; idx < _NPCPV; idx++) {
- field = idx / 64;
- bit = idx % 64;
- if ((pc->pc_map[field] & 1ul << bit) == 0) { /* inuse */
+ for (field = 0; field < _NPCM; field++) {
+ while ((inuse = (~(pc->pc_map[field])) & pc_freemask[field]) != 0) {
+ bit = bsfq(inuse);
+ idx = field * 64 + bit;
pv = &pc->pc_pventry[idx];
pte = vtopte(pv->pv_va);
More information about the p4-projects
mailing list