Deleted Added
full compact
vm_object.c (92511) vm_object.c (92654)
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 * $FreeBSD: head/sys/vm/vm_object.c 92511 2002-03-17 18:37:37Z alc $
64 * $FreeBSD: head/sys/vm/vm_object.c 92654 2002-03-19 09:11:49Z jeff $
65 */
66
67/*
68 * Virtual memory object module.
69 */
70
71#include <sys/param.h>
72#include <sys/systm.h>

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

142vm_object_t kmem_object;
143static struct vm_object kernel_object_store;
144static struct vm_object kmem_object_store;
145extern int vm_pageout_page_count;
146
147static long object_collapses;
148static long object_bypasses;
149static int next_index;
65 */
66
67/*
68 * Virtual memory object module.
69 */
70
71#include <sys/param.h>
72#include <sys/systm.h>

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

142vm_object_t kmem_object;
143static struct vm_object kernel_object_store;
144static struct vm_object kmem_object_store;
145extern int vm_pageout_page_count;
146
147static long object_collapses;
148static long object_bypasses;
149static int next_index;
150static vm_zone_t obj_zone;
151static struct vm_zone obj_zone_store;
152static int object_hash_rand;
150static int object_hash_rand;
151static vm_zone_t obj_zone;
153#define VM_OBJECTS_INIT 256
152#define VM_OBJECTS_INIT 256
154static struct vm_object vm_objects_init[VM_OBJECTS_INIT];
155
153
154static void vm_object_zinit(void *mem, int size);
155
156#ifdef INVARIANTS
157static void vm_object_zdtor(void *mem, int size, void *arg);
158
159static void
160vm_object_zdtor(void *mem, int size, void *arg)
161{
162 vm_object_t object;
163
164 object = (vm_object_t)mem;
165 KASSERT(object->paging_in_progress == 0,
166 ("object %p paging_in_progress = %d",
167 object, object->paging_in_progress));
168 KASSERT(object->resident_page_count == 0,
169 ("object %p resident_page_count = %d",
170 object, object->resident_page_count));
171 KASSERT(object->shadow_count == 0,
172 ("object %p shadow_count = %d",
173 object, object->shadow_count));
174}
175#endif
176
177static void
178vm_object_zinit(void *mem, int size)
179{
180 vm_object_t object;
181
182 object = (vm_object_t)mem;
183
184 /* These are true for any object that has been freed */
185 object->paging_in_progress = 0;
186 object->resident_page_count = 0;
187 object->shadow_count = 0;
188}
189
156void
157_vm_object_allocate(objtype_t type, vm_size_t size, vm_object_t object)
158{
159 int incr;
160
161 GIANT_REQUIRED;
162
163 TAILQ_INIT(&object->memq);
164 TAILQ_INIT(&object->shadow_head);
165
166 object->type = type;
167 object->size = size;
168 object->ref_count = 1;
169 object->flags = 0;
170 if ((object->type == OBJT_DEFAULT) || (object->type == OBJT_SWAP))
171 vm_object_set_flag(object, OBJ_ONEMAPPING);
190void
191_vm_object_allocate(objtype_t type, vm_size_t size, vm_object_t object)
192{
193 int incr;
194
195 GIANT_REQUIRED;
196
197 TAILQ_INIT(&object->memq);
198 TAILQ_INIT(&object->shadow_head);
199
200 object->type = type;
201 object->size = size;
202 object->ref_count = 1;
203 object->flags = 0;
204 if ((object->type == OBJT_DEFAULT) || (object->type == OBJT_SWAP))
205 vm_object_set_flag(object, OBJ_ONEMAPPING);
172 object->paging_in_progress = 0;
173 object->resident_page_count = 0;
174 object->shadow_count = 0;
175 object->pg_color = next_index;
176 if (size > (PQ_L2_SIZE / 3 + PQ_PRIME1))
177 incr = PQ_L2_SIZE / 3 + PQ_PRIME1;
178 else
179 incr = size;
180 next_index = (next_index + incr) & PQ_L2_MASK;
181 object->handle = NULL;
182 object->backing_object = NULL;

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

211
212 kernel_object = &kernel_object_store;
213 _vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
214 kernel_object);
215
216 kmem_object = &kmem_object_store;
217 _vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
218 kmem_object);
206 object->pg_color = next_index;
207 if (size > (PQ_L2_SIZE / 3 + PQ_PRIME1))
208 incr = PQ_L2_SIZE / 3 + PQ_PRIME1;
209 else
210 incr = size;
211 next_index = (next_index + incr) & PQ_L2_MASK;
212 object->handle = NULL;
213 object->backing_object = NULL;

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

242
243 kernel_object = &kernel_object_store;
244 _vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
245 kernel_object);
246
247 kmem_object = &kmem_object_store;
248 _vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS),
249 kmem_object);
219
220 obj_zone = &obj_zone_store;
221 zbootinit(obj_zone, "VM OBJECT", sizeof (struct vm_object),
222 vm_objects_init, VM_OBJECTS_INIT);
250 obj_zone = uma_zcreate("VM OBJECT", sizeof (struct vm_object), NULL,
251#ifdef INVARIANTS
252 vm_object_zdtor,
253#else
254 NULL,
255#endif
256 vm_object_zinit, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
257 uma_prealloc(obj_zone, VM_OBJECTS_INIT);
223}
224
225void
226vm_object_init2(void)
227{
258}
259
260void
261vm_object_init2(void)
262{
228 zinitna(obj_zone, NULL, NULL, 0, 0, 0, 1);
229}
230
231void
232vm_object_set_flag(vm_object_t object, u_short bits)
233{
234 GIANT_REQUIRED;
235 object->flags |= bits;
236}

--- 1764 unchanged lines hidden ---
263}
264
265void
266vm_object_set_flag(vm_object_t object, u_short bits)
267{
268 GIANT_REQUIRED;
269 object->flags |= bits;
270}

--- 1764 unchanged lines hidden ---