Deleted Added
full compact
vm_object.c (28992) vm_object.c (29653)
1/*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. 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

--- 47 unchanged lines hidden (view full) ---

56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
57 * School of Computer Science
58 * Carnegie Mellon University
59 * Pittsburgh PA 15213-3890
60 *
61 * any improvements or extensions that they make and grant Carnegie the
62 * rights to redistribute these changes.
63 *
1/*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. 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

--- 47 unchanged lines hidden (view full) ---

56 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
57 * School of Computer Science
58 * Carnegie Mellon University
59 * Pittsburgh PA 15213-3890
60 *
61 * any improvements or extensions that they make and grant Carnegie the
62 * rights to redistribute these changes.
63 *
64 * $Id: vm_object.c,v 1.96 1997/09/01 02:55:48 bde Exp $
64 * $Id: vm_object.c,v 1.97 1997/09/01 03:17:22 bde Exp $
65 */
66
67/*
68 * Virtual memory object module.
69 */
70
71#include <sys/param.h>
72#include <sys/systm.h>

--- 11 unchanged lines hidden (view full) ---

84#include <vm/vm_map.h>
85#include <vm/vm_object.h>
86#include <vm/vm_page.h>
87#include <vm/vm_pageout.h>
88#include <vm/vm_pager.h>
89#include <vm/swap_pager.h>
90#include <vm/vm_kern.h>
91#include <vm/vm_extern.h>
65 */
66
67/*
68 * Virtual memory object module.
69 */
70
71#include <sys/param.h>
72#include <sys/systm.h>

--- 11 unchanged lines hidden (view full) ---

84#include <vm/vm_map.h>
85#include <vm/vm_object.h>
86#include <vm/vm_page.h>
87#include <vm/vm_pageout.h>
88#include <vm/vm_pager.h>
89#include <vm/swap_pager.h>
90#include <vm/vm_kern.h>
91#include <vm/vm_extern.h>
92#include <vm/vm_zone.h>
92
93static void vm_object_qcollapse __P((vm_object_t object));
94#ifdef not_used
95static void vm_object_deactivate_pages __P((vm_object_t));
96#endif
97static void vm_object_terminate __P((vm_object_t));
98static void vm_object_cache_trim __P((void));
99

--- 33 unchanged lines hidden (view full) ---

133vm_object_t kmem_object;
134static struct vm_object kernel_object_store;
135static struct vm_object kmem_object_store;
136extern int vm_pageout_page_count;
137
138static long object_collapses;
139static long object_bypasses;
140static int next_index;
93
94static void vm_object_qcollapse __P((vm_object_t object));
95#ifdef not_used
96static void vm_object_deactivate_pages __P((vm_object_t));
97#endif
98static void vm_object_terminate __P((vm_object_t));
99static void vm_object_cache_trim __P((void));
100

--- 33 unchanged lines hidden (view full) ---

134vm_object_t kmem_object;
135static struct vm_object kernel_object_store;
136static struct vm_object kmem_object_store;
137extern int vm_pageout_page_count;
138
139static long object_collapses;
140static long object_bypasses;
141static int next_index;
142static vm_zone_t obj_zone;
143static struct vm_zone obj_zone_store;
144#define VM_OBJECTS_INIT 256
145struct vm_object vm_objects_init[VM_OBJECTS_INIT];
141
142void
143_vm_object_allocate(type, size, object)
144 objtype_t type;
145 vm_size_t size;
146 register vm_object_t object;
147{
146
147void
148_vm_object_allocate(type, size, object)
149 objtype_t type;
150 vm_size_t size;
151 register vm_object_t object;
152{
153 int incr;
148 TAILQ_INIT(&object->memq);
149 TAILQ_INIT(&object->shadow_head);
150
151 object->type = type;
152 object->size = size;
153 object->ref_count = 1;
154 object->flags = 0;
155 object->behavior = OBJ_NORMAL;
156 object->paging_in_progress = 0;
157 object->resident_page_count = 0;
158 object->shadow_count = 0;
159 object->pg_color = next_index;
154 TAILQ_INIT(&object->memq);
155 TAILQ_INIT(&object->shadow_head);
156
157 object->type = type;
158 object->size = size;
159 object->ref_count = 1;
160 object->flags = 0;
161 object->behavior = OBJ_NORMAL;
162 object->paging_in_progress = 0;
163 object->resident_page_count = 0;
164 object->shadow_count = 0;
165 object->pg_color = next_index;
160 next_index = (next_index + PQ_PRIME1) & PQ_L2_MASK;
166 if ( size > (PQ_L2_SIZE / 3 + PQ_PRIME1))
167 incr = PQ_L2_SIZE / 3 + PQ_PRIME1;
168 else
169 incr = size;
170 next_index = (next_index + incr) & PQ_L2_MASK;
161 object->handle = NULL;
162 object->paging_offset = (vm_ooffset_t) 0;
163 object->backing_object = NULL;
164 object->backing_object_offset = (vm_ooffset_t) 0;
165 object->page_hint = NULL;
166
167 object->last_read = 0;
168

--- 20 unchanged lines hidden (view full) ---

189
190 kernel_object = &kernel_object_store;
191 _vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
192 kernel_object);
193
194 kmem_object = &kmem_object_store;
195 _vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
196 kmem_object);
171 object->handle = NULL;
172 object->paging_offset = (vm_ooffset_t) 0;
173 object->backing_object = NULL;
174 object->backing_object_offset = (vm_ooffset_t) 0;
175 object->page_hint = NULL;
176
177 object->last_read = 0;
178

--- 20 unchanged lines hidden (view full) ---

199
200 kernel_object = &kernel_object_store;
201 _vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
202 kernel_object);
203
204 kmem_object = &kmem_object_store;
205 _vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
206 kmem_object);
207
208 obj_zone = &obj_zone_store;
209 zbootinit(obj_zone, "VM OBJECT", sizeof (struct vm_object),
210 vm_objects_init, VM_OBJECTS_INIT);
197}
198
211}
212
213void
214vm_object_init2() {
215 zinitna(obj_zone, NULL, NULL, 0, 0, 0, 4);
216}
217
199/*
200 * vm_object_allocate:
201 *
202 * Returns a new object with the given size.
203 */
204
205vm_object_t
206vm_object_allocate(type, size)
207 objtype_t type;
208 vm_size_t size;
209{
210 register vm_object_t result;
218/*
219 * vm_object_allocate:
220 *
221 * Returns a new object with the given size.
222 */
223
224vm_object_t
225vm_object_allocate(type, size)
226 objtype_t type;
227 vm_size_t size;
228{
229 register vm_object_t result;
230 result = (vm_object_t) zalloc(obj_zone);
211
231
212 result = (vm_object_t)
213 malloc((u_long) sizeof *result, M_VMOBJ, M_WAITOK);
214
215
216 _vm_object_allocate(type, size, result);
217
218 return (result);
219}
220
221
222/*
223 * vm_object_reference:

--- 200 unchanged lines hidden (view full) ---

424 vm_object_count--;
425 simple_unlock(&vm_object_list_lock);
426
427 wakeup(object);
428
429 /*
430 * Free the space for the object.
431 */
232 _vm_object_allocate(type, size, result);
233
234 return (result);
235}
236
237
238/*
239 * vm_object_reference:

--- 200 unchanged lines hidden (view full) ---

440 vm_object_count--;
441 simple_unlock(&vm_object_list_lock);
442
443 wakeup(object);
444
445 /*
446 * Free the space for the object.
447 */
432 free((caddr_t) object, M_VMOBJ);
448 zfree(obj_zone, object);
433}
434
435/*
436 * vm_object_page_clean
437 *
438 * Clean all dirty pages in the specified range of object.
439 * Leaves page on whatever queue it is currently on.
440 *

--- 656 unchanged lines hidden (view full) ---

1097 * and no object references within it, all that is
1098 * necessary is to dispose of it.
1099 */
1100
1101 TAILQ_REMOVE(&vm_object_list, backing_object,
1102 object_list);
1103 vm_object_count--;
1104
449}
450
451/*
452 * vm_object_page_clean
453 *
454 * Clean all dirty pages in the specified range of object.
455 * Leaves page on whatever queue it is currently on.
456 *

--- 656 unchanged lines hidden (view full) ---

1113 * and no object references within it, all that is
1114 * necessary is to dispose of it.
1115 */
1116
1117 TAILQ_REMOVE(&vm_object_list, backing_object,
1118 object_list);
1119 vm_object_count--;
1120
1105 free((caddr_t) backing_object, M_VMOBJ);
1121 zfree(obj_zone, backing_object);
1106
1107 object_collapses++;
1108 } else {
1109 /*
1110 * If all of the pages in the backing object are
1111 * shadowed by the parent object, the parent object no
1112 * longer has to shadow the backing object; it can
1113 * shadow the next one in the chain.

--- 523 unchanged lines hidden ---
1122
1123 object_collapses++;
1124 } else {
1125 /*
1126 * If all of the pages in the backing object are
1127 * shadowed by the parent object, the parent object no
1128 * longer has to shadow the backing object; it can
1129 * shadow the next one in the chain.

--- 523 unchanged lines hidden ---