vmparam.h revision 879
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 * 36607Srgrimes * from: @(#)vmparam.h 5.9 (Berkeley) 5/12/91 37879Swollman * $Id: vmparam.h,v 1.8 1993/11/07 17:43:17 wollman Exp $ 384Srgrimes */ 394Srgrimes 404Srgrimes 41719Swollman#ifndef _MACHINE_VMPARAM_H_ 42719Swollman#define _MACHINE_VMPARAM_H_ 1 43719Swollman 444Srgrimes/* 454Srgrimes * Machine dependent constants for 386. 464Srgrimes */ 474Srgrimes 484Srgrimes/* 494Srgrimes * Virtual address space arrangement. On 386, both user and kernel 504Srgrimes * share the address space, not unlike the vax. 514Srgrimes * USRTEXT is the start of the user text/data space, while USRSTACK 524Srgrimes * is the top (end) of the user stack. Immediately above the user stack 534Srgrimes * resides the user structure, which is UPAGES long and contains the 544Srgrimes * kernel stack. 554Srgrimes * 564Srgrimes * Immediately after the user structure is the page table map, and then 574Srgrimes * kernal address space. 584Srgrimes */ 59879Swollman#define USRTEXT 0UL 60879Swollman#define USRSTACK 0xFDBFE000UL 614Srgrimes#define BTOPUSRSTACK (0xFDC00-(UPAGES)) /* btop(USRSTACK) */ 62879Swollman#define LOWPAGES 0UL 634Srgrimes#define HIGHPAGES UPAGES 644Srgrimes 654Srgrimes/* 664Srgrimes * Virtual memory related constants, all in bytes 674Srgrimes */ 68879Swollman#define MAXTSIZ (6UL*1024*1024) /* max text size */ 694Srgrimes#ifndef DFLDSIZ 70879Swollman#define DFLDSIZ (16UL*1024*1024) /* initial data size limit */ 714Srgrimes#endif 724Srgrimes#ifndef MAXDSIZ 73879Swollman#define MAXDSIZ (32UL*1024*1024) /* max data size */ 744Srgrimes#endif 754Srgrimes#ifndef DFLSSIZ 76879Swollman#define DFLSSIZ (512UL*1024) /* initial stack size limit */ 774Srgrimes#endif 784Srgrimes#ifndef MAXSSIZ 79879Swollman#define MAXSSIZ (8UL*1024*1024) /* max stack size */ 804Srgrimes#endif 814Srgrimes 824Srgrimes/* 834Srgrimes * Default sizes of swap allocation chunks (see dmap.h). 844Srgrimes * The actual values may be changed in vminit() based on MAXDSIZ. 854Srgrimes * With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024. 864Srgrimes */ 874Srgrimes#define DMMIN 32 /* smallest swap allocation */ 884Srgrimes#define DMMAX 4096 /* largest potential swap allocation */ 894Srgrimes#define DMTEXT 1024 /* swap allocation for text */ 904Srgrimes 914Srgrimes/* 924Srgrimes * Sizes of the system and user portions of the system page table. 934Srgrimes */ 944Srgrimes#define SYSPTSIZE (2*NPTEPG) 954Srgrimes#define USRPTSIZE (2*NPTEPG) 964Srgrimes 974Srgrimes/* 98511Srgrimes * Size of the Shared Memory Pages page table. 99511Srgrimes */ 100561Sdg#ifndef SHMMAXPGS 101607Srgrimes#define SHMMAXPGS 512 /* XXX until we have more kmap space */ 102511Srgrimes#endif 103511Srgrimes 104511Srgrimes/* 1054Srgrimes * Size of User Raw I/O map 1064Srgrimes */ 1074Srgrimes#define USRIOSIZE 300 1084Srgrimes 1094Srgrimes/* 1104Srgrimes * The size of the clock loop. 1114Srgrimes */ 1124Srgrimes#define LOOPPAGES (maxfree - firstfree) 1134Srgrimes 1144Srgrimes/* 1154Srgrimes * The time for a process to be blocked before being very swappable. 1164Srgrimes * This is a number of seconds which the system takes as being a non-trivial 1174Srgrimes * amount of real time. You probably shouldn't change this; 1184Srgrimes * it is used in subtle ways (fractions and multiples of it are, that is, like 1194Srgrimes * half of a ``long time'', almost a long time, etc.) 1204Srgrimes * It is related to human patience and other factors which don't really 1214Srgrimes * change over time. 1224Srgrimes */ 1234Srgrimes#define MAXSLP 20 1244Srgrimes 1254Srgrimes/* 1264Srgrimes * A swapped in process is given a small amount of core without being bothered 1274Srgrimes * by the page replacement algorithm. Basically this says that if you are 1284Srgrimes * swapped in you deserve some resources. We protect the last SAFERSS 1294Srgrimes * pages against paging and will just swap you out rather than paging you. 1304Srgrimes * Note that each process has at least UPAGES+CLSIZE pages which are not 1314Srgrimes * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this 1324Srgrimes * number just means a swapped in process is given around 25k bytes. 1334Srgrimes * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81), 1344Srgrimes * so we loan each swapped in process memory worth 100$, or just admit 1354Srgrimes * that we don't consider it worthwhile and swap it out to disk which costs 1364Srgrimes * $30/mb or about $0.75. 1374Srgrimes * { wfj 6/16/89: Retail AT memory expansion $800/megabyte, loan of $17 1384Srgrimes * on disk costing $7/mb or $0.18 (in memory still 100:1 in cost!) } 1394Srgrimes */ 1404Srgrimes#define SAFERSS 8 /* nominal ``small'' resident set size 1414Srgrimes protected against replacement */ 1424Srgrimes 1434Srgrimes/* 1444Srgrimes * DISKRPM is used to estimate the number of paging i/o operations 1454Srgrimes * which one can expect from a single disk controller. 1464Srgrimes */ 1474Srgrimes#define DISKRPM 60 1484Srgrimes 1494Srgrimes/* 1504Srgrimes * Klustering constants. Klustering is the gathering 1514Srgrimes * of pages together for pagein/pageout, while clustering 1524Srgrimes * is the treatment of hardware page size as though it were 1534Srgrimes * larger than it really is. 1544Srgrimes * 1554Srgrimes * KLMAX gives maximum cluster size in CLSIZE page (cluster-page) 1564Srgrimes * units. Note that KLMAX*CLSIZE must be <= DMMIN in dmap.h. 1574Srgrimes */ 1584Srgrimes 1594Srgrimes#define KLMAX (4/CLSIZE) 1604Srgrimes#define KLSEQL (2/CLSIZE) /* in klust if vadvise(VA_SEQL) */ 1614Srgrimes#define KLIN (4/CLSIZE) /* default data/stack in klust */ 1624Srgrimes#define KLTXT (4/CLSIZE) /* default text in klust */ 1634Srgrimes#define KLOUT (4/CLSIZE) 1644Srgrimes 1654Srgrimes/* 1664Srgrimes * KLSDIST is the advance or retard of the fifo reclaim for sequential 1674Srgrimes * processes data space. 1684Srgrimes */ 1694Srgrimes#define KLSDIST 3 /* klusters advance/retard for seq. fifo */ 1704Srgrimes 1714Srgrimes/* 1724Srgrimes * Paging thresholds (see vm_sched.c). 1734Srgrimes * Strategy of 1/19/85: 1744Srgrimes * lotsfree is 512k bytes, but at most 1/4 of memory 1754Srgrimes * desfree is 200k bytes, but at most 1/8 of memory 1764Srgrimes * minfree is 64k bytes, but at most 1/2 of desfree 1774Srgrimes */ 1784Srgrimes#define LOTSFREE (512 * 1024) 1794Srgrimes#define LOTSFREEFRACT 4 1804Srgrimes#define DESFREE (200 * 1024) 1814Srgrimes#define DESFREEFRACT 8 1824Srgrimes#define MINFREE (64 * 1024) 1834Srgrimes#define MINFREEFRACT 2 1844Srgrimes 1854Srgrimes/* 1864Srgrimes * There are two clock hands, initially separated by HANDSPREAD bytes 1874Srgrimes * (but at most all of user memory). The amount of time to reclaim 1884Srgrimes * a page once the pageout process examines it increases with this 1894Srgrimes * distance and decreases as the scan rate rises. 1904Srgrimes */ 1914Srgrimes#define HANDSPREAD (2 * 1024 * 1024) 1924Srgrimes 1934Srgrimes/* 1944Srgrimes * The number of times per second to recompute the desired paging rate 1954Srgrimes * and poke the pagedaemon. 1964Srgrimes */ 1974Srgrimes#define RATETOSCHEDPAGING 4 1984Srgrimes 1994Srgrimes/* 2004Srgrimes * Believed threshold (in megabytes) for which interleaved 2014Srgrimes * swapping area is desirable. 2024Srgrimes */ 2034Srgrimes#define LOTSOFMEM 2 2044Srgrimes 2054Srgrimes#define mapin(pte, v, pfnum, prot) \ 2064Srgrimes {(*(int *)(pte) = ((pfnum)<<PGSHIFT) | (prot)) ; } 2074Srgrimes 2084Srgrimes/* 2094Srgrimes * Mach derived constants 2104Srgrimes */ 2114Srgrimes 2124Srgrimes/* user/kernel map constants */ 2134Srgrimes#define VM_MIN_ADDRESS ((vm_offset_t)0) 214879Swollman#define VM_MAXUSER_ADDRESS ((vm_offset_t)0xFDBFE000UL) 215879Swollman#define UPT_MIN_ADDRESS ((vm_offset_t)0xFDC00000UL) 216879Swollman#define UPT_MAX_ADDRESS ((vm_offset_t)0xFDFF7000UL) 2174Srgrimes#define VM_MAX_ADDRESS UPT_MAX_ADDRESS 218879Swollman#define VM_MIN_KERNEL_ADDRESS ((vm_offset_t)0xFDFF7000UL) 2194Srgrimes#define UPDT VM_MIN_KERNEL_ADDRESS 220879Swollman#define KPT_MIN_ADDRESS ((vm_offset_t)0xFDFF8000UL) 221879Swollman#define KPT_MAX_ADDRESS ((vm_offset_t)0xFDFFF000UL) 222879Swollman#define VM_MAX_KERNEL_ADDRESS ((vm_offset_t)0xFF7FF000UL) 2234Srgrimes 2244Srgrimes/* virtual sizes (bytes) for various kernel submaps */ 2254Srgrimes#define VM_MBUF_SIZE (NMBCLUSTERS*MCLBYTES) 226607Srgrimes#define VM_KMEM_SIZE (16 * 1024 * 1024) 2274Srgrimes#define VM_PHYS_SIZE (USRIOSIZE*CLBYTES) 2284Srgrimes 2294Srgrimes/* pcb base */ 2304Srgrimes#define pcbb(p) ((u_int)(p)->p_addr) 2314Srgrimes 2324Srgrimes/* 2334Srgrimes * Flush MMU TLB 2344Srgrimes */ 2354Srgrimes 2364Srgrimes#ifndef I386_CR3PAT 2374Srgrimes#define I386_CR3PAT 0x0 2384Srgrimes#endif 2394Srgrimes 2404Srgrimes#ifdef notyet 2414Srgrimes#define _cr3() ({u_long rtn; \ 2424Srgrimes asm (" movl %%cr3,%%eax; movl %%eax,%0 " \ 2434Srgrimes : "=g" (rtn) \ 2444Srgrimes : \ 2454Srgrimes : "ax"); \ 2464Srgrimes rtn; \ 2474Srgrimes}) 2484Srgrimes 2494Srgrimes#define load_cr3(s) ({ u_long val; \ 2504Srgrimes val = (s) | I386_CR3PAT; \ 2514Srgrimes asm ("movl %0,%%eax; movl %%eax,%%cr3" \ 2524Srgrimes : \ 2534Srgrimes : "g" (val) \ 2544Srgrimes : "ax"); \ 2554Srgrimes}) 2564Srgrimes 2574Srgrimes#define tlbflush() ({ u_long val; \ 2584Srgrimes val = u.u_pcb.pcb_ptd | I386_CR3PAT; \ 2594Srgrimes asm ("movl %0,%%eax; movl %%eax,%%cr3" \ 2604Srgrimes : \ 2614Srgrimes : "g" (val) \ 2624Srgrimes : "ax"); \ 2634Srgrimes}) 2644Srgrimes#endif 265719Swollman#endif /* _MACHINE_VMPARAM_H_ */ 266