From owner-freebsd-mips@FreeBSD.ORG Thu Jun 3 06:23:39 2010 Return-Path: Delivered-To: mips@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8027F1065670; Thu, 3 Jun 2010 06:23:39 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 2532A8FC0A; Thu, 3 Jun 2010 06:23:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o536Fud4048193; Thu, 3 Jun 2010 00:15:56 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Thu, 03 Jun 2010 00:16:08 -0600 (MDT) Message-Id: <20100603.001608.628446057294691926.imp@bsdimp.com> To: jmallett@FreeBSD.org From: "M. Warner Losh" In-Reply-To: References: <4C0736A5.1010101@imimic.com> X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: alc@imimic.com, mips@FreeBSD.org, alc@cs.rice.edu Subject: Re: init_pte_prot() patch X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jun 2010 06:23:39 -0000 In message: Juli Mallett writes: : Hi Alan, : = : On Wed, Jun 2, 2010 at 21:59, Alan Cox wrote: : > I would appreciate it if someone would test the attached patch. =A0= (A : > "buildworld" would probably suffice.) =A0Essentially, it does two t= hings: : = : Sorry I didn't respond to this when you sent it to me. : = : > 1. The virtual memory system only cares about the contents of a pag= e's dirty : > field if that page is managed (i.e., it is pageable). =A0And, in fa= ct, if you : > survey the calls to vm_page_dirty() in the MIPS or any other pmap, = they are : > generally conditioned on the mapping having been for a managed page= .= : > : > The MIPS pmap_enter() is an exception to this rule. =A0It is uncond= itionally : > calling vm_page_dirty() on any page mapped within the kernel addres= s space, : > managed or otherwise. =A0In fact, it is highly unusual for pmap_ent= er() to be : > calling vm_page_dirty() on the page being mapped, regardless of whe= ther it : > is managed. =A0This call to vm_page_dirty() shouldn't be needed if = change #2 : > below is also made. =A0The attached patch eliminates the call. : = : I believe that the reason the MIPS pmap does that is because : PTE_RWPAGE includes PTE_M which is the TLB dirty bit. This means tha= t : we won't get exceptions when that page is modified, and so MIPS is : pre-dirtying the VM page to allow it to make that optimization. At : least, that's what the intent appears to be. Whether that's a correc= t : model for the interaction between pmap and the VM system's management= : of those kernel pages, I don't know. On MIPS, the hardware is such that the 'M' bit in the PTE needs to be set in order to write to the page. So we need to set it on pages the kernel needs to write, otherwise we take a TLB exception on first write. It is cheaper to pre-dirty kernel pages by setting the M bit in the TLB entry than to take the TLB miss and set it there. It isn't clear from me that this change takes that into account. But it also is rare that things are clear to me in the vm layer without an hour of careful study :) Warner