xref: /csrg-svn/sys/i386/include/vmparam.h (revision 45964)
141062Swilliam /*-
241062Swilliam  * Copyright (c) 1990 The Regents of the University of California.
341062Swilliam  * All rights reserved.
441062Swilliam  *
541062Swilliam  * This code is derived from software contributed to Berkeley by
641062Swilliam  * William Jolitz.
741062Swilliam  *
841062Swilliam  * %sccs.include.noredist.c%
941062Swilliam  *
10*45964Swilliam  *	@(#)vmparam.h	5.4 (Berkeley) 01/15/91
1141062Swilliam  */
1241062Swilliam 
13*45964Swilliam 
1441062Swilliam /*
1541062Swilliam  * Machine dependent constants for 386.
1641062Swilliam  */
1741062Swilliam 
1841062Swilliam /*
1941062Swilliam  * Virtual address space arrangement. On 386, both user and kernel
20*45964Swilliam  * share the address space, not unlike the vax.
2141062Swilliam  * USRTEXT is the start of the user text/data space, while USRSTACK
2241062Swilliam  * is the top (end) of the user stack. Immediately above the user stack
2341062Swilliam  * resides the user structure, which is UPAGES long and contains the
2441062Swilliam  * kernel stack. As such, UPAGES is the number of pages from the beginning
2541062Swilliam  * of the P1 region to the beginning of the user stack. Also, the P0
2641062Swilliam  * region begins with user text and ends with user data.
2741062Swilliam  * Immediately after the user structure is the kernal address space.
2841062Swilliam  */
2941062Swilliam #define	USRTEXT		0
3041062Swilliam #define	USRSTACK	0xFDFFE000	/* Sysbase - UPAGES*NBPG */
3141062Swilliam #define	BTOPUSRSTACK	(0xFE000-(UPAGES))	/* btop(USRSTACK) */
3241062Swilliam 
3341062Swilliam #define P1PAGES		0xFE000
3441062Swilliam #define	LOWPAGES	0
3541062Swilliam #define HIGHPAGES	UPAGES
3641062Swilliam 
3741062Swilliam /*
3841062Swilliam  * Virtual memory related constants, all in bytes
3941062Swilliam  */
4041062Swilliam #define	MAXTSIZ		(6*1024*1024)		/* max text size */
4141062Swilliam #ifndef DFLDSIZ
4241062Swilliam #define	DFLDSIZ		(6*1024*1024)		/* initial data size limit */
4341062Swilliam #endif
4441062Swilliam #ifndef MAXDSIZ
4541062Swilliam #define	MAXDSIZ		(32*1024*1024)		/* max data size */
4641062Swilliam #endif
4741062Swilliam #ifndef	DFLSSIZ
4841062Swilliam #define	DFLSSIZ		(512*1024)		/* initial stack size limit */
4941062Swilliam #endif
5041062Swilliam #ifndef	MAXSSIZ
5141062Swilliam #define	MAXSSIZ		MAXDSIZ			/* max stack size */
5241062Swilliam #endif
5341062Swilliam 
5441062Swilliam /*
5541062Swilliam  * Default sizes of swap allocation chunks (see dmap.h).
5641062Swilliam  * The actual values may be changed in vminit() based on MAXDSIZ.
5741062Swilliam  * With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024.
5841062Swilliam  */
5941062Swilliam #define	DMMIN	32			/* smallest swap allocation */
6041062Swilliam #define	DMMAX	4096			/* largest potential swap allocation */
6141062Swilliam #define	DMTEXT	1024			/* swap allocation for text */
6241062Swilliam 
6341062Swilliam /*
6441062Swilliam  * Sizes of the system and user portions of the system page table.
6541062Swilliam  */
6641062Swilliam #define	SYSPTSIZE 	(2*NPTEPG)
6741062Swilliam #define	USRPTSIZE 	(2*NPTEPG)
6841062Swilliam 
6941062Swilliam /*
7045593Sbill  * Size of User Raw I/O map
7145593Sbill  */
72*45964Swilliam #define	USRIOSIZE 	300
7345593Sbill 
7445593Sbill /*
7541062Swilliam  * The size of the clock loop.
7641062Swilliam  */
7741062Swilliam #define	LOOPPAGES	(maxfree - firstfree)
7841062Swilliam 
7941062Swilliam /*
8041062Swilliam  * The time for a process to be blocked before being very swappable.
8141062Swilliam  * This is a number of seconds which the system takes as being a non-trivial
8241062Swilliam  * amount of real time.  You probably shouldn't change this;
8341062Swilliam  * it is used in subtle ways (fractions and multiples of it are, that is, like
8441062Swilliam  * half of a ``long time'', almost a long time, etc.)
8541062Swilliam  * It is related to human patience and other factors which don't really
8641062Swilliam  * change over time.
8741062Swilliam  */
8841062Swilliam #define	MAXSLP 		20
8941062Swilliam 
9041062Swilliam /*
9141062Swilliam  * A swapped in process is given a small amount of core without being bothered
9241062Swilliam  * by the page replacement algorithm.  Basically this says that if you are
9341062Swilliam  * swapped in you deserve some resources.  We protect the last SAFERSS
9441062Swilliam  * pages against paging and will just swap you out rather than paging you.
9541062Swilliam  * Note that each process has at least UPAGES+CLSIZE pages which are not
9641062Swilliam  * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this
9741062Swilliam  * number just means a swapped in process is given around 25k bytes.
9841062Swilliam  * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81),
9941062Swilliam  * so we loan each swapped in process memory worth 100$, or just admit
10041062Swilliam  * that we don't consider it worthwhile and swap it out to disk which costs
10141062Swilliam  * $30/mb or about $0.75.
10241062Swilliam  * { wfj 6/16/89: Retail AT memory expansion $800/megabyte, loan of $17
10341062Swilliam  *   on disk costing $7/mb or $0.18 (in memory still 100:1 in cost!) }
10441062Swilliam  */
10545593Sbill #define	SAFERSS		8		/* nominal ``small'' resident set size
10641062Swilliam 					   protected against replacement */
10741062Swilliam 
10841062Swilliam /*
10941062Swilliam  * DISKRPM is used to estimate the number of paging i/o operations
11041062Swilliam  * which one can expect from a single disk controller.
11141062Swilliam  */
11241062Swilliam #define	DISKRPM		60
11341062Swilliam 
11441062Swilliam /*
11541062Swilliam  * Klustering constants.  Klustering is the gathering
11641062Swilliam  * of pages together for pagein/pageout, while clustering
11741062Swilliam  * is the treatment of hardware page size as though it were
11841062Swilliam  * larger than it really is.
11941062Swilliam  *
12041062Swilliam  * KLMAX gives maximum cluster size in CLSIZE page (cluster-page)
12141062Swilliam  * units.  Note that KLMAX*CLSIZE must be <= DMMIN in dmap.h.
12241062Swilliam  */
12341062Swilliam 
12441062Swilliam #define	KLMAX	(4/CLSIZE)
12541062Swilliam #define	KLSEQL	(2/CLSIZE)		/* in klust if vadvise(VA_SEQL) */
12641062Swilliam #define	KLIN	(4/CLSIZE)		/* default data/stack in klust */
12741062Swilliam #define	KLTXT	(4/CLSIZE)		/* default text in klust */
12841062Swilliam #define	KLOUT	(4/CLSIZE)
12941062Swilliam 
13041062Swilliam /*
13141062Swilliam  * KLSDIST is the advance or retard of the fifo reclaim for sequential
13241062Swilliam  * processes data space.
13341062Swilliam  */
13441062Swilliam #define	KLSDIST	3		/* klusters advance/retard for seq. fifo */
13541062Swilliam 
13641062Swilliam /*
13741062Swilliam  * Paging thresholds (see vm_sched.c).
13841062Swilliam  * Strategy of 1/19/85:
13941062Swilliam  *	lotsfree is 512k bytes, but at most 1/4 of memory
14041062Swilliam  *	desfree is 200k bytes, but at most 1/8 of memory
14141062Swilliam  *	minfree is 64k bytes, but at most 1/2 of desfree
14241062Swilliam  */
14341062Swilliam #define	LOTSFREE	(512 * 1024)
14441062Swilliam #define	LOTSFREEFRACT	4
14541062Swilliam #define	DESFREE		(200 * 1024)
14641062Swilliam #define	DESFREEFRACT	8
14741062Swilliam #define	MINFREE		(64 * 1024)
14841062Swilliam #define	MINFREEFRACT	2
14941062Swilliam 
15041062Swilliam /*
15141062Swilliam  * There are two clock hands, initially separated by HANDSPREAD bytes
15241062Swilliam  * (but at most all of user memory).  The amount of time to reclaim
15341062Swilliam  * a page once the pageout process examines it increases with this
15441062Swilliam  * distance and decreases as the scan rate rises.
15541062Swilliam  */
15641062Swilliam #define	HANDSPREAD	(2 * 1024 * 1024)
15741062Swilliam 
15841062Swilliam /*
15941062Swilliam  * The number of times per second to recompute the desired paging rate
16041062Swilliam  * and poke the pagedaemon.
16141062Swilliam  */
16241062Swilliam #define	RATETOSCHEDPAGING	4
16341062Swilliam 
16441062Swilliam /*
16541062Swilliam  * Believed threshold (in megabytes) for which interleaved
16641062Swilliam  * swapping area is desirable.
16741062Swilliam  */
16841062Swilliam #define	LOTSOFMEM	2
16941062Swilliam 
17041062Swilliam #define	mapin(pte, v, pfnum, prot) \
171*45964Swilliam 	{(*(int *)(pte) = ((pfnum)<<PGSHIFT) | (prot)) ; }
17241062Swilliam 
17341062Swilliam /*
17441062Swilliam  * Invalidate a cluster (optimized here for standard CLSIZE).
17541062Swilliam  */
17641062Swilliam #if CLSIZE == 1
17741062Swilliam #define	tbiscl(v)
17841062Swilliam #endif
17945593Sbill 
18045593Sbill /*
18145593Sbill  * Flush MMU TLB
18245593Sbill  */
18345593Sbill 
18445623Sbill #ifndef I386_CR3PAT
18545623Sbill #define	I386_CR3PAT	0x0
18645623Sbill #endif
18745623Sbill 
18845623Sbill #define _cr3() ({u_long rtn; \
18945623Sbill 	asm (" movl %%cr3,%%eax; movl %%eax,%0 " \
19045623Sbill 		: "=g" (rtn) \
19145623Sbill 		: \
19245623Sbill 		: "ax"); \
19345623Sbill 	rtn; \
19445623Sbill })
19545623Sbill 
19645623Sbill #define load_cr3(s) ({ u_long val; \
19745623Sbill 	val = (s) | I386_CR3PAT; \
19845623Sbill 	asm ("movl %0,%%eax; movl %%eax,%%cr3" \
19945623Sbill 		:  \
20045623Sbill 		: "g" (val) \
20145623Sbill 		: "ax"); \
20245623Sbill })
203*45964Swilliam 
204*45964Swilliam #define tlbflush() ({ u_long val; \
205*45964Swilliam 	val = u.u_pcb.pcb_ptd | I386_CR3PAT; \
206*45964Swilliam 	asm ("movl %0,%%eax; movl %%eax,%%cr3" \
207*45964Swilliam 		:  \
208*45964Swilliam 		: "g" (val) \
209*45964Swilliam 		: "ax"); \
210*45964Swilliam })
211