vmparam.h revision 373
14Srgrimes/*- 24Srgrimes * Copyright (c) 1990 The Regents of the University of California. 34Srgrimes * All rights reserved. 44Srgrimes * 54Srgrimes * This code is derived from software contributed to Berkeley by 64Srgrimes * William Jolitz. 74Srgrimes * 84Srgrimes * Redistribution and use in source and binary forms, with or without 94Srgrimes * modification, are permitted provided that the following conditions 104Srgrimes * are met: 114Srgrimes * 1. Redistributions of source code must retain the above copyright 124Srgrimes * notice, this list of conditions and the following disclaimer. 134Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 144Srgrimes * notice, this list of conditions and the following disclaimer in the 154Srgrimes * documentation and/or other materials provided with the distribution. 164Srgrimes * 3. All advertising materials mentioning features or use of this software 174Srgrimes * must display the following acknowledgement: 184Srgrimes * This product includes software developed by the University of 194Srgrimes * California, Berkeley and its contributors. 204Srgrimes * 4. Neither the name of the University nor the names of its contributors 214Srgrimes * may be used to endorse or promote products derived from this software 224Srgrimes * without specific prior written permission. 234Srgrimes * 244Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 254Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 264Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 274Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 284Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 294Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 304Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 314Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 324Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 334Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 344Srgrimes * SUCH DAMAGE. 354Srgrimes * 364Srgrimes * @(#)vmparam.h 5.9 (Berkeley) 5/12/91 374Srgrimes */ 384Srgrimes 394Srgrimes 404Srgrimes/* 414Srgrimes * Machine dependent constants for 386. 424Srgrimes */ 434Srgrimes 444Srgrimes/* 454Srgrimes * Virtual address space arrangement. On 386, both user and kernel 464Srgrimes * share the address space, not unlike the vax. 474Srgrimes * USRTEXT is the start of the user text/data space, while USRSTACK 484Srgrimes * is the top (end) of the user stack. Immediately above the user stack 494Srgrimes * resides the user structure, which is UPAGES long and contains the 504Srgrimes * kernel stack. 514Srgrimes * 524Srgrimes * Immediately after the user structure is the page table map, and then 534Srgrimes * kernal address space. 544Srgrimes */ 554Srgrimes#define USRTEXT 0 564Srgrimes#define USRSTACK 0xFDBFE000 574Srgrimes#define BTOPUSRSTACK (0xFDC00-(UPAGES)) /* btop(USRSTACK) */ 584Srgrimes#define LOWPAGES 0 594Srgrimes#define HIGHPAGES UPAGES 604Srgrimes 614Srgrimes/* 624Srgrimes * Virtual memory related constants, all in bytes 634Srgrimes */ 644Srgrimes#define MAXTSIZ (6*1024*1024) /* max text size */ 654Srgrimes#ifndef DFLDSIZ 6690Sroot#define DFLDSIZ (16*1024*1024) /* initial data size limit */ 674Srgrimes#endif 684Srgrimes#ifndef MAXDSIZ 694Srgrimes#define MAXDSIZ (32*1024*1024) /* max data size */ 704Srgrimes#endif 714Srgrimes#ifndef DFLSSIZ 724Srgrimes#define DFLSSIZ (512*1024) /* initial stack size limit */ 734Srgrimes#endif 744Srgrimes#ifndef MAXSSIZ 75373Srgrimes#define MAXSSIZ (8*1024*1024) /* max stack size */ 764Srgrimes#endif 774Srgrimes 784Srgrimes/* 794Srgrimes * Default sizes of swap allocation chunks (see dmap.h). 804Srgrimes * The actual values may be changed in vminit() based on MAXDSIZ. 814Srgrimes * With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024. 824Srgrimes */ 834Srgrimes#define DMMIN 32 /* smallest swap allocation */ 844Srgrimes#define DMMAX 4096 /* largest potential swap allocation */ 854Srgrimes#define DMTEXT 1024 /* swap allocation for text */ 864Srgrimes 874Srgrimes/* 884Srgrimes * Sizes of the system and user portions of the system page table. 894Srgrimes */ 904Srgrimes#define SYSPTSIZE (2*NPTEPG) 914Srgrimes#define USRPTSIZE (2*NPTEPG) 924Srgrimes 934Srgrimes/* 944Srgrimes * Size of User Raw I/O map 954Srgrimes */ 964Srgrimes#define USRIOSIZE 300 974Srgrimes 984Srgrimes/* 994Srgrimes * The size of the clock loop. 1004Srgrimes */ 1014Srgrimes#define LOOPPAGES (maxfree - firstfree) 1024Srgrimes 1034Srgrimes/* 1044Srgrimes * The time for a process to be blocked before being very swappable. 1054Srgrimes * This is a number of seconds which the system takes as being a non-trivial 1064Srgrimes * amount of real time. You probably shouldn't change this; 1074Srgrimes * it is used in subtle ways (fractions and multiples of it are, that is, like 1084Srgrimes * half of a ``long time'', almost a long time, etc.) 1094Srgrimes * It is related to human patience and other factors which don't really 1104Srgrimes * change over time. 1114Srgrimes */ 1124Srgrimes#define MAXSLP 20 1134Srgrimes 1144Srgrimes/* 1154Srgrimes * A swapped in process is given a small amount of core without being bothered 1164Srgrimes * by the page replacement algorithm. Basically this says that if you are 1174Srgrimes * swapped in you deserve some resources. We protect the last SAFERSS 1184Srgrimes * pages against paging and will just swap you out rather than paging you. 1194Srgrimes * Note that each process has at least UPAGES+CLSIZE pages which are not 1204Srgrimes * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this 1214Srgrimes * number just means a swapped in process is given around 25k bytes. 1224Srgrimes * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81), 1234Srgrimes * so we loan each swapped in process memory worth 100$, or just admit 1244Srgrimes * that we don't consider it worthwhile and swap it out to disk which costs 1254Srgrimes * $30/mb or about $0.75. 1264Srgrimes * { wfj 6/16/89: Retail AT memory expansion $800/megabyte, loan of $17 1274Srgrimes * on disk costing $7/mb or $0.18 (in memory still 100:1 in cost!) } 1284Srgrimes */ 1294Srgrimes#define SAFERSS 8 /* nominal ``small'' resident set size 1304Srgrimes protected against replacement */ 1314Srgrimes 1324Srgrimes/* 1334Srgrimes * DISKRPM is used to estimate the number of paging i/o operations 1344Srgrimes * which one can expect from a single disk controller. 1354Srgrimes */ 1364Srgrimes#define DISKRPM 60 1374Srgrimes 1384Srgrimes/* 1394Srgrimes * Klustering constants. Klustering is the gathering 1404Srgrimes * of pages together for pagein/pageout, while clustering 1414Srgrimes * is the treatment of hardware page size as though it were 1424Srgrimes * larger than it really is. 1434Srgrimes * 1444Srgrimes * KLMAX gives maximum cluster size in CLSIZE page (cluster-page) 1454Srgrimes * units. Note that KLMAX*CLSIZE must be <= DMMIN in dmap.h. 1464Srgrimes */ 1474Srgrimes 1484Srgrimes#define KLMAX (4/CLSIZE) 1494Srgrimes#define KLSEQL (2/CLSIZE) /* in klust if vadvise(VA_SEQL) */ 1504Srgrimes#define KLIN (4/CLSIZE) /* default data/stack in klust */ 1514Srgrimes#define KLTXT (4/CLSIZE) /* default text in klust */ 1524Srgrimes#define KLOUT (4/CLSIZE) 1534Srgrimes 1544Srgrimes/* 1554Srgrimes * KLSDIST is the advance or retard of the fifo reclaim for sequential 1564Srgrimes * processes data space. 1574Srgrimes */ 1584Srgrimes#define KLSDIST 3 /* klusters advance/retard for seq. fifo */ 1594Srgrimes 1604Srgrimes/* 1614Srgrimes * Paging thresholds (see vm_sched.c). 1624Srgrimes * Strategy of 1/19/85: 1634Srgrimes * lotsfree is 512k bytes, but at most 1/4 of memory 1644Srgrimes * desfree is 200k bytes, but at most 1/8 of memory 1654Srgrimes * minfree is 64k bytes, but at most 1/2 of desfree 1664Srgrimes */ 1674Srgrimes#define LOTSFREE (512 * 1024) 1684Srgrimes#define LOTSFREEFRACT 4 1694Srgrimes#define DESFREE (200 * 1024) 1704Srgrimes#define DESFREEFRACT 8 1714Srgrimes#define MINFREE (64 * 1024) 1724Srgrimes#define MINFREEFRACT 2 1734Srgrimes 1744Srgrimes/* 1754Srgrimes * There are two clock hands, initially separated by HANDSPREAD bytes 1764Srgrimes * (but at most all of user memory). The amount of time to reclaim 1774Srgrimes * a page once the pageout process examines it increases with this 1784Srgrimes * distance and decreases as the scan rate rises. 1794Srgrimes */ 1804Srgrimes#define HANDSPREAD (2 * 1024 * 1024) 1814Srgrimes 1824Srgrimes/* 1834Srgrimes * The number of times per second to recompute the desired paging rate 1844Srgrimes * and poke the pagedaemon. 1854Srgrimes */ 1864Srgrimes#define RATETOSCHEDPAGING 4 1874Srgrimes 1884Srgrimes/* 1894Srgrimes * Believed threshold (in megabytes) for which interleaved 1904Srgrimes * swapping area is desirable. 1914Srgrimes */ 1924Srgrimes#define LOTSOFMEM 2 1934Srgrimes 1944Srgrimes#define mapin(pte, v, pfnum, prot) \ 1954Srgrimes {(*(int *)(pte) = ((pfnum)<<PGSHIFT) | (prot)) ; } 1964Srgrimes 1974Srgrimes/* 1984Srgrimes * Mach derived constants 1994Srgrimes */ 2004Srgrimes 2014Srgrimes/* user/kernel map constants */ 2024Srgrimes#define VM_MIN_ADDRESS ((vm_offset_t)0) 2034Srgrimes#define VM_MAXUSER_ADDRESS ((vm_offset_t)0xFDBFE000) 2044Srgrimes#define UPT_MIN_ADDRESS ((vm_offset_t)0xFDC00000) 2054Srgrimes#define UPT_MAX_ADDRESS ((vm_offset_t)0xFDFF7000) 2064Srgrimes#define VM_MAX_ADDRESS UPT_MAX_ADDRESS 2074Srgrimes#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)0xFDFF7000) 2084Srgrimes#define UPDT VM_MIN_KERNEL_ADDRESS 2094Srgrimes#define KPT_MIN_ADDRESS ((vm_offset_t)0xFDFF8000) 2104Srgrimes#define KPT_MAX_ADDRESS ((vm_offset_t)0xFDFFF000) 2114Srgrimes#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t)0xFF7FF000) 2124Srgrimes 2134Srgrimes/* virtual sizes (bytes) for various kernel submaps */ 2144Srgrimes#define VM_MBUF_SIZE (NMBCLUSTERS*MCLBYTES) 2154Srgrimes#define VM_KMEM_SIZE (NKMEMCLUSTERS*CLBYTES) 2164Srgrimes#define VM_PHYS_SIZE (USRIOSIZE*CLBYTES) 2174Srgrimes 2184Srgrimes/* # of kernel PT pages (initial only, can grow dynamically) */ 2194Srgrimes#define VM_KERNEL_PT_PAGES ((vm_size_t)2) /* XXX: SYSPTSIZE */ 2204Srgrimes 2214Srgrimes/* pcb base */ 2224Srgrimes#define pcbb(p) ((u_int)(p)->p_addr) 2234Srgrimes 2244Srgrimes/* 2254Srgrimes * Flush MMU TLB 2264Srgrimes */ 2274Srgrimes 2284Srgrimes#ifndef I386_CR3PAT 2294Srgrimes#define I386_CR3PAT 0x0 2304Srgrimes#endif 2314Srgrimes 2324Srgrimes#ifdef notyet 2334Srgrimes#define _cr3() ({u_long rtn; \ 2344Srgrimes asm (" movl %%cr3,%%eax; movl %%eax,%0 " \ 2354Srgrimes : "=g" (rtn) \ 2364Srgrimes : \ 2374Srgrimes : "ax"); \ 2384Srgrimes rtn; \ 2394Srgrimes}) 2404Srgrimes 2414Srgrimes#define load_cr3(s) ({ u_long val; \ 2424Srgrimes val = (s) | I386_CR3PAT; \ 2434Srgrimes asm ("movl %0,%%eax; movl %%eax,%%cr3" \ 2444Srgrimes : \ 2454Srgrimes : "g" (val) \ 2464Srgrimes : "ax"); \ 2474Srgrimes}) 2484Srgrimes 2494Srgrimes#define tlbflush() ({ u_long val; \ 2504Srgrimes val = u.u_pcb.pcb_ptd | I386_CR3PAT; \ 2514Srgrimes asm ("movl %0,%%eax; movl %%eax,%%cr3" \ 2524Srgrimes : \ 2534Srgrimes : "g" (val) \ 2544Srgrimes : "ax"); \ 2554Srgrimes}) 2564Srgrimes#endif 257