| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: uvm_page.h,v 1.73 2011/06/12 03:36:03 rmind Exp $ */ | | 1 | /* $NetBSD: uvm_page.h,v 1.74 2012/01/28 19:12:10 rmind Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1997 Charles D. Cranor and Washington University. | | 4 | * Copyright (c) 1997 Charles D. Cranor and Washington University. |
5 | * Copyright (c) 1991, 1993, The Regents of the University of California. | | 5 | * Copyright (c) 1991, 1993, The Regents of the University of California. |
6 | * | | 6 | * |
7 | * All rights reserved. | | 7 | * All rights reserved. |
8 | * | | 8 | * |
9 | * This code is derived from software contributed to Berkeley by | | 9 | * This code is derived from software contributed to Berkeley by |
10 | * The Mach Operating System project at Carnegie-Mellon University. | | 10 | * The Mach Operating System project at Carnegie-Mellon University. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -54,103 +54,96 @@ | | | @@ -54,103 +54,96 @@ |
54 | * | | 54 | * |
55 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | | 55 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU |
56 | * School of Computer Science | | 56 | * School of Computer Science |
57 | * Carnegie Mellon University | | 57 | * Carnegie Mellon University |
58 | * Pittsburgh PA 15213-3890 | | 58 | * Pittsburgh PA 15213-3890 |
59 | * | | 59 | * |
60 | * any improvements or extensions that they make and grant Carnegie the | | 60 | * any improvements or extensions that they make and grant Carnegie the |
61 | * rights to redistribute these changes. | | 61 | * rights to redistribute these changes. |
62 | */ | | 62 | */ |
63 | | | 63 | |
64 | #ifndef _UVM_UVM_PAGE_H_ | | 64 | #ifndef _UVM_UVM_PAGE_H_ |
65 | #define _UVM_UVM_PAGE_H_ | | 65 | #define _UVM_UVM_PAGE_H_ |
66 | | | 66 | |
67 | /* | | 67 | #include <uvm/uvm_extern.h> |
68 | * uvm_page.h | | 68 | #include <uvm/uvm_pglist.h> |
69 | */ | | | |
70 | | | 69 | |
71 | /* | | 70 | #include <sys/rbtree.h> |
72 | * Resident memory system definitions. | | | |
73 | */ | | | |
74 | | | 71 | |
75 | /* | | 72 | /* |
76 | * Management of resident (logical) pages. | | 73 | * Management of resident (logical) pages. |
77 | * | | | |
78 | * A small structure is kept for each resident | | | |
79 | * page, indexed by page number. Each structure | | | |
80 | * is an element of several lists: | | | |
81 | * | | | |
82 | * A red-black tree rooted with the containing | | | |
83 | * object is used to quickly perform object+ | | | |
84 | * offset lookups | | | |
85 | * | | | |
86 | * A list of all pages for a given object, | | | |
87 | * so they can be quickly deactivated at | | | |
88 | * time of deallocation. | | | |
89 | * | | 74 | * |
90 | * An ordered list of pages due for pageout. | | 75 | * Each resident page has a vm_page structure, indexed by page number. |
| | | 76 | * There are several lists in the structure: |
91 | * | | 77 | * |
92 | * In addition, the structure contains the object | | 78 | * - A red-black tree rooted with the containing object is used to |
93 | * and offset to which this page belongs (for pageout), | | 79 | * quickly perform object+offset lookups. |
94 | * and sundry status bits. | | 80 | * - A list of all pages for a given object, for a quick deactivation |
| | | 81 | * at a time of deallocation. |
| | | 82 | * - An ordered list of pages due for pageout. |
| | | 83 | * |
| | | 84 | * In addition, the structure contains the object and offset to which |
| | | 85 | * this page belongs (for pageout) and sundry status bits. |
| | | 86 | * |
| | | 87 | * Note that the page structure has no lock of its own. The page is |
| | | 88 | * generally protected by its owner's lock (UVM object or amap/anon). |
| | | 89 | * It should be noted that UVM has to serialize pmap(9) operations on |
| | | 90 | * the managed pages, e.g. for pmap_enter() calls. Hence, the lock |
| | | 91 | * order is as follows: |
| | | 92 | * |
| | | 93 | * [vmpage-owner-lock] -> |
| | | 94 | * any pmap locks (e.g. PV hash lock) |
| | | 95 | * |
| | | 96 | * Since the kernel is always self-consistent, no serialization is |
| | | 97 | * required for unmanaged mappings, e.g. for pmap_kenter_pa() calls. |
| | | 98 | * |
| | | 99 | * Field markings and the corresponding locks: |
| | | 100 | * |
| | | 101 | * o: page owner's lock (UVM object or amap/anon) |
| | | 102 | * p: lock on the page queues |
| | | 103 | * o|p: either lock can be acquired |
| | | 104 | * o&p: both locks are required |
| | | 105 | * ?: locked by pmap or assumed page owner's lock |
95 | * | | 106 | * |
96 | * Fields in this structure are locked either by the lock on the | | 107 | * UVM and pmap(9) may use uvm_page_locked_p() to assert whether the |
97 | * object that the page belongs to (O) or by the lock on the page | | 108 | * page owner's lock is acquired. |
98 | * queues (P) [or both]. | | | |
99 | */ | | 109 | */ |
100 | | | 110 | |
101 | /* | | | |
102 | * locking note: the mach version of this data structure had bit | | | |
103 | * fields for the flags, and the bit fields were divided into two | | | |
104 | * items (depending on who locked what). some time, in BSD, the bit | | | |
105 | * fields were dumped and all the flags were lumped into one short. | | | |
106 | * that is fine for a single threaded uniprocessor OS, but bad if you | | | |
107 | * want to actual make use of locking. so, we've separated things | | | |
108 | * back out again. | | | |
109 | * | | | |
110 | * note the page structure has no lock of its own. | | | |
111 | */ | | | |
112 | | | | |
113 | #include <uvm/uvm_extern.h> | | | |
114 | #include <uvm/uvm_pglist.h> | | | |
115 | | | | |
116 | #include <sys/rbtree.h> | | | |
117 | | | | |
118 | struct vm_page { | | 111 | struct vm_page { |
119 | struct rb_node rb_node; /* tree of pages in obj (O) */ | | 112 | struct rb_node rb_node; /* o: tree of pages in obj */ |
120 | | | 113 | |
121 | union { | | 114 | union { |
122 | TAILQ_ENTRY(vm_page) queue; | | 115 | TAILQ_ENTRY(vm_page) queue; |
123 | LIST_ENTRY(vm_page) list; | | 116 | LIST_ENTRY(vm_page) list; |
124 | } pageq; /* queue info for FIFO | | 117 | } pageq; /* p: queue info for FIFO |
125 | * queue or free list (P) */ | | 118 | * queue or free list */ |
126 | union { | | 119 | union { |
127 | TAILQ_ENTRY(vm_page) queue; | | 120 | TAILQ_ENTRY(vm_page) queue; |
128 | LIST_ENTRY(vm_page) list; | | 121 | LIST_ENTRY(vm_page) list; |
129 | } listq; /* pages in same object (O)*/ | | 122 | } listq; /* o: pages in same object */ |
130 | | | 123 | |
131 | struct vm_anon *uanon; /* anon (O,P) */ | | 124 | struct vm_anon *uanon; /* o,p: anon */ |
132 | struct uvm_object *uobject; /* object (O,P) */ | | 125 | struct uvm_object *uobject; /* o,p: object */ |
133 | voff_t offset; /* offset into object (O,P) */ | | 126 | voff_t offset; /* o,p: offset into object */ |
134 | uint16_t flags; /* object flags [O] */ | | 127 | uint16_t flags; /* o: object flags */ |
135 | uint16_t loan_count; /* number of active loans | | 128 | uint16_t loan_count; /* number of active loans |
136 | * to read: [O or P] | | 129 | * o|p: for reading |
137 | * to modify: [O _and_ P] */ | | 130 | * o&p: for modification */ |
138 | uint16_t wire_count; /* wired down map refs [P] */ | | 131 | uint16_t wire_count; /* p: wired down map refs */ |
139 | uint16_t pqflags; /* page queue flags [P] */ | | 132 | uint16_t pqflags; /* p: page queue flags */ |
140 | paddr_t phys_addr; /* physical address of page */ | | 133 | paddr_t phys_addr; /* physical address of page */ |
141 | | | 134 | |
142 | #ifdef __HAVE_VM_PAGE_MD | | 135 | #ifdef __HAVE_VM_PAGE_MD |
143 | struct vm_page_md mdpage; /* pmap-specific data */ | | 136 | struct vm_page_md mdpage; /* ?: pmap-specific data */ |
144 | #endif | | 137 | #endif |
145 | | | 138 | |
146 | #if defined(UVM_PAGE_TRKOWN) | | 139 | #if defined(UVM_PAGE_TRKOWN) |
147 | /* debugging fields to track page ownership */ | | 140 | /* debugging fields to track page ownership */ |
148 | pid_t owner; /* proc that set PG_BUSY */ | | 141 | pid_t owner; /* proc that set PG_BUSY */ |
149 | lwpid_t lowner; /* lwp that set PG_BUSY */ | | 142 | lwpid_t lowner; /* lwp that set PG_BUSY */ |
150 | const char *owner_tag; /* why it was set busy */ | | 143 | const char *owner_tag; /* why it was set busy */ |
151 | #endif | | 144 | #endif |
152 | }; | | 145 | }; |
153 | | | 146 | |
154 | /* | | 147 | /* |
155 | * These are the flags defined for vm_page. | | 148 | * These are the flags defined for vm_page. |
156 | */ | | 149 | */ |