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 /* 2235a5a358SJonathan 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 */ 27b4203d75SMarcel Telka /* 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 */ 61*338664dfSAndy Fiddaman extern uint64_t low_mem_scan; /* num times page scan due to low memory */ 62*338664dfSAndy Fiddaman extern volatile uint64_t n_throttle; /* num times page create throttled */ 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 /* 75f6ef4223SJoshua M. Clulow * TRUE if the pageout daemon, fsflush daemon, or the scheduler. These threads 76f6ef4223SJoshua M. Clulow * can't sleep while trying to free up memory since a deadlock will occur if 77f6ef4223SJoshua M. Clulow * they do sleep. 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate #define NOMEMWAIT() (ttoproc(curthread) == proc_pageout || \ 807c478bd9Sstevel@tonic-gate ttoproc(curthread) == proc_fsflush || \ 81f6ef4223SJoshua M. Clulow ttoproc(curthread) == proc_sched || \ 82f6ef4223SJoshua M. Clulow (curthread->t_flag & T_PUSHPAGE) != 0) 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* insure non-zero */ 857c478bd9Sstevel@tonic-gate #define nz(x) ((x) != 0 ? (x) : 1) 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* 887c478bd9Sstevel@tonic-gate * Flags passed by the swapper to swapout routines of each 897c478bd9Sstevel@tonic-gate * scheduling class. 907c478bd9Sstevel@tonic-gate */ 917c478bd9Sstevel@tonic-gate #define HARDSWAP 1 927c478bd9Sstevel@tonic-gate #define SOFTSWAP 2 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* 957c478bd9Sstevel@tonic-gate * Values returned by valid_usr_range() 967c478bd9Sstevel@tonic-gate */ 977c478bd9Sstevel@tonic-gate #define RANGE_OKAY (0) 987c478bd9Sstevel@tonic-gate #define RANGE_BADADDR (1) 997c478bd9Sstevel@tonic-gate #define RANGE_BADPROT (2) 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* 1027c478bd9Sstevel@tonic-gate * map_pgsz: temporary - subject to change. 1037c478bd9Sstevel@tonic-gate */ 1047c478bd9Sstevel@tonic-gate #define MAPPGSZ_VA 0x01 1057c478bd9Sstevel@tonic-gate #define MAPPGSZ_STK 0x02 1067c478bd9Sstevel@tonic-gate #define MAPPGSZ_HEAP 0x04 1077c478bd9Sstevel@tonic-gate #define MAPPGSZ_ISM 0x08 1087c478bd9Sstevel@tonic-gate 109ec25b48fSsusans /* 110ec25b48fSsusans * Flags for map_pgszcvec 111ec25b48fSsusans */ 112ec25b48fSsusans #define MAPPGSZC_SHM 0x01 113ec25b48fSsusans #define MAPPGSZC_PRIVM 0x02 114ec25b48fSsusans #define MAPPGSZC_STACK 0x04 115ec25b48fSsusans #define MAPPGSZC_HEAP 0x08 116ec25b48fSsusans 11760946fe0Smec /* 11860946fe0Smec * vacalign values for choose_addr 11960946fe0Smec */ 12060946fe0Smec #define ADDR_NOVACALIGN 0 12160946fe0Smec #define ADDR_VACALIGN 1 12260946fe0Smec 1237c478bd9Sstevel@tonic-gate struct as; 1247c478bd9Sstevel@tonic-gate struct page; 1257c478bd9Sstevel@tonic-gate struct anon; 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate extern int maxslp; 1287c478bd9Sstevel@tonic-gate extern ulong_t pginrate; 1297c478bd9Sstevel@tonic-gate extern ulong_t pgoutrate; 1307c478bd9Sstevel@tonic-gate extern void swapout_lwp(klwp_t *); 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate extern int valid_va_range(caddr_t *basep, size_t *lenp, size_t minlen, 1337c478bd9Sstevel@tonic-gate int dir); 13446ab9534Smec extern int valid_va_range_aligned(caddr_t *basep, size_t *lenp, 13546ab9534Smec size_t minlen, int dir, size_t align, size_t redzone, size_t off); 13646ab9534Smec 1377c478bd9Sstevel@tonic-gate extern int valid_usr_range(caddr_t, size_t, uint_t, struct as *, caddr_t); 1387c478bd9Sstevel@tonic-gate extern int useracc(void *, size_t, int); 139ec25b48fSsusans extern size_t map_pgsz(int maptype, struct proc *p, caddr_t addr, size_t len, 140ec25b48fSsusans int memcntl); 141ec25b48fSsusans extern uint_t map_pgszcvec(caddr_t addr, size_t size, uintptr_t off, int flags, 142ec25b48fSsusans int type, int memcntl); 14360946fe0Smec extern int choose_addr(struct as *as, caddr_t *addrp, size_t len, offset_t off, 14460946fe0Smec int vacalign, uint_t flags); 1457c478bd9Sstevel@tonic-gate extern void map_addr(caddr_t *addrp, size_t len, offset_t off, int vacalign, 1467c478bd9Sstevel@tonic-gate uint_t flags); 1477c478bd9Sstevel@tonic-gate extern int map_addr_vacalign_check(caddr_t, u_offset_t); 1487c478bd9Sstevel@tonic-gate extern void map_addr_proc(caddr_t *addrp, size_t len, offset_t off, 1497c478bd9Sstevel@tonic-gate int vacalign, caddr_t userlimit, struct proc *p, uint_t flags); 1507c478bd9Sstevel@tonic-gate extern void vmmeter(void); 1517c478bd9Sstevel@tonic-gate extern int cow_mapin(struct as *, caddr_t, caddr_t, struct page **, 1527c478bd9Sstevel@tonic-gate struct anon **, size_t *, int); 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate extern caddr_t ppmapin(struct page *, uint_t, caddr_t); 1557c478bd9Sstevel@tonic-gate extern void ppmapout(caddr_t); 1567c478bd9Sstevel@tonic-gate 1577c478bd9Sstevel@tonic-gate extern int pf_is_memory(pfn_t); 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 163102033aaSdp extern size_t exec_get_spslew(void); 164102033aaSdp 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