From owner-p4-projects@FreeBSD.ORG Mon Apr 3 20:06:27 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 06B1016A428; Mon, 3 Apr 2006 20:06:27 +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 9CA0916A41F for ; Mon, 3 Apr 2006 20:06:26 +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 1A14343D45 for ; Mon, 3 Apr 2006 20:06:26 +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 k33K6PbK046926 for ; Mon, 3 Apr 2006 20:06:26 GMT (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k33K6Pai046923 for perforce@freebsd.org; Mon, 3 Apr 2006 20:06:25 GMT (envelope-from peter@freebsd.org) Date: Mon, 3 Apr 2006 20:06:25 GMT Message-Id: <200604032006.k33K6Pai046923@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 94554 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 20:06:27 -0000 http://perforce.freebsd.org/chv.cgi?CH=94554 Change 94554 by peter@peter_daintree on 2006/04/03 20:05:29 Reimplement alc@'s changes for soft-failing pv entry allocation in things like pmap_copy(). Add a 'try' arg to get_pv_entry() so that it will quietly fail (instead of panicing) and won't call pmap_collect() either. Affected files ... .. //depot/projects/hammer/sys/amd64/amd64/pmap.c#149 edit Differences ... ==== //depot/projects/hammer/sys/amd64/amd64/pmap.c#149 (text+ko) ==== @@ -205,7 +205,7 @@ static caddr_t crashdumpmap; static void free_pv_entry(pmap_t pmap, pv_entry_t pv); -static pv_entry_t get_pv_entry(pmap_t locked_pmap); +static pv_entry_t get_pv_entry(pmap_t locked_pmap, int try); static void pmap_clear_ptes(vm_page_t m, long bit); static int pmap_remove_pte(pmap_t pmap, pt_entry_t *ptq, @@ -1463,7 +1463,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; +static int pc_chunk_count, pc_chunk_allocs, pc_chunk_frees, pc_chunk_tryfail; SYSCTL_INT(_vm_pmap, OID_AUTO, pc_chunk_count, CTLFLAG_RD, &pc_chunk_count, 0, "Current number of pv entry chunks"); @@ -1471,6 +1471,8 @@ "Current number of pv entry chunks allocated"); SYSCTL_INT(_vm_pmap, OID_AUTO, pc_chunk_frees, CTLFLAG_RD, &pc_chunk_frees, 0, "Current number of pv entry chunks frees"); +SYSCTL_INT(_vm_pmap, OID_AUTO, pc_chunk_tryfail, CTLFLAG_RD, &pc_chunk_tryfail, 0, + "Number of times tried to get a chunk page but failed."); static int pv_entry_frees, pv_entry_allocs, pv_entry_spare; @@ -1586,7 +1588,7 @@ * when needed. */ static pv_entry_t -get_pv_entry(pmap_t pmap) +get_pv_entry(pmap_t pmap, int try) { static const struct timeval printinterval = { 60, 0 }; static struct timeval lastprint; @@ -1626,6 +1628,10 @@ /* No free items, allocate another chunk */ m = vm_page_alloc(NULL, colour, VM_ALLOC_SYSTEM | VM_ALLOC_NOOBJ); if (m == NULL) { + if (try) { + PV_STAT(pc_chunk_tryfail++); + return (NULL); + } /* * Reclaim pv entries: At first, destroy mappings to inactive * pages. After that, if a pv chunk entry is still needed, @@ -1690,11 +1696,10 @@ { pv_entry_t pv; - pv = get_pv_entry(pmap); - pv->pv_va = va; - PMAP_LOCK_ASSERT(pmap, MA_OWNED); mtx_assert(&vm_page_queue_mtx, MA_OWNED); + pv = get_pv_entry(pmap, FALSE); + pv->pv_va = va; TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_list); m->md.pv_list_count++; } @@ -1710,11 +1715,8 @@ PMAP_LOCK_ASSERT(pmap, MA_OWNED); mtx_assert(&vm_page_queue_mtx, MA_OWNED); if (pv_entry_count < pv_entry_high_water && - (pv = uma_zalloc(pvzone, M_NOWAIT)) != NULL) { - pv_entry_count++; + (pv = get_pv_entry(pmap, TRUE)) != NULL) { pv->pv_va = va; - pv->pv_pmap = pmap; - TAILQ_INSERT_TAIL(&pmap->pm_pvlist, pv, pv_plist); TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_list); m->md.pv_list_count++; return (TRUE);