From owner-svn-src-all@FreeBSD.ORG Thu Jun 3 16:33:07 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 CA2CF1065675; Thu, 3 Jun 2010 16:33:07 +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 5F39D8FC1A; Thu, 3 Jun 2010 16:33:07 +0000 (UTC) Received: from mail.cs.rice.edu (localhost.localdomain [127.0.0.1]) by mail.cs.rice.edu (Postfix) with ESMTP id B0C2D2C2BF0; Thu, 3 Jun 2010 11:33:06 -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 6MVur+C+vsFV; Thu, 3 Jun 2010 11:32:59 -0500 (CDT) Received: from adsl-216-63-78-18.dsl.hstntx.swbell.net (adsl-216-63-78-18.dsl.hstntx.swbell.net [216.63.78.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cs.rice.edu (Postfix) with ESMTP id 495E62C2AEB; Thu, 3 Jun 2010 11:32:58 -0500 (CDT) Message-ID: <4C07D939.6010008@cs.rice.edu> Date: Thu, 03 Jun 2010 11:32:57 -0500 From: Alan Cox User-Agent: Thunderbird 2.0.0.24 (X11/20100501) MIME-Version: 1.0 To: "C. Jayachandran" References: <201005271005.o4RA5eVu032269@svn.freebsd.org> <4C058145.3000707@cs.rice.edu> <4C05F9BC.40409@cs.rice.edu> <4C0731A5.7090301@cs.rice.edu> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: src-committers@freebsd.org, "Jayachandran C." , svn-src-all@freebsd.org, Randall Stewart , Konstantin Belousov , svn-src-head@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: Thu, 03 Jun 2010 16:33:07 -0000 C. Jayachandran wrote: > On Thu, Jun 3, 2010 at 10:20 AM, C. Jayachandran > wrote: > >> On Thu, Jun 3, 2010 at 10:07 AM, Alan Cox wrote: >> >>> C. Jayachandran wrote: >>> >>>> On Wed, Jun 2, 2010 at 11:57 AM, Alan Cox wrote: >>>> >>>> >>>>> C. Jayachandran wrote: >>>>> >>>>> >>>>>> On Wed, Jun 2, 2010 at 3:23 AM, Alan Cox wrote: >>>>>> >>>>>> >>>>>> >>>>>>> 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(). >>>>>>> >>>>>>> >>>>>>> >>>>>> I had seen the vm_contig_grow_cache() usage, but could not use it as >>>>>> it was defined as a static function. >>>>>> >>>>>> I did not want to use contigmalloc()/kmem_alloc_contig() either, >>>>>> because the pages in that memory region are already direct mapped and >>>>>> setting up another mapping is not necessary. The overall idea is to >>>>>> allocate pages in the direct mapped region for the page table entries >>>>>> so that we don't take a TLB exception while accessing page tables >>>>>> (which is costly as MIPS has a software TLB exception handler). >>>>>> >>>>>> Can you suggest the right way to do this? I will make the changes and >>>>>> send a patch for approval. >>>>>> >>>>>> >>>>>> >>>>> I would encourage you to make vm_contig_grow_cache() an extern function >>>>> and >>>>> use it. (vm/vm_pageout.h is probably the best place for the function >>>>> prototype.) >>>>> >>>>> >>>> I'll create a patch for this and related changes in mips/mips/pmap.c >>>> >>>> >>>> >>> Great. Thanks! >>> >>> >>>>> If you're interested in taking this a small step further, it would make >>>>> sense to add two parameters to vm_contig_grow_cache() and >>>>> vm_contig_launder(): a "low" and a "high" physical address. >>>>> vm_contig_launder() could then skip pages that are outside the desired >>>>> range. >>>>> >>>>> >>>> I am looking at this now, part of the logic which >>>> vm_phys_alloc_contig() uses to check pages address should work here. >>>> Will send out changes for this, if it works out. >>>> >>>> >>>> >>> I suspect that you'll just need to add two or three lines to >>> vm_contig_launder(). If something doesn't make sense, just e-mail me. >>> >> The current changes I have is attached - still testing it. >> > > I've attached the patch for review, but I was not able trigger the > condition in which vm_contig_grow_cache() is called during testing so > far. > > But if you are okay with the patch I can commit it. > The patch looks good. Please go ahead and commit it. Thanks, Alan