Annotation of src/sys/uvm/uvm.h, Revision 1.73
1.73 ! ad 1: /* $NetBSD: uvm.h,v 1.72 2019/12/27 13:19:24 ad Exp $ */
1.3 mrg 2:
1.1 mrg 3: /*
4: * Copyright (c) 1997 Charles D. Cranor and Washington University.
5: * All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
15: *
16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.3 mrg 26: *
27: * from: Id: uvm.h,v 1.1.2.14 1998/02/02 20:07:19 chuck Exp
1.1 mrg 28: */
29:
1.4 perry 30: #ifndef _UVM_UVM_H_
31: #define _UVM_UVM_H_
32:
1.28 mrg 33: #if defined(_KERNEL_OPT)
1.8 thorpej 34: #include "opt_lockdebug.h"
1.12 thorpej 35: #include "opt_multiprocessor.h"
1.5 mrg 36: #include "opt_uvmhist.h"
1.59 uebayasi 37: #include "opt_uvm_page_trkown.h"
1.9 pk 38: #endif
1.5 mrg 39:
1.1 mrg 40: #include <uvm/uvm_extern.h>
41:
1.62 mrg 42: #ifdef _KERNEL
1.1 mrg 43: #include <uvm/uvm_stat.h>
1.62 mrg 44: #endif
1.1 mrg 45:
46: /*
47: * pull in prototypes
48: */
49:
50: #include <uvm/uvm_amap.h>
51: #include <uvm/uvm_aobj.h>
52: #include <uvm/uvm_fault.h>
53: #include <uvm/uvm_glue.h>
54: #include <uvm/uvm_km.h>
55: #include <uvm/uvm_loan.h>
56: #include <uvm/uvm_map.h>
57: #include <uvm/uvm_object.h>
58: #include <uvm/uvm_page.h>
59: #include <uvm/uvm_pager.h>
60: #include <uvm/uvm_pdaemon.h>
61: #include <uvm/uvm_swap.h>
62:
1.32 thorpej 63: #ifdef _KERNEL
64:
1.68 cherry 65: #include <uvm/uvm_physseg.h>
1.66 riastrad 66: #include <sys/rndsource.h>
67:
1.1 mrg 68: /*
1.10 thorpej 69: * pull in VM_NFREELIST
70: */
71: #include <machine/vmparam.h>
72:
1.45 yamt 73: struct workqueue;
1.71 ad 74: struct pgflcache;
1.45 yamt 75:
1.10 thorpej 76: /*
1.54 ad 77: * per-cpu data
78: */
79:
80: struct uvm_cpu {
1.72 ad 81: /* allocator */
1.71 ad 82: struct pgflcache *pgflcache[VM_NFREELIST];/* cpu-local cached pages */
83: void *pgflcachemem; /* pointer to allocated mem */
84: size_t pgflcachememsz; /* size of allocated memory */
85: u_int pgflcolor; /* next color to allocate */
86: u_int pgflbucket; /* where to send our pages */
1.72 ad 87:
88: /* entropy */
1.71 ad 89: krndsource_t rs; /* entropy source */
1.73 ! ad 90:
! 91: /* uvmpdpol: queue of intended page status changes. */
! 92: struct vm_page **pdq; /* queue entries */
! 93: u_int pdqhead; /* current queue head */
! 94: u_int pdqtail; /* maximum number entries */
! 95: int pdqtime; /* last time queue cleared */
1.54 ad 96: };
97:
98: /*
1.1 mrg 99: * uvm structure (vm global state: collected in one structure for ease
100: * of reference...)
101: */
102:
103: struct uvm {
104: /* vm_page related parameters */
1.24 chs 105:
1.1 mrg 106: /* vm_page queues */
1.21 thorpej 107: struct pgfreelist page_free[VM_NFREELIST]; /* unallocated pages */
1.71 ad 108: u_int bucketcount;
109: bool page_init_done; /* true if uvm_page_init() finished */
110: bool numa_alloc; /* use NUMA page allocation strategy */
1.24 chs 111:
1.1 mrg 112: /* page daemon trigger */
113: int pagedaemon; /* daemon sleeps on this */
1.52 ad 114: struct lwp *pagedaemon_lwp; /* daemon's lid */
1.24 chs 115:
1.45 yamt 116: /* aiodone daemon */
117: struct workqueue *aiodone_queue;
1.24 chs 118:
1.1 mrg 119: /* aio_done is locked by uvm.pagedaemon_lock and splbio! */
1.24 chs 120: TAILQ_HEAD(, buf) aio_done; /* done async i/o reqs */
1.52 ad 121: };
1.1 mrg 122:
1.52 ad 123: /*
124: * kernel object: to support anonymous pageable kernel memory
125: */
126: extern struct uvm_object *uvm_kernel_object;
1.32 thorpej 127:
1.51 ad 128: /*
129: * locks (made globals for lockstat).
130: */
131:
1.52 ad 132: extern kmutex_t uvm_kentry_lock;
1.51 ad 133:
1.32 thorpej 134: #endif /* _KERNEL */
1.1 mrg 135:
136: /*
137: * vm_map_entry etype bits:
138: */
139:
140: #define UVM_ET_OBJ 0x01 /* it is a uvm_object */
1.13 chuck 141: #define UVM_ET_SUBMAP 0x02 /* it is a vm_map submap */
142: #define UVM_ET_COPYONWRITE 0x04 /* copy_on_write */
143: #define UVM_ET_NEEDSCOPY 0x08 /* needs_copy */
1.1 mrg 144:
145: #define UVM_ET_ISOBJ(E) (((E)->etype & UVM_ET_OBJ) != 0)
146: #define UVM_ET_ISSUBMAP(E) (((E)->etype & UVM_ET_SUBMAP) != 0)
147: #define UVM_ET_ISCOPYONWRITE(E) (((E)->etype & UVM_ET_COPYONWRITE) != 0)
148: #define UVM_ET_ISNEEDSCOPY(E) (((E)->etype & UVM_ET_NEEDSCOPY) != 0)
149:
1.23 mrg 150: #ifdef _KERNEL
151:
1.1 mrg 152: /*
1.23 mrg 153: * holds all the internal UVM data
1.1 mrg 154: */
1.20 chs 155: extern struct uvm uvm;
156:
157: /*
158: * historys
159: */
160:
1.34 perry 161: #ifdef UVMHIST
1.20 chs 162: UVMHIST_DECL(maphist);
163: UVMHIST_DECL(pdhist);
1.24 chs 164: UVMHIST_DECL(ubchist);
1.38 yamt 165: UVMHIST_DECL(loanhist);
1.33 perry 166: #endif
1.16 thorpej 167:
1.42 yamt 168: extern struct evcnt uvm_ra_total;
169: extern struct evcnt uvm_ra_hit;
170: extern struct evcnt uvm_ra_miss;
171:
1.1 mrg 172: /*
1.22 thorpej 173: * UVM_UNLOCK_AND_WAIT: atomic unlock+wait... wrapper around the
174: * interlocked tsleep() function.
1.1 mrg 175: */
176:
1.22 thorpej 177: #define UVM_UNLOCK_AND_WAIT(event, slock, intr, msg, timo) \
178: do { \
1.53 ad 179: (void) mtsleep(event, PVM | PNORELOCK | (intr ? PCATCH : 0), \
1.22 thorpej 180: msg, timo, slock); \
1.33 perry 181: } while (/*CONSTCOND*/ 0)
1.30 thorpej 182:
1.44 yamt 183: void uvm_kick_pdaemon(void);
1.1 mrg 184:
185: /*
186: * UVM_PAGE_OWN: track page ownership (only if UVM_PAGE_TRKOWN)
187: */
188:
189: #if defined(UVM_PAGE_TRKOWN)
190: #define UVM_PAGE_OWN(PG, TAG) uvm_page_own(PG, TAG)
1.16 thorpej 191: #else
1.1 mrg 192: #define UVM_PAGE_OWN(PG, TAG) /* nothing */
193: #endif /* UVM_PAGE_TRKOWN */
194:
195: #include <uvm/uvm_fault_i.h>
1.41 yamt 196:
1.16 thorpej 197: #endif /* _KERNEL */
1.4 perry 198:
1.43 yamt 199: #endif /* _UVM_UVM_H_ */
CVSweb <webmaster@jp.NetBSD.org>