swap_pager.h revision 108599
11541Srgrimes/* 21541Srgrimes * Copyright (c) 1990 University of Utah. 31549Srgrimes * Copyright (c) 1991 The Regents of the University of California. 41549Srgrimes * All rights reserved. 51541Srgrimes * 61541Srgrimes * This code is derived from software contributed to Berkeley by 71541Srgrimes * the Systems Programming Group of the University of Utah Computer 81541Srgrimes * Science Department. 91541Srgrimes * 101541Srgrimes * Redistribution and use in source and binary forms, with or without 111541Srgrimes * modification, are permitted provided that the following conditions 121541Srgrimes * are met: 131541Srgrimes * 1. Redistributions of source code must retain the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer. 151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161541Srgrimes * notice, this list of conditions and the following disclaimer in the 171541Srgrimes * documentation and/or other materials provided with the distribution. 181541Srgrimes * 3. All advertising materials mentioning features or use of this software 191541Srgrimes * must display the following acknowledgement: 201541Srgrimes * This product includes software developed by the University of 211541Srgrimes * California, Berkeley and its contributors. 221541Srgrimes * 4. Neither the name of the University nor the names of its contributors 231541Srgrimes * may be used to endorse or promote products derived from this software 241541Srgrimes * without specific prior written permission. 251541Srgrimes * 261541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 271541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 281541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 291541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 301541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 311541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 321541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 331541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 341541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 351541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 361541Srgrimes * SUCH DAMAGE. 371541Srgrimes * 381549Srgrimes * from: @(#)swap_pager.h 7.1 (Berkeley) 12/5/90 3950477Speter * $FreeBSD: head/sys/vm/swap_pager.h 108599 2003-01-03 14:22:52Z phk $ 401541Srgrimes */ 411541Srgrimes 421549Srgrimes/* 431549Srgrimes * Modifications to the block allocation data structure by John S. Dyson 441549Srgrimes * 18 Dec 93. 451549Srgrimes */ 461549Srgrimes 47108599Sphk#ifndef _VM_SWAP_PAGER_H_ 48108599Sphk#define _VM_SWAP_PAGER_H_ 1 491541Srgrimes 501541Srgrimes/* 5167082Sdillon * SWB_NPAGES must be a power of 2. It may be set to 1, 2, 4, 8, or 16 5267082Sdillon * pages per allocation. We recommend you stick with the default of 8. 5367082Sdillon * The 16-page limit is due to the radix code (kern/subr_blist.c). 541541Srgrimes */ 5533758Sdyson#if !defined(SWB_NPAGES) 561549Srgrimes#define SWB_NPAGES 8 5733758Sdyson#endif 5833758Sdyson 5942957Sdillon/* 6042957Sdillon * Piecemeal swap metadata structure. Swap is stored in a radix tree. 6142957Sdillon * 6242957Sdillon * If SWB_NPAGES is 8 and sizeof(char *) == sizeof(daddr_t), our radix 6342957Sdillon * is basically 8. Assuming PAGE_SIZE == 4096, one tree level represents 6442957Sdillon * 32K worth of data, two levels represent 256K, three levels represent 6542957Sdillon * 2 MBytes. This is acceptable. 6642957Sdillon * 6742957Sdillon * Overall memory utilization is about the same as the old swap structure. 6842957Sdillon */ 6942957Sdillon#define SWCORRECT(n) (sizeof(void *) * (n) / sizeof(daddr_t)) 7042957Sdillon#define SWAP_META_PAGES (SWB_NPAGES * 2) 7142957Sdillon#define SWAP_META_MASK (SWAP_META_PAGES - 1) 7242957Sdillon 735455Sdgstruct swblock { 7442957Sdillon struct swblock *swb_hnext; 7542957Sdillon vm_object_t swb_object; 7651339Sdillon vm_pindex_t swb_index; 7742957Sdillon int swb_count; 7842957Sdillon daddr_t swb_pages[SWAP_META_PAGES]; 791541Srgrimes}; 801541Srgrimes 8155206Speter#ifdef _KERNEL 8210080Sbdeextern struct pagerlst swap_pager_un_object_list; 8311317Sdgextern int swap_pager_full; 8442957Sdillonextern struct blist *swapblist; 85102966Sbdeextern struct uma_zone *swap_zone; 86107913Sdillonextern int nswap_lowat, nswap_hiwat; 8710080Sbde 8892727Salfredvoid swap_pager_putpages(vm_object_t, vm_page_t *, int, boolean_t, int *); 8992727Salfredboolean_t swap_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before, int *after); 90107913Sdillonvoid swap_pager_swapoff(int devidx, int *sw_used); 9142957Sdillon 9292727Salfredint swap_pager_swp_alloc(vm_object_t, int); 9392727Salfredvoid swap_pager_copy(vm_object_t, vm_object_t, vm_pindex_t, int); 9492727Salfredvoid swap_pager_freespace(vm_object_t, vm_pindex_t, vm_size_t); 9592727Salfredvoid swap_pager_dmzspace(vm_object_t, vm_pindex_t, vm_size_t); 9692727Salfredvoid swap_pager_swap_init(void); 9792727Salfredint swap_pager_reserve(vm_object_t, vm_pindex_t, vm_size_t); 9842957Sdillon 9942957Sdillon/* 10042957Sdillon * newswap functions 10142957Sdillon */ 10242957Sdillon 10392727Salfredvoid swap_pager_page_removed(vm_page_t, vm_object_t); 10442957Sdillon 10553338Speter/* choose underlying swap device and queue up I/O */ 10653338Speterstruct buf; 10792727Salfredvoid swstrategy(struct buf *bp); /* probably needs to move elsewhere */ 10853338Speter 10992029Seivind#endif /* _KERNEL */ 110108599Sphk#endif /* _VM_SWAP_PAGER_H_ */ 111