swap_pager.h revision 50477
139172Sjkh/* 239172Sjkh * Copyright (c) 1990 University of Utah. 339172Sjkh * Copyright (c) 1991 The Regents of the University of California. 439172Sjkh * All rights reserved. 539172Sjkh * 639172Sjkh * This code is derived from software contributed to Berkeley by 739172Sjkh * the Systems Programming Group of the University of Utah Computer 839172Sjkh * Science Department. 939172Sjkh * 1039172Sjkh * Redistribution and use in source and binary forms, with or without 1139172Sjkh * modification, are permitted provided that the following conditions 1239172Sjkh * are met: 1339172Sjkh * 1. Redistributions of source code must retain the above copyright 1439172Sjkh * notice, this list of conditions and the following disclaimer. 1539172Sjkh * 2. Redistributions in binary form must reproduce the above copyright 1639172Sjkh * notice, this list of conditions and the following disclaimer in the 1739172Sjkh * documentation and/or other materials provided with the distribution. 1839172Sjkh * 3. All advertising materials mentioning features or use of this software 1939172Sjkh * must display the following acknowledgement: 2039172Sjkh * This product includes software developed by the University of 2139172Sjkh * California, Berkeley and its contributors. 2239172Sjkh * 4. Neither the name of the University nor the names of its contributors 2339172Sjkh * may be used to endorse or promote products derived from this software 2439172Sjkh * without specific prior written permission. 2539172Sjkh * 2639172Sjkh * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2739172Sjkh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2839172Sjkh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2939172Sjkh * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3039172Sjkh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3139172Sjkh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3239172Sjkh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3339172Sjkh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3439172Sjkh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3539172Sjkh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3639172Sjkh * SUCH DAMAGE. 3739172Sjkh * 3839172Sjkh * from: @(#)swap_pager.h 7.1 (Berkeley) 12/5/90 3939172Sjkh * $FreeBSD: head/sys/vm/swap_pager.h 50477 1999-08-28 01:08:13Z peter $ 4039172Sjkh */ 41 42/* 43 * Modifications to the block allocation data structure by John S. Dyson 44 * 18 Dec 93. 45 */ 46 47#ifndef _SWAP_PAGER_ 48#define _SWAP_PAGER_ 1 49 50/* 51 * SWB_NPAGES can be set to any value from 1 to 16 pages per allocation, 52 * however, due to the allocation spilling into non-swap pager backed memory, 53 * suggest keeping SWB_NPAGES small (1-4). If high performance is mandatory 54 * perhaps up to 8 pages might be in order???? 55 * Above problem has been fixed, now we support 16 pages per block. Unused 56 * space is recovered by the swap pager now... 57 */ 58#if !defined(SWB_NPAGES) 59#define SWB_NPAGES 8 60#endif 61 62/* 63 * Piecemeal swap metadata structure. Swap is stored in a radix tree. 64 * 65 * If SWB_NPAGES is 8 and sizeof(char *) == sizeof(daddr_t), our radix 66 * is basically 8. Assuming PAGE_SIZE == 4096, one tree level represents 67 * 32K worth of data, two levels represent 256K, three levels represent 68 * 2 MBytes. This is acceptable. 69 * 70 * Overall memory utilization is about the same as the old swap structure. 71 */ 72 73#define SWCORRECT(n) (sizeof(void *) * (n) / sizeof(daddr_t)) 74 75#define SWAP_META_PAGES (SWB_NPAGES * 2) 76#define SWAP_META_MASK (SWAP_META_PAGES - 1) 77 78struct swblock { 79 struct swblock *swb_hnext; 80 vm_object_t swb_object; 81 int swb_index; 82 int swb_count; 83 daddr_t swb_pages[SWAP_META_PAGES]; 84}; 85 86#ifdef KERNEL 87extern struct pagerlst swap_pager_un_object_list; 88extern int swap_pager_full; 89extern struct blist *swapblist; 90 91void swap_pager_putpages __P((vm_object_t, vm_page_t *, int, boolean_t, int *)); 92boolean_t swap_pager_haspage __P((vm_object_t object, vm_pindex_t pindex, int *before, int *after)); 93 94int swap_pager_swp_alloc __P((vm_object_t, int)); 95void swap_pager_copy __P((vm_object_t, vm_object_t, vm_pindex_t, int)); 96void swap_pager_freespace __P((vm_object_t, vm_pindex_t, vm_size_t)); 97void swap_pager_dmzspace __P((vm_object_t, vm_pindex_t, vm_size_t)); 98void swap_pager_swap_init __P((void)); 99 100/* 101 * newswap functions 102 */ 103 104void swap_pager_page_removed __P((vm_page_t, vm_object_t)); 105 106#endif 107 108#endif /* _SWAP_PAGER_ */ 109