xref: /csrg-svn/sys/i386/include/vmparam.h (revision 41062)
1*41062Swilliam /*-
2*41062Swilliam  * Copyright (c) 1990 The Regents of the University of California.
3*41062Swilliam  * All rights reserved.
4*41062Swilliam  *
5*41062Swilliam  * This code is derived from software contributed to Berkeley by
6*41062Swilliam  * William Jolitz.
7*41062Swilliam  *
8*41062Swilliam  * %sccs.include.noredist.c%
9*41062Swilliam  *
10*41062Swilliam  *	@(#)vmparam.h	5.1 (Berkeley) 04/24/90
11*41062Swilliam  */
12*41062Swilliam 
13*41062Swilliam /*
14*41062Swilliam  * Machine dependent constants for 386.
15*41062Swilliam  */
16*41062Swilliam 
17*41062Swilliam /*
18*41062Swilliam  * Virtual address space arrangement. On 386, both user and kernel
19*41062Swilliam  * share the address space, not unlike the arrangements on the vax.
20*41062Swilliam  * USRTEXT is the start of the user text/data space, while USRSTACK
21*41062Swilliam  * is the top (end) of the user stack. Immediately above the user stack
22*41062Swilliam  * resides the user structure, which is UPAGES long and contains the
23*41062Swilliam  * kernel stack. As such, UPAGES is the number of pages from the beginning
24*41062Swilliam  * of the P1 region to the beginning of the user stack. Also, the P0
25*41062Swilliam  * region begins with user text and ends with user data.
26*41062Swilliam  * Immediately after the user structure is the kernal address space.
27*41062Swilliam  */
28*41062Swilliam #define	USRTEXT		0
29*41062Swilliam #define	USRSTACK	0xFDFFE000	/* Sysbase - UPAGES*NBPG */
30*41062Swilliam #define	BTOPUSRSTACK	(0xFE000-(UPAGES))	/* btop(USRSTACK) */
31*41062Swilliam 
32*41062Swilliam #define P1PAGES		0xFE000
33*41062Swilliam #define	LOWPAGES	0
34*41062Swilliam #define HIGHPAGES	UPAGES
35*41062Swilliam 
36*41062Swilliam /*
37*41062Swilliam  * Virtual memory related constants, all in bytes
38*41062Swilliam  */
39*41062Swilliam #define	MAXTSIZ		(6*1024*1024)		/* max text size */
40*41062Swilliam #ifndef DFLDSIZ
41*41062Swilliam #define	DFLDSIZ		(6*1024*1024)		/* initial data size limit */
42*41062Swilliam #endif
43*41062Swilliam #ifndef MAXDSIZ
44*41062Swilliam #define	MAXDSIZ		(32*1024*1024)		/* max data size */
45*41062Swilliam #endif
46*41062Swilliam #ifndef	DFLSSIZ
47*41062Swilliam #define	DFLSSIZ		(512*1024)		/* initial stack size limit */
48*41062Swilliam #endif
49*41062Swilliam #ifndef	MAXSSIZ
50*41062Swilliam #define	MAXSSIZ		MAXDSIZ			/* max stack size */
51*41062Swilliam #endif
52*41062Swilliam 
53*41062Swilliam /*
54*41062Swilliam  * Default sizes of swap allocation chunks (see dmap.h).
55*41062Swilliam  * The actual values may be changed in vminit() based on MAXDSIZ.
56*41062Swilliam  * With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024.
57*41062Swilliam  */
58*41062Swilliam #define	DMMIN	32			/* smallest swap allocation */
59*41062Swilliam #define	DMMAX	4096			/* largest potential swap allocation */
60*41062Swilliam #define	DMTEXT	1024			/* swap allocation for text */
61*41062Swilliam 
62*41062Swilliam /*
63*41062Swilliam  * Sizes of the system and user portions of the system page table.
64*41062Swilliam  */
65*41062Swilliam #define	SYSPTSIZE 	(2*NPTEPG)
66*41062Swilliam #define	USRPTSIZE 	(2*NPTEPG)
67*41062Swilliam 
68*41062Swilliam /*
69*41062Swilliam  * The size of the clock loop.
70*41062Swilliam  */
71*41062Swilliam #define	LOOPPAGES	(maxfree - firstfree)
72*41062Swilliam 
73*41062Swilliam /*
74*41062Swilliam  * The time for a process to be blocked before being very swappable.
75*41062Swilliam  * This is a number of seconds which the system takes as being a non-trivial
76*41062Swilliam  * amount of real time.  You probably shouldn't change this;
77*41062Swilliam  * it is used in subtle ways (fractions and multiples of it are, that is, like
78*41062Swilliam  * half of a ``long time'', almost a long time, etc.)
79*41062Swilliam  * It is related to human patience and other factors which don't really
80*41062Swilliam  * change over time.
81*41062Swilliam  */
82*41062Swilliam #define	MAXSLP 		20
83*41062Swilliam 
84*41062Swilliam /*
85*41062Swilliam  * A swapped in process is given a small amount of core without being bothered
86*41062Swilliam  * by the page replacement algorithm.  Basically this says that if you are
87*41062Swilliam  * swapped in you deserve some resources.  We protect the last SAFERSS
88*41062Swilliam  * pages against paging and will just swap you out rather than paging you.
89*41062Swilliam  * Note that each process has at least UPAGES+CLSIZE pages which are not
90*41062Swilliam  * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this
91*41062Swilliam  * number just means a swapped in process is given around 25k bytes.
92*41062Swilliam  * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81),
93*41062Swilliam  * so we loan each swapped in process memory worth 100$, or just admit
94*41062Swilliam  * that we don't consider it worthwhile and swap it out to disk which costs
95*41062Swilliam  * $30/mb or about $0.75.
96*41062Swilliam  * { wfj 6/16/89: Retail AT memory expansion $800/megabyte, loan of $17
97*41062Swilliam  *   on disk costing $7/mb or $0.18 (in memory still 100:1 in cost!) }
98*41062Swilliam  */
99*41062Swilliam #define	SAFERSS		32		/* nominal ``small'' resident set size
100*41062Swilliam 					   protected against replacement */
101*41062Swilliam 
102*41062Swilliam /*
103*41062Swilliam  * DISKRPM is used to estimate the number of paging i/o operations
104*41062Swilliam  * which one can expect from a single disk controller.
105*41062Swilliam  */
106*41062Swilliam #define	DISKRPM		60
107*41062Swilliam 
108*41062Swilliam /*
109*41062Swilliam  * Klustering constants.  Klustering is the gathering
110*41062Swilliam  * of pages together for pagein/pageout, while clustering
111*41062Swilliam  * is the treatment of hardware page size as though it were
112*41062Swilliam  * larger than it really is.
113*41062Swilliam  *
114*41062Swilliam  * KLMAX gives maximum cluster size in CLSIZE page (cluster-page)
115*41062Swilliam  * units.  Note that KLMAX*CLSIZE must be <= DMMIN in dmap.h.
116*41062Swilliam  */
117*41062Swilliam 
118*41062Swilliam #define	KLMAX	(4/CLSIZE)
119*41062Swilliam #define	KLSEQL	(2/CLSIZE)		/* in klust if vadvise(VA_SEQL) */
120*41062Swilliam #define	KLIN	(4/CLSIZE)		/* default data/stack in klust */
121*41062Swilliam #define	KLTXT	(4/CLSIZE)		/* default text in klust */
122*41062Swilliam #define	KLOUT	(4/CLSIZE)
123*41062Swilliam 
124*41062Swilliam /*
125*41062Swilliam  * KLSDIST is the advance or retard of the fifo reclaim for sequential
126*41062Swilliam  * processes data space.
127*41062Swilliam  */
128*41062Swilliam #define	KLSDIST	3		/* klusters advance/retard for seq. fifo */
129*41062Swilliam 
130*41062Swilliam /*
131*41062Swilliam  * Paging thresholds (see vm_sched.c).
132*41062Swilliam  * Strategy of 1/19/85:
133*41062Swilliam  *	lotsfree is 512k bytes, but at most 1/4 of memory
134*41062Swilliam  *	desfree is 200k bytes, but at most 1/8 of memory
135*41062Swilliam  *	minfree is 64k bytes, but at most 1/2 of desfree
136*41062Swilliam  */
137*41062Swilliam #define	LOTSFREE	(512 * 1024)
138*41062Swilliam #define	LOTSFREEFRACT	4
139*41062Swilliam #define	DESFREE		(200 * 1024)
140*41062Swilliam #define	DESFREEFRACT	8
141*41062Swilliam #define	MINFREE		(64 * 1024)
142*41062Swilliam #define	MINFREEFRACT	2
143*41062Swilliam 
144*41062Swilliam /*
145*41062Swilliam  * There are two clock hands, initially separated by HANDSPREAD bytes
146*41062Swilliam  * (but at most all of user memory).  The amount of time to reclaim
147*41062Swilliam  * a page once the pageout process examines it increases with this
148*41062Swilliam  * distance and decreases as the scan rate rises.
149*41062Swilliam  */
150*41062Swilliam #define	HANDSPREAD	(2 * 1024 * 1024)
151*41062Swilliam 
152*41062Swilliam /*
153*41062Swilliam  * The number of times per second to recompute the desired paging rate
154*41062Swilliam  * and poke the pagedaemon.
155*41062Swilliam  */
156*41062Swilliam #define	RATETOSCHEDPAGING	4
157*41062Swilliam 
158*41062Swilliam /*
159*41062Swilliam  * Believed threshold (in megabytes) for which interleaved
160*41062Swilliam  * swapping area is desirable.
161*41062Swilliam  */
162*41062Swilliam #define	LOTSOFMEM	2
163*41062Swilliam 
164*41062Swilliam #define	mapin(pte, v, pfnum, prot) \
165*41062Swilliam 	(*(int *)(pte) = ((pfnum)<<PGSHIFT) | (prot))
166*41062Swilliam 
167*41062Swilliam /*
168*41062Swilliam  * Invalidate a cluster (optimized here for standard CLSIZE).
169*41062Swilliam  */
170*41062Swilliam #if CLSIZE == 1
171*41062Swilliam #define	tbiscl(v)
172*41062Swilliam #endif
173