xref: /titanic_53/usr/src/uts/common/sys/vmsystm.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
32*7c478bd9Sstevel@tonic-gate  * The Regents of the University of California
33*7c478bd9Sstevel@tonic-gate  * All Rights Reserved
34*7c478bd9Sstevel@tonic-gate  *
35*7c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
36*7c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
37*7c478bd9Sstevel@tonic-gate  * contributors.
38*7c478bd9Sstevel@tonic-gate  */
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #ifndef _SYS_VMSYSTM_H
41*7c478bd9Sstevel@tonic-gate #define	_SYS_VMSYSTM_H
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #include <sys/proc.h>
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
48*7c478bd9Sstevel@tonic-gate extern "C" {
49*7c478bd9Sstevel@tonic-gate #endif
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate /*
52*7c478bd9Sstevel@tonic-gate  * Miscellaneous virtual memory subsystem variables and structures.
53*7c478bd9Sstevel@tonic-gate  */
54*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
55*7c478bd9Sstevel@tonic-gate extern pgcnt_t	freemem;	/* remaining blocks of free memory */
56*7c478bd9Sstevel@tonic-gate extern pgcnt_t	avefree;	/* 5 sec moving average of free memory */
57*7c478bd9Sstevel@tonic-gate extern pgcnt_t	avefree30;	/* 30 sec moving average of free memory */
58*7c478bd9Sstevel@tonic-gate extern pgcnt_t	deficit;	/* estimate of needs of new swapped in procs */
59*7c478bd9Sstevel@tonic-gate extern pgcnt_t	nscan;		/* number of scans in last second */
60*7c478bd9Sstevel@tonic-gate extern pgcnt_t	desscan;	/* desired pages scanned per second */
61*7c478bd9Sstevel@tonic-gate extern pgcnt_t	slowscan;
62*7c478bd9Sstevel@tonic-gate extern pgcnt_t	fastscan;
63*7c478bd9Sstevel@tonic-gate extern pgcnt_t	pushes;		/* number of pages pushed to swap device */
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate /* writable copies of tunables */
66*7c478bd9Sstevel@tonic-gate extern pgcnt_t	maxpgio;	/* max paging i/o per sec before start swaps */
67*7c478bd9Sstevel@tonic-gate extern pgcnt_t	lotsfree;	/* max free before clock freezes */
68*7c478bd9Sstevel@tonic-gate extern pgcnt_t	desfree;	/* minimum free pages before swapping begins */
69*7c478bd9Sstevel@tonic-gate extern pgcnt_t	minfree;	/* no of pages to try to keep free via daemon */
70*7c478bd9Sstevel@tonic-gate extern pgcnt_t	needfree;	/* no of pages currently being waited for */
71*7c478bd9Sstevel@tonic-gate extern pgcnt_t	throttlefree;	/* point at which we block PG_WAIT calls */
72*7c478bd9Sstevel@tonic-gate extern pgcnt_t	pageout_reserve; /* point at which we deny non-PG_WAIT calls */
73*7c478bd9Sstevel@tonic-gate extern pgcnt_t	pages_before_pager; /* XXX */
74*7c478bd9Sstevel@tonic-gate 
75*7c478bd9Sstevel@tonic-gate /*
76*7c478bd9Sstevel@tonic-gate  * TRUE if the pageout daemon, fsflush daemon or the scheduler.  These
77*7c478bd9Sstevel@tonic-gate  * processes can't sleep while trying to free up memory since a deadlock
78*7c478bd9Sstevel@tonic-gate  * will occur if they do sleep.
79*7c478bd9Sstevel@tonic-gate  */
80*7c478bd9Sstevel@tonic-gate #define	NOMEMWAIT() (ttoproc(curthread) == proc_pageout || \
81*7c478bd9Sstevel@tonic-gate 			ttoproc(curthread) == proc_fsflush || \
82*7c478bd9Sstevel@tonic-gate 			ttoproc(curthread) == proc_sched)
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate /* insure non-zero */
85*7c478bd9Sstevel@tonic-gate #define	nz(x)	((x) != 0 ? (x) : 1)
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate /*
88*7c478bd9Sstevel@tonic-gate  * Flags passed by the swapper to swapout routines of each
89*7c478bd9Sstevel@tonic-gate  * scheduling class.
90*7c478bd9Sstevel@tonic-gate  */
91*7c478bd9Sstevel@tonic-gate #define	HARDSWAP	1
92*7c478bd9Sstevel@tonic-gate #define	SOFTSWAP	2
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate /*
95*7c478bd9Sstevel@tonic-gate  * Values returned by valid_usr_range()
96*7c478bd9Sstevel@tonic-gate  */
97*7c478bd9Sstevel@tonic-gate #define	RANGE_OKAY	(0)
98*7c478bd9Sstevel@tonic-gate #define	RANGE_BADADDR	(1)
99*7c478bd9Sstevel@tonic-gate #define	RANGE_BADPROT	(2)
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate /*
102*7c478bd9Sstevel@tonic-gate  * map_pgsz: temporary - subject to change.
103*7c478bd9Sstevel@tonic-gate  */
104*7c478bd9Sstevel@tonic-gate #define	MAPPGSZ_VA	0x01
105*7c478bd9Sstevel@tonic-gate #define	MAPPGSZ_STK	0x02
106*7c478bd9Sstevel@tonic-gate #define	MAPPGSZ_HEAP	0x04
107*7c478bd9Sstevel@tonic-gate #define	MAPPGSZ_ISM	0x08
108*7c478bd9Sstevel@tonic-gate 
109*7c478bd9Sstevel@tonic-gate struct as;
110*7c478bd9Sstevel@tonic-gate struct page;
111*7c478bd9Sstevel@tonic-gate struct anon;
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate extern int maxslp;
114*7c478bd9Sstevel@tonic-gate extern ulong_t pginrate;
115*7c478bd9Sstevel@tonic-gate extern ulong_t pgoutrate;
116*7c478bd9Sstevel@tonic-gate extern void swapout_lwp(klwp_t *);
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate extern	int valid_va_range(caddr_t *basep, size_t *lenp, size_t minlen,
119*7c478bd9Sstevel@tonic-gate 		int dir);
120*7c478bd9Sstevel@tonic-gate extern	int valid_usr_range(caddr_t, size_t, uint_t, struct as *, caddr_t);
121*7c478bd9Sstevel@tonic-gate extern	int useracc(void *, size_t, int);
122*7c478bd9Sstevel@tonic-gate extern	size_t map_pgsz(int maptype, struct proc *p, caddr_t addr,
123*7c478bd9Sstevel@tonic-gate 		size_t len, int *remap);
124*7c478bd9Sstevel@tonic-gate extern	uint_t map_execseg_pgszcvec(int, caddr_t, size_t);
125*7c478bd9Sstevel@tonic-gate extern	void map_addr(caddr_t *addrp, size_t len, offset_t off, int vacalign,
126*7c478bd9Sstevel@tonic-gate     uint_t flags);
127*7c478bd9Sstevel@tonic-gate extern	int map_addr_vacalign_check(caddr_t, u_offset_t);
128*7c478bd9Sstevel@tonic-gate extern	void map_addr_proc(caddr_t *addrp, size_t len, offset_t off,
129*7c478bd9Sstevel@tonic-gate     int vacalign, caddr_t userlimit, struct proc *p, uint_t flags);
130*7c478bd9Sstevel@tonic-gate extern	void vmmeter(void);
131*7c478bd9Sstevel@tonic-gate extern	int cow_mapin(struct as *, caddr_t, caddr_t, struct page **,
132*7c478bd9Sstevel@tonic-gate 	struct anon **, size_t *, int);
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate extern	caddr_t	ppmapin(struct page *, uint_t, caddr_t);
135*7c478bd9Sstevel@tonic-gate extern	void	ppmapout(caddr_t);
136*7c478bd9Sstevel@tonic-gate 
137*7c478bd9Sstevel@tonic-gate extern	int pf_is_memory(pfn_t);
138*7c478bd9Sstevel@tonic-gate extern	void	pageout_init(void (*proc)(), proc_t *pp, pri_t pri);
139*7c478bd9Sstevel@tonic-gate 
140*7c478bd9Sstevel@tonic-gate extern	void	dcache_flushall(void);
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate extern	void	*boot_virt_alloc(void *addr, size_t size);
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
147*7c478bd9Sstevel@tonic-gate }
148*7c478bd9Sstevel@tonic-gate #endif
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_VMSYSTM_H */
151