From owner-freebsd-hackers@FreeBSD.ORG Tue Jun 30 22:31:54 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DC009106564A; Tue, 30 Jun 2009 22:31:54 +0000 (UTC) (envelope-from mel.flynn+fbsd.hackers@mailing.thruhere.net) Received: from mailhub.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 88F178FC1F; Tue, 30 Jun 2009 22:31:54 +0000 (UTC) (envelope-from mel.flynn+fbsd.hackers@mailing.thruhere.net) Received: from smoochies.rachie.is-a-geek.net (mailhub.rachie.is-a-geek.net [192.168.2.11]) by mailhub.rachie.is-a-geek.net (Postfix) with ESMTP id 17CE07E837; Tue, 30 Jun 2009 14:31:53 -0800 (AKDT) From: Mel Flynn To: freebsd-hackers@freebsd.org Date: Tue, 30 Jun 2009 14:31:37 -0800 User-Agent: KMail/1.11.4 (FreeBSD/8.0-CURRENT; KDE/4.2.4; i386; ; ) References: <200906291317.12040.mel.flynn+fbsd.hackers@mailing.thruhere.net> <4A49CBA0.1050806@cs.rice.edu> In-Reply-To: <4A49CBA0.1050806@cs.rice.edu> MIME-Version: 1.0 Content-Disposition: inline Content-Type: Multipart/Mixed; boundary="Boundary-00=_KJpSKBhXZSq2huD" Message-Id: <200906301431.38664.mel.flynn+fbsd.hackers@mailing.thruhere.net> Cc: Robert Watson , Wojciech Puchar , Alan Cox Subject: Re: large pages (amd64) 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, 30 Jun 2009 22:31:55 -0000 --Boundary-00=_KJpSKBhXZSq2huD Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Tuesday 30 June 2009 00:24:00 Alan Cox wrote: > Mel Flynn wrote: > > On Sunday 28 June 2009 15:41:49 Alan Cox wrote: > >> Wojciech Puchar wrote: > >>> how can i check how much (or maybe - what processes) 2MB pages are > >>> actually allocated? > >> > >> I'm afraid that you can't with great precision. For a given program > >> execution, on an otherwise idle machine, you can only estimate the > >> number by looking at the change in the quantity "promotions + mappings - > >> demotions" before, during, and after the program execution. > >> > >> A program can call mincore(2) in order to determine if a virtual address > >> is part of a 2 or 4MB virtual page. > > > > Would it be possible to expose the super page count as kve_super in the > > kinfo_vmentry struct so that procstat can show this information? If only > > to determine if one is using the feature and possibly benefiting from it. > > Yes, I think so. > > > It looks like sys/kern/kern_proc.c could call mincore around the loop at > > line 1601 (rev 194498), but I know nothing about the vm subsystem to know > > the implications or locking involved. There's still 16 bytes of spare to > > consume, in the kve_vminfo struct though ;) > > Yes, to start with, you could replace the call to pmap_extract() with a > call to pmap_mincore() and export a Boolean to user space that says, > "This region of the address space contains one or more superpage mappings." How about attached? % sudo procstat -av|grep 'S ' PID START END PRT RES PRES REF SHD FL TP PATH 1754 0x28900000 0x2ae00000 rw- 9385 0 3 0 --S df 2141 0x2f900000 0x30800000 rw- 3719 0 1 0 --S df 2146 0x3eec0000 0x4fac0000 rwx 1745 0 1 0 --S df -- Mel --Boundary-00=_KJpSKBhXZSq2huD Content-Type: text/x-patch; charset="ISO-8859-1"; name="procstat-superpages.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="procstat-superpages.patch" Index: sys/sys/user.h =================================================================== --- sys/sys/user.h (revision 195188) +++ sys/sys/user.h (working copy) @@ -348,6 +348,7 @@ #define KVME_FLAG_COW 0x00000001 #define KVME_FLAG_NEEDS_COPY 0x00000002 +#define KVME_FLAG_SUPER 0x00000004 #if defined(__amd64__) #define KINFO_OVMENTRY_SIZE 1168 Index: sys/kern/kern_proc.c =================================================================== --- sys/kern/kern_proc.c (revision 195188) +++ sys/kern/kern_proc.c (working copy) @@ -59,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -1599,8 +1600,13 @@ kve->kve_resident = 0; addr = entry->start; while (addr < entry->end) { - if (pmap_extract(map->pmap, addr)) + int flags; + + flags = pmap_mincore(map->pmap, addr); + if ( flags & MINCORE_INCORE ) kve->kve_resident++; + if( flags & MINCORE_SUPER ) + kve->kve_flags |= KVME_FLAG_SUPER; addr += PAGE_SIZE; } Index: usr.bin/procstat/procstat_vm.c =================================================================== --- usr.bin/procstat/procstat_vm.c (revision 195188) +++ usr.bin/procstat/procstat_vm.c (working copy) @@ -49,7 +49,7 @@ ptrwidth = 2*sizeof(void *) + 2; if (!hflag) - printf("%5s %*s %*s %3s %4s %4s %3s %3s %2s %-2s %-s\n", + printf("%5s %*s %*s %3s %4s %4s %3s %3s %3s %-2s %-s\n", "PID", ptrwidth, "START", ptrwidth, "END", "PRT", "RES", "PRES", "REF", "SHD", "FL", "TP", "PATH"); @@ -69,8 +69,9 @@ printf("%3d ", kve->kve_ref_count); printf("%3d ", kve->kve_shadow_count); printf("%-1s", kve->kve_flags & KVME_FLAG_COW ? "C" : "-"); - printf("%-1s ", kve->kve_flags & KVME_FLAG_NEEDS_COPY ? "N" : + printf("%-1s", kve->kve_flags & KVME_FLAG_NEEDS_COPY ? "N" : "-"); + printf("%-1s ", kve->kve_flags & KVME_FLAG_SUPER ? "S" : "-"); switch (kve->kve_type) { case KVME_TYPE_NONE: str = "--"; Index: usr.bin/procstat/procstat.1 =================================================================== --- usr.bin/procstat/procstat.1 (revision 195188) +++ usr.bin/procstat/procstat.1 (working copy) @@ -332,6 +332,8 @@ copy-on-write .It N needs copy +.It S +One or more superpage mappings are used .El .Sh EXIT STATUS .Ex -std --Boundary-00=_KJpSKBhXZSq2huD--