17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 507b65a64Saguzovsk * Common Development and Distribution License (the "License"). 607b65a64Saguzovsk * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*60946fe0Smec * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 317c478bd9Sstevel@tonic-gate * The Regents of the University of California 327c478bd9Sstevel@tonic-gate * All Rights Reserved 337c478bd9Sstevel@tonic-gate * 347c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 357c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 367c478bd9Sstevel@tonic-gate * contributors. 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifndef _SYS_VMSYSTM_H 407c478bd9Sstevel@tonic-gate #define _SYS_VMSYSTM_H 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #include <sys/proc.h> 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #ifdef __cplusplus 477c478bd9Sstevel@tonic-gate extern "C" { 487c478bd9Sstevel@tonic-gate #endif 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* 517c478bd9Sstevel@tonic-gate * Miscellaneous virtual memory subsystem variables and structures. 527c478bd9Sstevel@tonic-gate */ 537c478bd9Sstevel@tonic-gate #ifdef _KERNEL 547c478bd9Sstevel@tonic-gate extern pgcnt_t freemem; /* remaining blocks of free memory */ 557c478bd9Sstevel@tonic-gate extern pgcnt_t avefree; /* 5 sec moving average of free memory */ 567c478bd9Sstevel@tonic-gate extern pgcnt_t avefree30; /* 30 sec moving average of free memory */ 577c478bd9Sstevel@tonic-gate extern pgcnt_t deficit; /* estimate of needs of new swapped in procs */ 587c478bd9Sstevel@tonic-gate extern pgcnt_t nscan; /* number of scans in last second */ 597c478bd9Sstevel@tonic-gate extern pgcnt_t desscan; /* desired pages scanned per second */ 607c478bd9Sstevel@tonic-gate extern pgcnt_t slowscan; 617c478bd9Sstevel@tonic-gate extern pgcnt_t fastscan; 627c478bd9Sstevel@tonic-gate extern pgcnt_t pushes; /* number of pages pushed to swap device */ 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* writable copies of tunables */ 657c478bd9Sstevel@tonic-gate extern pgcnt_t maxpgio; /* max paging i/o per sec before start swaps */ 667c478bd9Sstevel@tonic-gate extern pgcnt_t lotsfree; /* max free before clock freezes */ 677c478bd9Sstevel@tonic-gate extern pgcnt_t desfree; /* minimum free pages before swapping begins */ 687c478bd9Sstevel@tonic-gate extern pgcnt_t minfree; /* no of pages to try to keep free via daemon */ 697c478bd9Sstevel@tonic-gate extern pgcnt_t needfree; /* no of pages currently being waited for */ 707c478bd9Sstevel@tonic-gate extern pgcnt_t throttlefree; /* point at which we block PG_WAIT calls */ 717c478bd9Sstevel@tonic-gate extern pgcnt_t pageout_reserve; /* point at which we deny non-PG_WAIT calls */ 727c478bd9Sstevel@tonic-gate extern pgcnt_t pages_before_pager; /* XXX */ 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate /* 757c478bd9Sstevel@tonic-gate * TRUE if the pageout daemon, fsflush daemon or the scheduler. These 767c478bd9Sstevel@tonic-gate * processes can't sleep while trying to free up memory since a deadlock 777c478bd9Sstevel@tonic-gate * will occur if they do sleep. 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate #define NOMEMWAIT() (ttoproc(curthread) == proc_pageout || \ 807c478bd9Sstevel@tonic-gate ttoproc(curthread) == proc_fsflush || \ 817c478bd9Sstevel@tonic-gate ttoproc(curthread) == proc_sched) 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* insure non-zero */ 847c478bd9Sstevel@tonic-gate #define nz(x) ((x) != 0 ? (x) : 1) 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate /* 877c478bd9Sstevel@tonic-gate * Flags passed by the swapper to swapout routines of each 887c478bd9Sstevel@tonic-gate * scheduling class. 897c478bd9Sstevel@tonic-gate */ 907c478bd9Sstevel@tonic-gate #define HARDSWAP 1 917c478bd9Sstevel@tonic-gate #define SOFTSWAP 2 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * Values returned by valid_usr_range() 957c478bd9Sstevel@tonic-gate */ 967c478bd9Sstevel@tonic-gate #define RANGE_OKAY (0) 977c478bd9Sstevel@tonic-gate #define RANGE_BADADDR (1) 987c478bd9Sstevel@tonic-gate #define RANGE_BADPROT (2) 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* 1017c478bd9Sstevel@tonic-gate * map_pgsz: temporary - subject to change. 1027c478bd9Sstevel@tonic-gate */ 1037c478bd9Sstevel@tonic-gate #define MAPPGSZ_VA 0x01 1047c478bd9Sstevel@tonic-gate #define MAPPGSZ_STK 0x02 1057c478bd9Sstevel@tonic-gate #define MAPPGSZ_HEAP 0x04 1067c478bd9Sstevel@tonic-gate #define MAPPGSZ_ISM 0x08 1077c478bd9Sstevel@tonic-gate 108ec25b48fSsusans /* 109ec25b48fSsusans * Flags for map_pgszcvec 110ec25b48fSsusans */ 111ec25b48fSsusans #define MAPPGSZC_SHM 0x01 112ec25b48fSsusans #define MAPPGSZC_PRIVM 0x02 113ec25b48fSsusans #define MAPPGSZC_STACK 0x04 114ec25b48fSsusans #define MAPPGSZC_HEAP 0x08 115ec25b48fSsusans 116*60946fe0Smec /* 117*60946fe0Smec * vacalign values for choose_addr 118*60946fe0Smec */ 119*60946fe0Smec #define ADDR_NOVACALIGN 0 120*60946fe0Smec #define ADDR_VACALIGN 1 121*60946fe0Smec 1227c478bd9Sstevel@tonic-gate struct as; 1237c478bd9Sstevel@tonic-gate struct page; 1247c478bd9Sstevel@tonic-gate struct anon; 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate extern int maxslp; 1277c478bd9Sstevel@tonic-gate extern ulong_t pginrate; 1287c478bd9Sstevel@tonic-gate extern ulong_t pgoutrate; 1297c478bd9Sstevel@tonic-gate extern void swapout_lwp(klwp_t *); 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate extern int valid_va_range(caddr_t *basep, size_t *lenp, size_t minlen, 1327c478bd9Sstevel@tonic-gate int dir); 13346ab9534Smec extern int valid_va_range_aligned(caddr_t *basep, size_t *lenp, 13446ab9534Smec size_t minlen, int dir, size_t align, size_t redzone, size_t off); 13546ab9534Smec 1367c478bd9Sstevel@tonic-gate extern int valid_usr_range(caddr_t, size_t, uint_t, struct as *, caddr_t); 1377c478bd9Sstevel@tonic-gate extern int useracc(void *, size_t, int); 138ec25b48fSsusans extern size_t map_pgsz(int maptype, struct proc *p, caddr_t addr, size_t len, 139ec25b48fSsusans int memcntl); 140ec25b48fSsusans extern uint_t map_pgszcvec(caddr_t addr, size_t size, uintptr_t off, int flags, 141ec25b48fSsusans int type, int memcntl); 142*60946fe0Smec extern int choose_addr(struct as *as, caddr_t *addrp, size_t len, offset_t off, 143*60946fe0Smec int vacalign, uint_t flags); 1447c478bd9Sstevel@tonic-gate extern void map_addr(caddr_t *addrp, size_t len, offset_t off, int vacalign, 1457c478bd9Sstevel@tonic-gate uint_t flags); 1467c478bd9Sstevel@tonic-gate extern int map_addr_vacalign_check(caddr_t, u_offset_t); 1477c478bd9Sstevel@tonic-gate extern void map_addr_proc(caddr_t *addrp, size_t len, offset_t off, 1487c478bd9Sstevel@tonic-gate int vacalign, caddr_t userlimit, struct proc *p, uint_t flags); 1497c478bd9Sstevel@tonic-gate extern void vmmeter(void); 1507c478bd9Sstevel@tonic-gate extern int cow_mapin(struct as *, caddr_t, caddr_t, struct page **, 1517c478bd9Sstevel@tonic-gate struct anon **, size_t *, int); 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate extern caddr_t ppmapin(struct page *, uint_t, caddr_t); 1547c478bd9Sstevel@tonic-gate extern void ppmapout(caddr_t); 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate extern int pf_is_memory(pfn_t); 1577c478bd9Sstevel@tonic-gate extern void pageout_init(void (*proc)(), proc_t *pp, pri_t pri); 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate extern void dcache_flushall(void); 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate extern void *boot_virt_alloc(void *addr, size_t size); 1627c478bd9Sstevel@tonic-gate 163102033aaSdp78419 extern size_t exec_get_spslew(void); 164102033aaSdp78419 1657c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1687c478bd9Sstevel@tonic-gate } 1697c478bd9Sstevel@tonic-gate #endif 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate #endif /* _SYS_VMSYSTM_H */ 172