q From:	HENRY::IN%"McGuire_Ed%grinnell.mailnet%MIT-MULTICS.ARPA%SRI-KL.ARPA%relay.cs.net@rca.com" 24-DEC-1986 16:39  To:	INFO-VAX@SRI-KL.ARPA Subj:	Virtual pages - 126 lines   M Brian McKeever (MCKEEVER@UMKCVAX1.BITNET) wrote to me the other day asking me H how to compute virtual pages in use by a process.  He said that he triedF subtracting the process parameter FREPTECNT from the SYSBOOT parameterM VIRTUALPAGECNT, but it was always 72 pages less than SHOW PROCESS/CONTINUOUS.   5 I'm writing this long note for the following reasons:   K -  In my ignorance, I have been confusing VIRTUALPAGECNT and PGFLQUOTA, and F    this is reflected in an error in the procedure SWAPFILE.COM which I    distributed a while back.  > -  I found the missing 72 pages, and the story is interesting.  K -  Now I have two new questions about virtual page management which I can't /    answer, and I hope someone on this list can.   N 1.  I thought in my ignorance that the process parameter PGFLQUOTA limited theK     total size of the process address space.  In fact, PGFLQUOTA limits the I     number of demand-zero pages and copy-on-reference section pages, i.e. N     pages that might end up in the page file.  I got mixed up when I found outM     that PGFLQUOTA does not limit the al number of pages that are actually IN I     the page file, only the number of pages that COULD BE PUT IN the page 	     file.   K     So SWAPFILE.COM, the procedure I wrote which displays information about K     process memory usage, says it reports virtual page count in its output. M     But what it's really doing is subtracting PAGFILCNT from PGFLQUOTA.  This K     is in fact another useful number, the local writeable page count, alias      the page file quota used.   L     I'm going to put the right column titles into SWAPFILE.COM, and add codeM     to correctly compute virtual pages if the numbers are available from DCL. 6     If you want the corrected version, send me a note.  L 2.  Here's what I learned about the parts of the process header that controlL     virtual pages.  I had to go all over the internals manual and experimentJ     to get this info.  Some of the definitions in the internals manual are%     wrong.  I hope this is all right.        DEFINITIONS   #     Item       Unit     Description M     ------------------------------------------------------------------------- B     2^21       page     Number of pages in P0, P1, S0, or S1 space  J     P0BR       address  Virtual address of the bottom of the P0 page table  E     P0LR       page     Number of used longwords in the P0 page table H                         (beginning at P0BR); number of pages in P0 space  G     FREP0VA    address  Virtual address of first nonexistent page in P0 8                         page; always equal to P0LR x 512  H     P1BR       address  Virtual address of the first page of the P1 pageJ                         table (P1 expands from 7FFFFFFF[16] toward smallerF                         addresses, so a longword at this address wouldJ                         describe the page at virtual address 40000000[16])  G     P1LR       page     Number of unused longwords in the P1 page table M                         (beginning at P1BR); always equal to 2^21 - number of )                         pages in P1 space   G     FREP1VA    address  Virtual address of first nonexistent page in P1 N                         space; always equal to (P1LR - 1) x 512 + 40000000[16]  J     FREPTECNT  page     Number of unused longwords in the page table spaceJ                         (pages available for P0 or P1 space); always equalJ                         to (VIRTUALPAGECNT + 127) DIV 128 - P0LR - (2^21 -!                         P1LR) - 1        DISCUSSION  H     A process page table is a database of longwords, each describing oneJ     page of virtual address space.  There are two page tables, the P0 pageJ     table and the P1 page table, that describe virtual address space for aL     process.  These two tables together I'll call the "page table space" for%     the purposes of this explanation.   L     Virtual address space for the "page table space", which is a part of theI     process header, is reserved when the process is created.  The SYSBOOT K     parameter VIRTUALPAGECNT sets the maximum virtual size of a process, so B     a "page table space" is created that is big enough to describe     VIRTUALPAGECNT pages.   I     There are 128 longwords in a page.  Therefore, each page of the "page K     table space" describes 128 pages of the process' virtual address space. D     So, the size of the "page table space" (in pages) is computed byJ     dividing VIRTUALPAGECNT by 128 and rounding up.  Let's call this valueI     TABLEPAGES.  You can use the following formula to compute TABLEPAGES.   %        (VIRTUALPAGECNT + 127) DIV 128   J     This means that the number of entries in the "page table space" can beJ     anywhere from VIRTUALPAGECNT to VIRTUALPAGECNT + 127.  For example, atH     Grinnell, VIRTUALPAGECNT is 68536.  A 536 page "page table space" isI     required to describe that many pages.  There are actually 536 x 128 = H     68608 longwords in this "page table space", which is 72 greater than
     68536.  L     The number of longwords in the "page table space" is equal to TABLEPAGESK     x 128.  We can call this TABLESLOTS.  To compute the size of a process' H     current virtual address space, subtract the process header parameterC     FREPTECNT from TABLESLOTS.  This is the value displayed by SHOW      PROCESS/CONTINUOUS.   4 3.  This are my mysteries.  Can anybody answer them?  F     The size of the process' current virtual address space can also beK     calculated by the formula P0LR + (2^21 - P1LR).  However, this value is J     always 1 greater than the value shown by SHOW PROCESS/CONTINUOUS.  WhyE     is there a difference?  Am I just making a silly fencepost error?   K     Is the real limit to a process' virtual address space VIRTUALPAGECNT or J     TABLESLOTS?  The fact that SHOW PROCESS/CONTINUOUS is apparently usingH     TABLESLOTS to compute current virtual address space is evidence thatH     TABLESLOTS is the real limit, but the documentation always says it's     VIRTUALPAGECNT.   N 4.  The quotations at the tops of some of the chapters in the internals manual.     are starting to make a lot of sense to me.  L     Chapter 16, Memory Management System Services:  _Confusion now hath made&     his masterpiece!_  --"Macbeth" 2,3  K     Chapter 26, Size of System Virtual Address Space:  _A little inaccuracy M     sometimes saves tons of explanation._  --Saki, "The Comments of Moung Ka" 