From owner-freebsd-mips@FreeBSD.ORG Sat Jun 19 17:04:20 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 A5A59106566C; Sat, 19 Jun 2010 17:04:20 +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 2A09D8FC16; Sat, 19 Jun 2010 17:04:20 +0000 (UTC) Received: from mail.cs.rice.edu (localhost.localdomain [127.0.0.1]) by mail.cs.rice.edu (Postfix) with ESMTP id CF5292C2AAC; Sat, 19 Jun 2010 12:04:19 -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 J4WG9I5Pfxxg; Sat, 19 Jun 2010 12:04:12 -0500 (CDT) Received: from [10.24.157.225] (h-67-101-114-10.snfccasy.static.covad.net [67.101.114.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cs.rice.edu (Postfix) with ESMTP id 8B67E2C2A81; Sat, 19 Jun 2010 12:04:11 -0500 (CDT) Message-ID: <4C1CF867.8070301@cs.rice.edu> Date: Sat, 19 Jun 2010 12:03:35 -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: Juli Mallett , mips@freebsd.org, Alan Cox References: <201006191023.o5JANNLq052471@svn.freebsd.org> In-Reply-To: <201006191023.o5JANNLq052471@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: Re: svn commit: r209336 - user/jmallett/octeon/sys/mips/include 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: Sat, 19 Jun 2010 17:04:20 -0000 On 6/19/2010 5:23 AM, Juli Mallett wrote: > Author: jmallett > Date: Sat Jun 19 10:23:23 2010 > New Revision: 209336 > URL: http://svn.freebsd.org/changeset/base/209336 > > Log: > Add notes about comments I need to update and attempt to explain the wired > bit (and mostly fail.) > > Modified: > user/jmallett/octeon/sys/mips/include/pte.h > > Modified: user/jmallett/octeon/sys/mips/include/pte.h > ============================================================================== > --- user/jmallett/octeon/sys/mips/include/pte.h Sat Jun 19 10:14:43 2010 (r209335) > +++ user/jmallett/octeon/sys/mips/include/pte.h Sat Jun 19 10:23:23 2010 (r209336) > @@ -55,6 +55,8 @@ typedef pt_entry_t *pd_entry_t; > #define TLBMASK_MASK ((PAGE_MASK>> TLBMASK_SHIFT)<< TLBMASK_SHIFT) > > /* > + * XXX This comment is not correct for FreeBSD. > + * > * PFN for EntryLo register. Upper bits are 0, which is to say that > * bit 29 is the last hardware bit; Bits 30 and upwards (EntryLo is > * 64 bit though it can be referred to in 32-bits providing 2 software > @@ -73,11 +75,14 @@ typedef pt_entry_t *pd_entry_t; > #define TLBLO_PTE_TO_PA(pte) (TLBLO_PFN_TO_PA(TLBLO_PTE_TO_PFN((pte)))) > > /* > + * XXX This comment is not correct for anything more modern than R4K. > + * > * VPN for EntryHi register. Upper two bits select user, supervisor, > * or kernel. Bits 61 to 40 copy bit 63. VPN2 is bits 39 and down to > * as low as 13, down to PAGE_SHIFT, to index 2 TLB pages*. From bit 12 > * to bit 8 there is a 5-bit 0 field. Low byte is ASID. > * > + * XXX This comment is not correct for FreeBSD. > * Note that in FreeBSD, we map 2 TLB pages is equal to 1 VM page. > */ > #define TLBHI_ASID_MASK (0xff) > @@ -121,7 +126,9 @@ typedef pt_entry_t *pd_entry_t; > * VM flags managed in software: > * RO: Read only. Never set PTE_D on this page, and don't > * listen to requests to write to it. > - * W: Wired. ??? > + * W: Wired. Allows us to quickly increment and decrement > + * the wired count by looking at the PTE and skip wired > + * mappings when removing mappings from a process. > */ > #define PTE_RO (0x01<< TLBLO_SWBITS_SHIFT) > #define PTE_W (0x02<< TLBLO_SWBITS_SHIFT) > I have two observations relating to PTE_W on mips: First, pmap_change_wiring() is broken on mips because it only updates the PTE_W bit in the PTE but not the wired flag in the pv entry. Consequently, pmap_page_wired_mappings() may return an incorrect result. Second, given the paucity of bits available to software, I think that this bit would be better used as a PTE_MANAGED or PTE_REFERENCED bit. PTE_MANAGED would allow you to avoid quite a number of PHYS_TO_VM_PAGE operations, which became more costly when you switched to VM_PHYSSEG_SPARSE, and PTE_REFERENCED would enable you to do a proper implementation of pmap_ts_referenced(). (FreeBSD's page daemon really wants to know how many processes have referenced a page, and mips does not currently provide that.) Alan