Annotation of Net2/vm/vm_page.h, revision 1.1.1.2

1.1       root        1: /* 
                      2:  * Copyright (c) 1991 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * This code is derived from software contributed to Berkeley by
                      6:  * The Mach Operating System project at Carnegie-Mellon University.
                      7:  *
                      8:  * Redistribution and use in source and binary forms, with or without
                      9:  * modification, are permitted provided that the following conditions
                     10:  * are met:
                     11:  * 1. Redistributions of source code must retain the above copyright
                     12:  *    notice, this list of conditions and the following disclaimer.
                     13:  * 2. Redistributions in binary form must reproduce the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer in the
                     15:  *    documentation and/or other materials provided with the distribution.
                     16:  * 3. All advertising materials mentioning features or use of this software
                     17:  *    must display the following acknowledgement:
                     18:  *     This product includes software developed by the University of
                     19:  *     California, Berkeley and its contributors.
                     20:  * 4. Neither the name of the University nor the names of its contributors
                     21:  *    may be used to endorse or promote products derived from this software
                     22:  *    without specific prior written permission.
                     23:  *
                     24:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     25:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     26:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     27:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     28:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     29:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     30:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     31:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     32:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     33:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     34:  * SUCH DAMAGE.
                     35:  *
1.1.1.2 ! root       36:  *     from: @(#)vm_page.h     7.3 (Berkeley) 4/21/91
        !            37:  *     vm_page.h,v 1.3 1993/05/20 03:59:38 cgd Exp
1.1       root       38:  *
                     39:  *
                     40:  * Copyright (c) 1987, 1990 Carnegie-Mellon University.
                     41:  * All rights reserved.
                     42:  *
                     43:  * Authors: Avadis Tevanian, Jr., Michael Wayne Young
                     44:  * 
                     45:  * Permission to use, copy, modify and distribute this software and
                     46:  * its documentation is hereby granted, provided that both the copyright
                     47:  * notice and this permission notice appear in all copies of the
                     48:  * software, derivative works or modified versions, and any portions
                     49:  * thereof, and that both notices appear in supporting documentation.
                     50:  * 
                     51:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 
                     52:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 
                     53:  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     54:  * 
                     55:  * Carnegie Mellon requests users of this software to return to
                     56:  *
                     57:  *  Software Distribution Coordinator  or  [email protected]
                     58:  *  School of Computer Science
                     59:  *  Carnegie Mellon University
                     60:  *  Pittsburgh PA 15213-3890
                     61:  *
                     62:  * any improvements or extensions that they make and grant Carnegie the
                     63:  * rights to redistribute these changes.
                     64:  */
                     65: 
1.1.1.2 ! root       66: #ifndef _VM_VM_PAGE_H_
        !            67: #define _VM_VM_PAGE_H_
        !            68: 
1.1       root       69: /*
                     70:  *     Resident memory system definitions.
                     71:  */
                     72: 
                     73: /*
                     74:  *     Management of resident (logical) pages.
                     75:  *
                     76:  *     A small structure is kept for each resident
                     77:  *     page, indexed by page number.  Each structure
                     78:  *     is an element of several lists:
                     79:  *
                     80:  *             A hash table bucket used to quickly
                     81:  *             perform object/offset lookups
                     82:  *
                     83:  *             A list of all pages for a given object,
                     84:  *             so they can be quickly deactivated at
                     85:  *             time of deallocation.
                     86:  *
                     87:  *             An ordered list of pages due for pageout.
                     88:  *
                     89:  *     In addition, the structure contains the object
                     90:  *     and offset to which this page belongs (for pageout),
                     91:  *     and sundry status bits.
                     92:  *
                     93:  *     Fields in this structure are locked either by the lock on the
                     94:  *     object that the page belongs to (O) or by the lock on the page
                     95:  *     queues (P).
                     96:  */
                     97: 
                     98: struct vm_page {
                     99:        queue_chain_t   pageq;          /* queue info for FIFO
                    100:                                         * queue or free list (P) */
                    101:        queue_chain_t   hashq;          /* hash table links (O)*/
                    102:        queue_chain_t   listq;          /* all pages in same object (O)*/
                    103: 
                    104:        vm_object_t     object;         /* which object am I in (O,P)*/
                    105:        vm_offset_t     offset;         /* offset into that object (O,P) */
                    106: 
                    107:        unsigned int    wire_count:16,  /* how many wired down maps use me?
                    108:                                           (P) */
                    109:        /* boolean_t */ inactive:1,     /* page is in inactive list (P) */
                    110:                        active:1,       /* page is in active list (P) */
                    111:                        laundry:1,      /* page is being cleaned now (P)*/
                    112: #ifdef DEBUG
                    113:                        pagerowned:1,   /* async paging op in progress */
                    114:                        ptpage:1,       /* is a user page table page */
                    115: #endif
                    116:                        :0;             /* (force to 'long' boundary) */
                    117: #ifdef ns32000
                    118:        int             pad;            /* extra space for ns32000 bit ops */
                    119: #endif ns32000
                    120:        boolean_t       clean;          /* page has not been modified */
                    121:        unsigned int
                    122:        /* boolean_t */ busy:1,         /* page is in transit (O) */
                    123:                        wanted:1,       /* someone is waiting for page (O) */
                    124:                        tabled:1,       /* page is in VP table (O) */
                    125:                        copy_on_write:1,/* page must be copied before being
                    126:                                           changed (O) */
                    127:                        fictitious:1,   /* physical page doesn't exist (O) */
                    128:                        absent:1,       /* virtual page doesn't exist (O) */
                    129:                        fake:1,         /* page is a placeholder for page-in
                    130:                                           (O) */
                    131:                        :0;
                    132: 
                    133:        vm_offset_t     phys_addr;      /* physical address of page */
                    134:        vm_prot_t       page_lock;      /* Uses prohibited by data manager */
                    135:        vm_prot_t       unlock_request; /* Outstanding unlock request */
                    136: };
                    137: 
                    138: typedef struct vm_page *vm_page_t;
                    139: 
                    140: #if    VM_PAGE_DEBUG
                    141: #define        VM_PAGE_CHECK(mem) { \
                    142:                if ( (((unsigned int) mem) < ((unsigned int) &vm_page_array[0])) || \
                    143:                     (((unsigned int) mem) > ((unsigned int) &vm_page_array[last_page-first_page])) || \
                    144:                     (mem->active && mem->inactive) \
                    145:                    ) panic("vm_page_check: not valid!"); \
                    146:                }
                    147: #else  VM_PAGE_DEBUG
                    148: #define        VM_PAGE_CHECK(mem)
                    149: #endif VM_PAGE_DEBUG
                    150: 
                    151: #ifdef KERNEL
                    152: /*
                    153:  *     Each pageable resident page falls into one of three lists:
                    154:  *
                    155:  *     free    
                    156:  *             Available for allocation now.
                    157:  *     inactive
                    158:  *             Not referenced in any map, but still has an
                    159:  *             object/offset-page mapping, and may be dirty.
                    160:  *             This is the list of pages that should be
                    161:  *             paged out next.
                    162:  *     active
                    163:  *             A list of pages which have been placed in
                    164:  *             at least one physical map.  This list is
                    165:  *             ordered, in LRU-like fashion.
                    166:  */
                    167: 
                    168: extern
                    169: queue_head_t   vm_page_queue_free;     /* memory free queue */
                    170: extern
                    171: queue_head_t   vm_page_queue_active;   /* active memory queue */
                    172: extern
                    173: queue_head_t   vm_page_queue_inactive; /* inactive memory queue */
                    174: 
                    175: extern
                    176: vm_page_t      vm_page_array;          /* First resident page in table */
                    177: extern
                    178: long           first_page;             /* first physical page number */
                    179:                                        /* ... represented in vm_page_array */
                    180: extern
                    181: long           last_page;              /* last physical page number */
                    182:                                        /* ... represented in vm_page_array */
                    183:                                        /* [INCLUSIVE] */
                    184: extern
                    185: vm_offset_t    first_phys_addr;        /* physical address for first_page */
                    186: extern
                    187: vm_offset_t    last_phys_addr;         /* physical address for last_page */
                    188: 
                    189: extern
                    190: int    vm_page_free_count;     /* How many pages are free? */
                    191: extern
                    192: int    vm_page_active_count;   /* How many pages are active? */
                    193: extern
                    194: int    vm_page_inactive_count; /* How many pages are inactive? */
                    195: extern
                    196: int    vm_page_wire_count;     /* How many pages are wired? */
                    197: extern
                    198: int    vm_page_free_target;    /* How many do we want free? */
                    199: extern
                    200: int    vm_page_free_min;       /* When to wakeup pageout */
                    201: extern
                    202: int    vm_page_inactive_target;/* How many do we want inactive? */
                    203: extern
                    204: int    vm_page_free_reserved;  /* How many pages reserved to do pageout */
                    205: extern
                    206: int    vm_page_laundry_count;  /* How many pages being laundered? */
                    207: 
                    208: #define VM_PAGE_TO_PHYS(entry) ((entry)->phys_addr)
                    209: 
                    210: #define IS_VM_PHYSADDR(pa) \
                    211:                ((pa) >= first_phys_addr && (pa) <= last_phys_addr)
                    212: 
                    213: #define PHYS_TO_VM_PAGE(pa) \
                    214:                (&vm_page_array[atop(pa) - first_page ])
                    215: 
                    216: extern
                    217: simple_lock_data_t     vm_page_queue_lock;     /* lock on active and inactive
                    218:                                                   page queues */
                    219: extern
                    220: simple_lock_data_t     vm_page_queue_free_lock;
                    221:                                                /* lock on free page queue */
                    222: vm_offset_t    vm_page_startup();
                    223: vm_page_t      vm_page_lookup();
                    224: vm_page_t      vm_page_alloc();
                    225: void           vm_page_init();
                    226: void           vm_page_free();
                    227: void           vm_page_activate();
                    228: void           vm_page_deactivate();
                    229: void           vm_page_rename();
                    230: void           vm_page_replace();
                    231: 
                    232: boolean_t      vm_page_zero_fill();
                    233: void           vm_page_copy();
                    234: 
                    235: void           vm_page_wire();
                    236: void           vm_page_unwire();
                    237: 
                    238: void           vm_set_page_size();
                    239: 
                    240: /*
                    241:  *     Functions implemented as macros
                    242:  */
                    243: 
                    244: #define PAGE_ASSERT_WAIT(m, interruptible)     { \
                    245:                                (m)->wanted = TRUE; \
                    246:                                assert_wait((int) (m), (interruptible)); \
                    247:                        }
                    248: 
                    249: #define PAGE_WAKEUP(m) { \
                    250:                                (m)->busy = FALSE; \
                    251:                                if ((m)->wanted) { \
                    252:                                        (m)->wanted = FALSE; \
                    253:                                        thread_wakeup((int) (m)); \
                    254:                                } \
                    255:                        }
                    256: 
                    257: #define        vm_page_lock_queues()   simple_lock(&vm_page_queue_lock)
                    258: #define        vm_page_unlock_queues() simple_unlock(&vm_page_queue_lock)
                    259: 
                    260: #define vm_page_set_modified(m)        { (m)->clean = FALSE; }
                    261: #endif KERNEL
1.1.1.2 ! root      262: 
        !           263: #endif /* !_VM_VM_PAGE_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.