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