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*35a5a358SJonathan Adams * Copyright 2009 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 #include <sys/proc.h> 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #ifdef __cplusplus 457c478bd9Sstevel@tonic-gate extern "C" { 467c478bd9Sstevel@tonic-gate #endif 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* 497c478bd9Sstevel@tonic-gate * Miscellaneous virtual memory subsystem variables and structures. 507c478bd9Sstevel@tonic-gate */ 517c478bd9Sstevel@tonic-gate #ifdef _KERNEL 527c478bd9Sstevel@tonic-gate extern pgcnt_t freemem; /* remaining blocks of free memory */ 537c478bd9Sstevel@tonic-gate extern pgcnt_t avefree; /* 5 sec moving average of free memory */ 547c478bd9Sstevel@tonic-gate extern pgcnt_t avefree30; /* 30 sec moving average of free memory */ 557c478bd9Sstevel@tonic-gate extern pgcnt_t deficit; /* estimate of needs of new swapped in procs */ 567c478bd9Sstevel@tonic-gate extern pgcnt_t nscan; /* number of scans in last second */ 577c478bd9Sstevel@tonic-gate extern pgcnt_t desscan; /* desired pages scanned per second */ 587c478bd9Sstevel@tonic-gate extern pgcnt_t slowscan; 597c478bd9Sstevel@tonic-gate extern pgcnt_t fastscan; 607c478bd9Sstevel@tonic-gate extern pgcnt_t pushes; /* number of pages pushed to swap device */ 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate /* writable copies of tunables */ 637c478bd9Sstevel@tonic-gate extern pgcnt_t maxpgio; /* max paging i/o per sec before start swaps */ 647c478bd9Sstevel@tonic-gate extern pgcnt_t lotsfree; /* max free before clock freezes */ 657c478bd9Sstevel@tonic-gate extern pgcnt_t desfree; /* minimum free pages before swapping begins */ 667c478bd9Sstevel@tonic-gate extern pgcnt_t minfree; /* no of pages to try to keep free via daemon */ 677c478bd9Sstevel@tonic-gate extern pgcnt_t needfree; /* no of pages currently being waited for */ 687c478bd9Sstevel@tonic-gate extern pgcnt_t throttlefree; /* point at which we block PG_WAIT calls */ 697c478bd9Sstevel@tonic-gate extern pgcnt_t pageout_reserve; /* point at which we deny non-PG_WAIT calls */ 707c478bd9Sstevel@tonic-gate extern pgcnt_t pages_before_pager; /* XXX */ 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * TRUE if the pageout daemon, fsflush daemon or the scheduler. These 747c478bd9Sstevel@tonic-gate * processes can't sleep while trying to free up memory since a deadlock 757c478bd9Sstevel@tonic-gate * will occur if they do sleep. 767c478bd9Sstevel@tonic-gate */ 777c478bd9Sstevel@tonic-gate #define NOMEMWAIT() (ttoproc(curthread) == proc_pageout || \ 787c478bd9Sstevel@tonic-gate ttoproc(curthread) == proc_fsflush || \ 797c478bd9Sstevel@tonic-gate ttoproc(curthread) == proc_sched) 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate /* insure non-zero */ 827c478bd9Sstevel@tonic-gate #define nz(x) ((x) != 0 ? (x) : 1) 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* 857c478bd9Sstevel@tonic-gate * Flags passed by the swapper to swapout routines of each 867c478bd9Sstevel@tonic-gate * scheduling class. 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate #define HARDSWAP 1 897c478bd9Sstevel@tonic-gate #define SOFTSWAP 2 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * Values returned by valid_usr_range() 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate #define RANGE_OKAY (0) 957c478bd9Sstevel@tonic-gate #define RANGE_BADADDR (1) 967c478bd9Sstevel@tonic-gate #define RANGE_BADPROT (2) 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate /* 997c478bd9Sstevel@tonic-gate * map_pgsz: temporary - subject to change. 1007c478bd9Sstevel@tonic-gate */ 1017c478bd9Sstevel@tonic-gate #define MAPPGSZ_VA 0x01 1027c478bd9Sstevel@tonic-gate #define MAPPGSZ_STK 0x02 1037c478bd9Sstevel@tonic-gate #define MAPPGSZ_HEAP 0x04 1047c478bd9Sstevel@tonic-gate #define MAPPGSZ_ISM 0x08 1057c478bd9Sstevel@tonic-gate 106ec25b48fSsusans /* 107ec25b48fSsusans * Flags for map_pgszcvec 108ec25b48fSsusans */ 109ec25b48fSsusans #define MAPPGSZC_SHM 0x01 110ec25b48fSsusans #define MAPPGSZC_PRIVM 0x02 111ec25b48fSsusans #define MAPPGSZC_STACK 0x04 112ec25b48fSsusans #define MAPPGSZC_HEAP 0x08 113ec25b48fSsusans 11460946fe0Smec /* 11560946fe0Smec * vacalign values for choose_addr 11660946fe0Smec */ 11760946fe0Smec #define ADDR_NOVACALIGN 0 11860946fe0Smec #define ADDR_VACALIGN 1 11960946fe0Smec 1207c478bd9Sstevel@tonic-gate struct as; 1217c478bd9Sstevel@tonic-gate struct page; 1227c478bd9Sstevel@tonic-gate struct anon; 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate extern int maxslp; 1257c478bd9Sstevel@tonic-gate extern ulong_t pginrate; 1267c478bd9Sstevel@tonic-gate extern ulong_t pgoutrate; 1277c478bd9Sstevel@tonic-gate extern void swapout_lwp(klwp_t *); 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate extern int valid_va_range(caddr_t *basep, size_t *lenp, size_t minlen, 1307c478bd9Sstevel@tonic-gate int dir); 13146ab9534Smec extern int valid_va_range_aligned(caddr_t *basep, size_t *lenp, 13246ab9534Smec size_t minlen, int dir, size_t align, size_t redzone, size_t off); 13346ab9534Smec 1347c478bd9Sstevel@tonic-gate extern int valid_usr_range(caddr_t, size_t, uint_t, struct as *, caddr_t); 1357c478bd9Sstevel@tonic-gate extern int useracc(void *, size_t, int); 136ec25b48fSsusans extern size_t map_pgsz(int maptype, struct proc *p, caddr_t addr, size_t len, 137ec25b48fSsusans int memcntl); 138ec25b48fSsusans extern uint_t map_pgszcvec(caddr_t addr, size_t size, uintptr_t off, int flags, 139ec25b48fSsusans int type, int memcntl); 14060946fe0Smec extern int choose_addr(struct as *as, caddr_t *addrp, size_t len, offset_t off, 14160946fe0Smec int vacalign, uint_t flags); 1427c478bd9Sstevel@tonic-gate extern void map_addr(caddr_t *addrp, size_t len, offset_t off, int vacalign, 1437c478bd9Sstevel@tonic-gate uint_t flags); 1447c478bd9Sstevel@tonic-gate extern int map_addr_vacalign_check(caddr_t, u_offset_t); 1457c478bd9Sstevel@tonic-gate extern void map_addr_proc(caddr_t *addrp, size_t len, offset_t off, 1467c478bd9Sstevel@tonic-gate int vacalign, caddr_t userlimit, struct proc *p, uint_t flags); 1477c478bd9Sstevel@tonic-gate extern void vmmeter(void); 1487c478bd9Sstevel@tonic-gate extern int cow_mapin(struct as *, caddr_t, caddr_t, struct page **, 1497c478bd9Sstevel@tonic-gate struct anon **, size_t *, int); 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate extern caddr_t ppmapin(struct page *, uint_t, caddr_t); 1527c478bd9Sstevel@tonic-gate extern void ppmapout(caddr_t); 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate extern int pf_is_memory(pfn_t); 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate extern void dcache_flushall(void); 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate extern void *boot_virt_alloc(void *addr, size_t size); 1597c478bd9Sstevel@tonic-gate 160102033aaSdp78419 extern size_t exec_get_spslew(void); 161102033aaSdp78419 1627c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1657c478bd9Sstevel@tonic-gate } 1667c478bd9Sstevel@tonic-gate #endif 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate #endif /* _SYS_VMSYSTM_H */ 169