xref: /onnv-gate/usr/src/uts/common/sys/vmsystm.h (revision 5668:7066e93e6b89)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52414Saguzovsk  * Common Development and Distribution License (the "License").
62414Saguzovsk  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*5668Smec  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
270Sstevel@tonic-gate /*	  All Rights Reserved  	*/
280Sstevel@tonic-gate 
290Sstevel@tonic-gate /*
300Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
310Sstevel@tonic-gate  * The Regents of the University of California
320Sstevel@tonic-gate  * All Rights Reserved
330Sstevel@tonic-gate  *
340Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
350Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
360Sstevel@tonic-gate  * contributors.
370Sstevel@tonic-gate  */
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #ifndef _SYS_VMSYSTM_H
400Sstevel@tonic-gate #define	_SYS_VMSYSTM_H
410Sstevel@tonic-gate 
420Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
430Sstevel@tonic-gate 
440Sstevel@tonic-gate #include <sys/proc.h>
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #ifdef	__cplusplus
470Sstevel@tonic-gate extern "C" {
480Sstevel@tonic-gate #endif
490Sstevel@tonic-gate 
500Sstevel@tonic-gate /*
510Sstevel@tonic-gate  * Miscellaneous virtual memory subsystem variables and structures.
520Sstevel@tonic-gate  */
530Sstevel@tonic-gate #ifdef _KERNEL
540Sstevel@tonic-gate extern pgcnt_t	freemem;	/* remaining blocks of free memory */
550Sstevel@tonic-gate extern pgcnt_t	avefree;	/* 5 sec moving average of free memory */
560Sstevel@tonic-gate extern pgcnt_t	avefree30;	/* 30 sec moving average of free memory */
570Sstevel@tonic-gate extern pgcnt_t	deficit;	/* estimate of needs of new swapped in procs */
580Sstevel@tonic-gate extern pgcnt_t	nscan;		/* number of scans in last second */
590Sstevel@tonic-gate extern pgcnt_t	desscan;	/* desired pages scanned per second */
600Sstevel@tonic-gate extern pgcnt_t	slowscan;
610Sstevel@tonic-gate extern pgcnt_t	fastscan;
620Sstevel@tonic-gate extern pgcnt_t	pushes;		/* number of pages pushed to swap device */
630Sstevel@tonic-gate 
640Sstevel@tonic-gate /* writable copies of tunables */
650Sstevel@tonic-gate extern pgcnt_t	maxpgio;	/* max paging i/o per sec before start swaps */
660Sstevel@tonic-gate extern pgcnt_t	lotsfree;	/* max free before clock freezes */
670Sstevel@tonic-gate extern pgcnt_t	desfree;	/* minimum free pages before swapping begins */
680Sstevel@tonic-gate extern pgcnt_t	minfree;	/* no of pages to try to keep free via daemon */
690Sstevel@tonic-gate extern pgcnt_t	needfree;	/* no of pages currently being waited for */
700Sstevel@tonic-gate extern pgcnt_t	throttlefree;	/* point at which we block PG_WAIT calls */
710Sstevel@tonic-gate extern pgcnt_t	pageout_reserve; /* point at which we deny non-PG_WAIT calls */
720Sstevel@tonic-gate extern pgcnt_t	pages_before_pager; /* XXX */
730Sstevel@tonic-gate 
740Sstevel@tonic-gate /*
750Sstevel@tonic-gate  * TRUE if the pageout daemon, fsflush daemon or the scheduler.  These
760Sstevel@tonic-gate  * processes can't sleep while trying to free up memory since a deadlock
770Sstevel@tonic-gate  * will occur if they do sleep.
780Sstevel@tonic-gate  */
790Sstevel@tonic-gate #define	NOMEMWAIT() (ttoproc(curthread) == proc_pageout || \
800Sstevel@tonic-gate 			ttoproc(curthread) == proc_fsflush || \
810Sstevel@tonic-gate 			ttoproc(curthread) == proc_sched)
820Sstevel@tonic-gate 
830Sstevel@tonic-gate /* insure non-zero */
840Sstevel@tonic-gate #define	nz(x)	((x) != 0 ? (x) : 1)
850Sstevel@tonic-gate 
860Sstevel@tonic-gate /*
870Sstevel@tonic-gate  * Flags passed by the swapper to swapout routines of each
880Sstevel@tonic-gate  * scheduling class.
890Sstevel@tonic-gate  */
900Sstevel@tonic-gate #define	HARDSWAP	1
910Sstevel@tonic-gate #define	SOFTSWAP	2
920Sstevel@tonic-gate 
930Sstevel@tonic-gate /*
940Sstevel@tonic-gate  * Values returned by valid_usr_range()
950Sstevel@tonic-gate  */
960Sstevel@tonic-gate #define	RANGE_OKAY	(0)
970Sstevel@tonic-gate #define	RANGE_BADADDR	(1)
980Sstevel@tonic-gate #define	RANGE_BADPROT	(2)
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate /*
1010Sstevel@tonic-gate  * map_pgsz: temporary - subject to change.
1020Sstevel@tonic-gate  */
1030Sstevel@tonic-gate #define	MAPPGSZ_VA	0x01
1040Sstevel@tonic-gate #define	MAPPGSZ_STK	0x02
1050Sstevel@tonic-gate #define	MAPPGSZ_HEAP	0x04
1060Sstevel@tonic-gate #define	MAPPGSZ_ISM	0x08
1070Sstevel@tonic-gate 
1082991Ssusans /*
1092991Ssusans  * Flags for map_pgszcvec
1102991Ssusans  */
1112991Ssusans #define	MAPPGSZC_SHM	0x01
1122991Ssusans #define	MAPPGSZC_PRIVM	0x02
1132991Ssusans #define	MAPPGSZC_STACK	0x04
1142991Ssusans #define	MAPPGSZC_HEAP	0x08
1152991Ssusans 
1160Sstevel@tonic-gate struct as;
1170Sstevel@tonic-gate struct page;
1180Sstevel@tonic-gate struct anon;
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate extern int maxslp;
1210Sstevel@tonic-gate extern ulong_t pginrate;
1220Sstevel@tonic-gate extern ulong_t pgoutrate;
1230Sstevel@tonic-gate extern void swapout_lwp(klwp_t *);
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate extern	int valid_va_range(caddr_t *basep, size_t *lenp, size_t minlen,
1260Sstevel@tonic-gate 		int dir);
127*5668Smec extern	int valid_va_range_aligned(caddr_t *basep, size_t *lenp,
128*5668Smec     size_t minlen, int dir, size_t align, size_t redzone, size_t off);
129*5668Smec 
1300Sstevel@tonic-gate extern	int valid_usr_range(caddr_t, size_t, uint_t, struct as *, caddr_t);
1310Sstevel@tonic-gate extern	int useracc(void *, size_t, int);
1322991Ssusans extern	size_t map_pgsz(int maptype, struct proc *p, caddr_t addr, size_t len,
1332991Ssusans     int memcntl);
1342991Ssusans extern	uint_t map_pgszcvec(caddr_t addr, size_t size, uintptr_t off, int flags,
1352991Ssusans     int type, int memcntl);
1360Sstevel@tonic-gate extern	void map_addr(caddr_t *addrp, size_t len, offset_t off, int vacalign,
1370Sstevel@tonic-gate     uint_t flags);
1380Sstevel@tonic-gate extern	int map_addr_vacalign_check(caddr_t, u_offset_t);
1390Sstevel@tonic-gate extern	void map_addr_proc(caddr_t *addrp, size_t len, offset_t off,
1400Sstevel@tonic-gate     int vacalign, caddr_t userlimit, struct proc *p, uint_t flags);
1410Sstevel@tonic-gate extern	void vmmeter(void);
1420Sstevel@tonic-gate extern	int cow_mapin(struct as *, caddr_t, caddr_t, struct page **,
1430Sstevel@tonic-gate 	struct anon **, size_t *, int);
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate extern	caddr_t	ppmapin(struct page *, uint_t, caddr_t);
1460Sstevel@tonic-gate extern	void	ppmapout(caddr_t);
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate extern	int pf_is_memory(pfn_t);
1490Sstevel@tonic-gate extern	void	pageout_init(void (*proc)(), proc_t *pp, pri_t pri);
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate extern	void	dcache_flushall(void);
1520Sstevel@tonic-gate 
1530Sstevel@tonic-gate extern	void	*boot_virt_alloc(void *addr, size_t size);
1540Sstevel@tonic-gate 
1553177Sdp78419 extern	size_t	exec_get_spslew(void);
1563177Sdp78419 
1570Sstevel@tonic-gate #endif	/* _KERNEL */
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate #ifdef	__cplusplus
1600Sstevel@tonic-gate }
1610Sstevel@tonic-gate #endif
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate #endif	/* _SYS_VMSYSTM_H */
164