Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Jun 2009 14:31:37 -0800
From:      Mel Flynn <mel.flynn+fbsd.hackers@mailing.thruhere.net>
To:        freebsd-hackers@freebsd.org
Cc:        Robert Watson <rwatson@freebsd.org>, Wojciech Puchar <wojtek@wojtek.tensor.gdynia.pl>, Alan Cox <alc@cs.rice.edu>
Subject:   Re: large pages (amd64)
Message-ID:  <200906301431.38664.mel.flynn%2Bfbsd.hackers@mailing.thruhere.net>
In-Reply-To: <4A49CBA0.1050806@cs.rice.edu>
References:  <alpine.BSF.2.00.0906281933580.1809@wojtek.tensor.gdynia.pl> <200906291317.12040.mel.flynn%2Bfbsd.hackers@mailing.thruhere.net> <4A49CBA0.1050806@cs.rice.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
--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 <sys/signalvar.h>
 #include <sys/sdt.h>
 #include <sys/sx.h>
+#include <sys/mman.h>
 #include <sys/user.h>
 #include <sys/jail.h>
 #include <sys/vnode.h>
@@ -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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906301431.38664.mel.flynn%2Bfbsd.hackers>