From owner-p4-projects@FreeBSD.ORG Wed Mar 15 02:32:51 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 7F8D816A422; Wed, 15 Mar 2006 02:32:51 +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 41D6916A400 for ; Wed, 15 Mar 2006 02:32:51 +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 0AE4143D46 for ; Wed, 15 Mar 2006 02:32:51 +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 k2F2WonT010126 for ; Wed, 15 Mar 2006 02:32:50 GMT (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k2F2WoGP010123 for perforce@freebsd.org; Wed, 15 Mar 2006 02:32:50 GMT (envelope-from peter@freebsd.org) Date: Wed, 15 Mar 2006 02:32:50 GMT Message-Id: <200603150232.k2F2WoGP010123@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 93334 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: Wed, 15 Mar 2006 02:32:51 -0000 http://perforce.freebsd.org/chv.cgi?CH=93334 Change 93334 by peter@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);