From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 3 18:52:21 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9FB941065672 for ; Tue, 3 Apr 2012 18:52:21 +0000 (UTC) (envelope-from vasanth.raonaik@gmail.com) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx1.freebsd.org (Postfix) with ESMTP id 272EA8FC19 for ; Tue, 3 Apr 2012 18:52:21 +0000 (UTC) Received: by wibhq7 with SMTP id hq7so25542wib.13 for ; Tue, 03 Apr 2012 11:52:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=rLwyTeo3bjmPNj0Vt67v42VDa/ZFvNoIq/L9zijnk7Y=; b=eEXChBCjvPI6kBkCT8MqJ5f9zjYq9hVmNLhOHOGkN+4EaY5wqKW25rZgGUWfehX5AN 1NiMLW5AcM3wsVVhEuXqqsGpysOXH/zRsyLgaHH45VwRI0Z2zV1WmYuioQRZ/M4l/thk yZCRz1XcIWe05Hc399+RBL+4um4COMr1JYE7MjB12CLj+bLN7WFahwtio+3HsGzubOiU QRqYors7kpu8kuudZNdk1dZ9fwXiu/ux5BGfCuT37wZ7+E33TZ6VvdvYKj6b7bLGHYX+ YZ4+9FxwlKSYY6/M4xfCTyatu9UEuBFJh/vqfvLI0tZW2pAC+D5ZwTbMBGqX4+YatSab 4/Dw== MIME-Version: 1.0 Received: by 10.180.76.240 with SMTP id n16mr39101751wiw.10.1333479139600; Tue, 03 Apr 2012 11:52:19 -0700 (PDT) Received: by 10.180.98.161 with HTTP; Tue, 3 Apr 2012 11:52:19 -0700 (PDT) In-Reply-To: References: Date: Tue, 3 Apr 2012 14:52:19 -0400 Message-ID: From: vasanth rao naik sabavat To: Mark Tinguely Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org Subject: Re: question about amd64 pagetable page allocation. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Apr 2012 18:52:21 -0000 Hello Mark, I think pmap_remove_pages() is executed only for the current process. 2549 #ifdef PMAP_REMOVE_PAGES_CURPROC_ONLY 2550 if (pmap != vmspace_pmap(curthread->td_proc->p_vmspace)) { 2551 printf("warning: pmap_remove_pages called with non-current pmap\n"); 2552 return; 2553 } 2554 #endif I dont still get it why this was removed? Thanks, Vasanth On Tue, Apr 3, 2012 at 12:42 PM, Mark Tinguely wrote: > On Tue, Apr 3, 2012 at 10:18 AM, vasanth rao naik sabavat > wrote: > > Hello Mark, > > > > Thank you for replying, > > > > Could you please point me to any document which illustrates the > > implementation of recursive page tables in FreeBSD for amd64. > > > > Also, I just found that with the following patch from Alon, the usage of > > vtopte() is removed in pmap_remove_pages(). Why was this removed? > > > > http://lists.freebsd.org/pipermail/svn-src-all/2009-March/006006.html > > > > Thanks, > > Vasanth > > > > On Tue, Apr 3, 2012 at 10:56 AM, Mark Tinguely > > wrote: > >> > >> On Tue, Apr 3, 2012 at 8:33 AM, vasanth rao naik sabavat > >> wrote: > >> > Hi, > >> > > >> > I am trying to understand the page table page allocation for a process > >> > in > >> > FBSD6.1. I see that the page table pages are allocated by > >> > vm_page_alloc(). > >> > I believe the virtual address for this allocated page can be derived > by > >> > PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m)), however when I compare this address > >> > with > >> > the virtual address accessed in pmap_remove_pages() they are not the > >> > same. > >> > > >> > The virtual address of a *PTE in pmap_remove_pages() is something like > >> > *0xffff800000643200 > >> > * > >> > However, the virtual address of the page allocated by vm_page_alloc() > is > >> > * > >> > 0xffffff033c6a0000 > >> > > >> > *I would also like to understand the importance of loc_PTmap, I > believe > >> > the > >> > pmap_remove_pages() is derving the page table page addresses from > >> > loc_PTmap? > >> > (kgdb) p loc_PTmap > >> > Cannot access memory at address 0xffff800000000000 > >> > > >> > How do we relate the loc_PTmap to the page table pages allocated by > >> > vm_page_alloc() in _pmap_allocpte(). > >> > > >> > Thanks, > >> > Vasanth > >> > >> > >> > >> The answer to your questions will be more obvious when you get an > >> understanding of the Recursive Page Tables. > >> > >> --Mark Tinguely. > > > > > > Search for "recursive page tables" start with 32 bits first. I did not > read it, but the below page looks promising: > > > http://www.rohitab.com/discuss/topic/31139-tutorial-paging-memory-mapping-with-a-recursive-page-directory/ > > The nice thing about recursive page table is the MMU does the work. But: > > 1) User recursive page tables work only for the current map. > 2) Kernel mappings are placed at the top of every map - so the kernel > recursive addresses will always be valid. > > As the comment in the link states, that change converted from using > user recursive page table virtual address (which is only valid when > the map is current) to using the physical to virtual direct map (which > is always valid). > > --Mark Tinguely. >