vm_pager.c (76827) | vm_pager.c (79224) |
---|---|
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_pager.c 76827 2001-05-19 01:28:09Z alfred $ | 64 * $FreeBSD: head/sys/vm/vm_pager.c 79224 2001-07-04 16:20:28Z dillon $ |
65 */ 66 67/* 68 * Paging space routine stubs. Emulates a matchmaker-like interface 69 * for builtin pagers. 70 */ 71 72#include <sys/param.h> --- 167 unchanged lines hidden (view full) --- 240 * need to perform page-level validation (e.g. the device pager). 241 */ 242vm_object_t 243vm_pager_allocate(objtype_t type, void *handle, vm_ooffset_t size, 244 vm_prot_t prot, vm_ooffset_t off) 245{ 246 vm_object_t ret; 247 struct pagerops *ops; | 65 */ 66 67/* 68 * Paging space routine stubs. Emulates a matchmaker-like interface 69 * for builtin pagers. 70 */ 71 72#include <sys/param.h> --- 167 unchanged lines hidden (view full) --- 240 * need to perform page-level validation (e.g. the device pager). 241 */ 242vm_object_t 243vm_pager_allocate(objtype_t type, void *handle, vm_ooffset_t size, 244 vm_prot_t prot, vm_ooffset_t off) 245{ 246 vm_object_t ret; 247 struct pagerops *ops; |
248 int hadvmlock; | |
249 | 248 |
250 hadvmlock = mtx_owned(&vm_mtx); 251 if (!hadvmlock) 252 mtx_lock(&vm_mtx); | 249 GIANT_REQUIRED; 250 |
253 ops = pagertab[type]; 254 if (ops) 255 ret = (*ops->pgo_alloc) (handle, size, prot, off); 256 else 257 ret = NULL; | 251 ops = pagertab[type]; 252 if (ops) 253 ret = (*ops->pgo_alloc) (handle, size, prot, off); 254 else 255 ret = NULL; |
258 if (!hadvmlock) 259 mtx_unlock(&vm_mtx); | |
260 return (ret); 261} 262 263void 264vm_pager_deallocate(object) 265 vm_object_t object; 266{ | 256 return (ret); 257} 258 259void 260vm_pager_deallocate(object) 261 vm_object_t object; 262{ |
267 268 mtx_assert(&vm_mtx, MA_OWNED); | 263 GIANT_REQUIRED; |
269 (*pagertab[object->type]->pgo_dealloc) (object); 270} 271 272/* 273 * vm_pager_strategy: 274 * 275 * called with no specific spl 276 * Execute strategy routine directly to pager. --- 103 unchanged lines hidden (view full) --- 380 * to 1/2 nswbuf. getpbuf() decrements this counter in allocation and 381 * increments it on release, and blocks if the counter hits zero. A 382 * subsystem may initialize the counter to -1 to disable the feature, 383 * but it must still be sure to match up all uses of getpbuf() with 384 * relpbuf() using the same variable. 385 * 386 * NOTE: pfreecnt can be NULL, but this 'feature' will be removed 387 * relatively soon when the rest of the subsystems get smart about it. XXX | 264 (*pagertab[object->type]->pgo_dealloc) (object); 265} 266 267/* 268 * vm_pager_strategy: 269 * 270 * called with no specific spl 271 * Execute strategy routine directly to pager. --- 103 unchanged lines hidden (view full) --- 375 * to 1/2 nswbuf. getpbuf() decrements this counter in allocation and 376 * increments it on release, and blocks if the counter hits zero. A 377 * subsystem may initialize the counter to -1 to disable the feature, 378 * but it must still be sure to match up all uses of getpbuf() with 379 * relpbuf() using the same variable. 380 * 381 * NOTE: pfreecnt can be NULL, but this 'feature' will be removed 382 * relatively soon when the rest of the subsystems get smart about it. XXX |
388 * 389 * vm_mtx can be held or unheld | |
390 */ 391struct buf * 392getpbuf(pfreecnt) 393 int *pfreecnt; 394{ 395 int s; 396 struct buf *bp; | 383 */ 384struct buf * 385getpbuf(pfreecnt) 386 int *pfreecnt; 387{ 388 int s; 389 struct buf *bp; |
397 int hadvmlock; | |
398 399 s = splvm(); | 390 391 s = splvm(); |
400 hadvmlock = mtx_owned(&vm_mtx); 401 if (hadvmlock) 402 mtx_unlock(&vm_mtx); | 392 GIANT_REQUIRED; |
403 mtx_lock(&pbuf_mtx); 404 405 for (;;) { 406 if (pfreecnt) { 407 while (*pfreecnt == 0) { 408 msleep(pfreecnt, &pbuf_mtx, PVM, "wswbuf0", 0); 409 } 410 } --- 8 unchanged lines hidden (view full) --- 419 } 420 TAILQ_REMOVE(&bswlist, bp, b_freelist); 421 if (pfreecnt) 422 --*pfreecnt; 423 mtx_unlock(&pbuf_mtx); 424 splx(s); 425 426 initpbuf(bp); | 393 mtx_lock(&pbuf_mtx); 394 395 for (;;) { 396 if (pfreecnt) { 397 while (*pfreecnt == 0) { 398 msleep(pfreecnt, &pbuf_mtx, PVM, "wswbuf0", 0); 399 } 400 } --- 8 unchanged lines hidden (view full) --- 409 } 410 TAILQ_REMOVE(&bswlist, bp, b_freelist); 411 if (pfreecnt) 412 --*pfreecnt; 413 mtx_unlock(&pbuf_mtx); 414 splx(s); 415 416 initpbuf(bp); |
427 if (hadvmlock) 428 mtx_lock(&vm_mtx); | |
429 return bp; 430} 431 432/* 433 * allocate a physical buffer, if one is available. 434 * 435 * Note that there is no NULL hack here - all subsystems using this 436 * call understand how to use pfreecnt. --- 70 unchanged lines hidden --- | 417 return bp; 418} 419 420/* 421 * allocate a physical buffer, if one is available. 422 * 423 * Note that there is no NULL hack here - all subsystems using this 424 * call understand how to use pfreecnt. --- 70 unchanged lines hidden --- |