From owner-svn-src-all@FreeBSD.ORG Tue Jun 1 21:53:30 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C6889106566B; Tue, 1 Jun 2010 21:53:30 +0000 (UTC) (envelope-from alc@cs.rice.edu) Received: from mail.cs.rice.edu (mail.cs.rice.edu [128.42.1.31]) by mx1.freebsd.org (Postfix) with ESMTP id 714538FC08; Tue, 1 Jun 2010 21:53:29 +0000 (UTC) Received: from mail.cs.rice.edu (localhost.localdomain [127.0.0.1]) by mail.cs.rice.edu (Postfix) with ESMTP id 546A32C2A8E; Tue, 1 Jun 2010 16:53:29 -0500 (CDT) X-Virus-Scanned: by amavis-2.4.0 at mail.cs.rice.edu Received: from mail.cs.rice.edu ([127.0.0.1]) by mail.cs.rice.edu (mail.cs.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ATNje++6sBZl; Tue, 1 Jun 2010 16:53:21 -0500 (CDT) Received: from [10.209.194.87] (unknown [10.209.194.87]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cs.rice.edu (Postfix) with ESMTP id A3B722C2A02; Tue, 1 Jun 2010 16:53:21 -0500 (CDT) Message-ID: <4C058145.3000707@cs.rice.edu> Date: Tue, 01 Jun 2010 16:53:09 -0500 From: Alan Cox User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: "Jayachandran C." References: <201005271005.o4RA5eVu032269@svn.freebsd.org> In-Reply-To: <201005271005.o4RA5eVu032269@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r208589 - head/sys/mips/mips X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Jun 2010 21:53:31 -0000 On 5/27/2010 5:05 AM, Jayachandran C. wrote: > Author: jchandra > Date: Thu May 27 10:05:40 2010 > New Revision: 208589 > URL: http://svn.freebsd.org/changeset/base/208589 > > Log: > Call VM_WAIT in pmap_ptpgzone_allocf() if M_WAITOK is set. > Removed unused variable. > > Approved by: rrs (mentor) > > I'm afraid that this will work some of the time, but not all of the time. Specifically, there is no guarantee that any of the available free (or cached) pages after the VM_WAIT will fall within the range of suitable physical addresses. Moreover, and perhaps most worrisome, is that this function could do a lot of spinning. Every time this function sleeps and a single page is freed (or cached) by someone else, this function will be reawakened. With a little bad luck, you could spin indefinitely. For essentially this reason, contigmalloc(), kmem_alloc_contig(), and kmem_alloc_attr() don't use VM_WAIT, but instead a function called vm_contig_grow_cache(). Regards, Alan > Modified: > head/sys/mips/mips/pmap.c > > Modified: head/sys/mips/mips/pmap.c > ============================================================================== > --- head/sys/mips/mips/pmap.c Thu May 27 08:21:52 2010 (r208588) > +++ head/sys/mips/mips/pmap.c Thu May 27 10:05:40 2010 (r208589) > @@ -969,10 +969,15 @@ pmap_ptpgzone_allocf(uma_zone_t zone, in > ("pmap_ptpgzone_allocf: invalid allocation size %d", bytes)); > > *flags = UMA_SLAB_PRIV; > - m = vm_phys_alloc_contig(1, 0, MIPS_KSEG0_LARGEST_PHYS, > - PAGE_SIZE, PAGE_SIZE); > - if (m == NULL) > - return (NULL); > + for (;;) { > + m = vm_phys_alloc_contig(1, 0, MIPS_KSEG0_LARGEST_PHYS, > + PAGE_SIZE, PAGE_SIZE); > + if (m != NULL) > + break; > + if ((wait& M_WAITOK) == 0) > + return (NULL); > + VM_WAIT; > + } > > paddr = VM_PAGE_TO_PHYS(m); > return ((void *)MIPS_PHYS_TO_KSEG0(paddr)); > @@ -1039,8 +1044,10 @@ pmap_pinit(pmap_t pmap) > * allocate the page directory page > */ > ptdpg = pmap_alloc_pte_page(pmap, NUSERPGTBLS, M_WAITOK,&ptdva); > - pmap->pm_segtab = (pd_entry_t *)ptdva; > + if (ptdpg == NULL) > + return (0); > > + pmap->pm_segtab = (pd_entry_t *)ptdva; > pmap->pm_active = 0; > pmap->pm_ptphint = NULL; > for (i = 0; i< MAXCPU; i++) { > @@ -1062,13 +1069,11 @@ _pmap_allocpte(pmap_t pmap, unsigned pte > { > vm_offset_t pteva; > vm_page_t m; > - int req; > > KASSERT((flags& (M_NOWAIT | M_WAITOK)) == M_NOWAIT || > (flags& (M_NOWAIT | M_WAITOK)) == M_WAITOK, > ("_pmap_allocpte: flags is neither M_NOWAIT nor M_WAITOK")); > > - req = VM_ALLOC_WIRED | VM_ALLOC_ZERO | VM_ALLOC_NOOBJ; > /* > * Find or fabricate a new pagetable page > */ >