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*11173SJonathan.Adams@Sun.COM * Copyright 2009 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 #include <sys/proc.h> 430Sstevel@tonic-gate 440Sstevel@tonic-gate #ifdef __cplusplus 450Sstevel@tonic-gate extern "C" { 460Sstevel@tonic-gate #endif 470Sstevel@tonic-gate 480Sstevel@tonic-gate /* 490Sstevel@tonic-gate * Miscellaneous virtual memory subsystem variables and structures. 500Sstevel@tonic-gate */ 510Sstevel@tonic-gate #ifdef _KERNEL 520Sstevel@tonic-gate extern pgcnt_t freemem; /* remaining blocks of free memory */ 530Sstevel@tonic-gate extern pgcnt_t avefree; /* 5 sec moving average of free memory */ 540Sstevel@tonic-gate extern pgcnt_t avefree30; /* 30 sec moving average of free memory */ 550Sstevel@tonic-gate extern pgcnt_t deficit; /* estimate of needs of new swapped in procs */ 560Sstevel@tonic-gate extern pgcnt_t nscan; /* number of scans in last second */ 570Sstevel@tonic-gate extern pgcnt_t desscan; /* desired pages scanned per second */ 580Sstevel@tonic-gate extern pgcnt_t slowscan; 590Sstevel@tonic-gate extern pgcnt_t fastscan; 600Sstevel@tonic-gate extern pgcnt_t pushes; /* number of pages pushed to swap device */ 610Sstevel@tonic-gate 620Sstevel@tonic-gate /* writable copies of tunables */ 630Sstevel@tonic-gate extern pgcnt_t maxpgio; /* max paging i/o per sec before start swaps */ 640Sstevel@tonic-gate extern pgcnt_t lotsfree; /* max free before clock freezes */ 650Sstevel@tonic-gate extern pgcnt_t desfree; /* minimum free pages before swapping begins */ 660Sstevel@tonic-gate extern pgcnt_t minfree; /* no of pages to try to keep free via daemon */ 670Sstevel@tonic-gate extern pgcnt_t needfree; /* no of pages currently being waited for */ 680Sstevel@tonic-gate extern pgcnt_t throttlefree; /* point at which we block PG_WAIT calls */ 690Sstevel@tonic-gate extern pgcnt_t pageout_reserve; /* point at which we deny non-PG_WAIT calls */ 700Sstevel@tonic-gate extern pgcnt_t pages_before_pager; /* XXX */ 710Sstevel@tonic-gate 720Sstevel@tonic-gate /* 730Sstevel@tonic-gate * TRUE if the pageout daemon, fsflush daemon or the scheduler. These 740Sstevel@tonic-gate * processes can't sleep while trying to free up memory since a deadlock 750Sstevel@tonic-gate * will occur if they do sleep. 760Sstevel@tonic-gate */ 770Sstevel@tonic-gate #define NOMEMWAIT() (ttoproc(curthread) == proc_pageout || \ 780Sstevel@tonic-gate ttoproc(curthread) == proc_fsflush || \ 790Sstevel@tonic-gate ttoproc(curthread) == proc_sched) 800Sstevel@tonic-gate 810Sstevel@tonic-gate /* insure non-zero */ 820Sstevel@tonic-gate #define nz(x) ((x) != 0 ? (x) : 1) 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* 850Sstevel@tonic-gate * Flags passed by the swapper to swapout routines of each 860Sstevel@tonic-gate * scheduling class. 870Sstevel@tonic-gate */ 880Sstevel@tonic-gate #define HARDSWAP 1 890Sstevel@tonic-gate #define SOFTSWAP 2 900Sstevel@tonic-gate 910Sstevel@tonic-gate /* 920Sstevel@tonic-gate * Values returned by valid_usr_range() 930Sstevel@tonic-gate */ 940Sstevel@tonic-gate #define RANGE_OKAY (0) 950Sstevel@tonic-gate #define RANGE_BADADDR (1) 960Sstevel@tonic-gate #define RANGE_BADPROT (2) 970Sstevel@tonic-gate 980Sstevel@tonic-gate /* 990Sstevel@tonic-gate * map_pgsz: temporary - subject to change. 1000Sstevel@tonic-gate */ 1010Sstevel@tonic-gate #define MAPPGSZ_VA 0x01 1020Sstevel@tonic-gate #define MAPPGSZ_STK 0x02 1030Sstevel@tonic-gate #define MAPPGSZ_HEAP 0x04 1040Sstevel@tonic-gate #define MAPPGSZ_ISM 0x08 1050Sstevel@tonic-gate 1062991Ssusans /* 1072991Ssusans * Flags for map_pgszcvec 1082991Ssusans */ 1092991Ssusans #define MAPPGSZC_SHM 0x01 1102991Ssusans #define MAPPGSZC_PRIVM 0x02 1112991Ssusans #define MAPPGSZC_STACK 0x04 1122991Ssusans #define MAPPGSZC_HEAP 0x08 1132991Ssusans 1146036Smec /* 1156036Smec * vacalign values for choose_addr 1166036Smec */ 1176036Smec #define ADDR_NOVACALIGN 0 1186036Smec #define ADDR_VACALIGN 1 1196036Smec 1200Sstevel@tonic-gate struct as; 1210Sstevel@tonic-gate struct page; 1220Sstevel@tonic-gate struct anon; 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate extern int maxslp; 1250Sstevel@tonic-gate extern ulong_t pginrate; 1260Sstevel@tonic-gate extern ulong_t pgoutrate; 1270Sstevel@tonic-gate extern void swapout_lwp(klwp_t *); 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate extern int valid_va_range(caddr_t *basep, size_t *lenp, size_t minlen, 1300Sstevel@tonic-gate int dir); 1315668Smec extern int valid_va_range_aligned(caddr_t *basep, size_t *lenp, 1325668Smec size_t minlen, int dir, size_t align, size_t redzone, size_t off); 1335668Smec 1340Sstevel@tonic-gate extern int valid_usr_range(caddr_t, size_t, uint_t, struct as *, caddr_t); 1350Sstevel@tonic-gate extern int useracc(void *, size_t, int); 1362991Ssusans extern size_t map_pgsz(int maptype, struct proc *p, caddr_t addr, size_t len, 1372991Ssusans int memcntl); 1382991Ssusans extern uint_t map_pgszcvec(caddr_t addr, size_t size, uintptr_t off, int flags, 1392991Ssusans int type, int memcntl); 1406036Smec extern int choose_addr(struct as *as, caddr_t *addrp, size_t len, offset_t off, 1416036Smec int vacalign, uint_t flags); 1420Sstevel@tonic-gate extern void map_addr(caddr_t *addrp, size_t len, offset_t off, int vacalign, 1430Sstevel@tonic-gate uint_t flags); 1440Sstevel@tonic-gate extern int map_addr_vacalign_check(caddr_t, u_offset_t); 1450Sstevel@tonic-gate extern void map_addr_proc(caddr_t *addrp, size_t len, offset_t off, 1460Sstevel@tonic-gate int vacalign, caddr_t userlimit, struct proc *p, uint_t flags); 1470Sstevel@tonic-gate extern void vmmeter(void); 1480Sstevel@tonic-gate extern int cow_mapin(struct as *, caddr_t, caddr_t, struct page **, 1490Sstevel@tonic-gate struct anon **, size_t *, int); 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate extern caddr_t ppmapin(struct page *, uint_t, caddr_t); 1520Sstevel@tonic-gate extern void ppmapout(caddr_t); 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate extern int pf_is_memory(pfn_t); 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate extern void dcache_flushall(void); 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate extern void *boot_virt_alloc(void *addr, size_t size); 1590Sstevel@tonic-gate 1603177Sdp78419 extern size_t exec_get_spslew(void); 1613177Sdp78419 1620Sstevel@tonic-gate #endif /* _KERNEL */ 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate #ifdef __cplusplus 1650Sstevel@tonic-gate } 1660Sstevel@tonic-gate #endif 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate #endif /* _SYS_VMSYSTM_H */ 169