Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_pager.c
Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | |||||
#include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
#include <vm/uma.h> | #include <vm/uma.h> | ||||
uma_zone_t pbuf_zone; | uma_zone_t pbuf_zone; | ||||
static int pbuf_init(void *, int, int); | static int pbuf_init(void *, int, int); | ||||
static int pbuf_ctor(void *, int, void *, int); | static int pbuf_ctor(void *, int, void *, int); | ||||
static void pbuf_dtor(void *, int, void *); | static void pbuf_dtor(void *, int, void *); | ||||
/* | |||||
* Number of pages that pbuf buffer can store in b_pages. | |||||
* It is +1 to allow for unaligned data buffer of maxphys size. | |||||
*/ | |||||
#define PBUF_PAGES (atop(maxphys) + 1) | |||||
static int dead_pager_getpages(vm_object_t, vm_page_t *, int, int *, int *); | static int dead_pager_getpages(vm_object_t, vm_page_t *, int, int *, int *); | ||||
static vm_object_t dead_pager_alloc(void *, vm_ooffset_t, vm_prot_t, | static vm_object_t dead_pager_alloc(void *, vm_ooffset_t, vm_prot_t, | ||||
vm_ooffset_t, struct ucred *); | vm_ooffset_t, struct ucred *); | ||||
static void dead_pager_putpages(vm_object_t, vm_page_t *, int, int, int *); | static void dead_pager_putpages(vm_object_t, vm_page_t *, int, int, int *); | ||||
static boolean_t dead_pager_haspage(vm_object_t, vm_pindex_t, int *, int *); | static boolean_t dead_pager_haspage(vm_object_t, vm_pindex_t, int *, int *); | ||||
static void dead_pager_dealloc(vm_object_t); | static void dead_pager_dealloc(vm_object_t); | ||||
static int | static int | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
static int nswbuf_max; | static int nswbuf_max; | ||||
void | void | ||||
vm_pager_bufferinit(void) | vm_pager_bufferinit(void) | ||||
{ | { | ||||
/* Main zone for paging bufs. */ | /* Main zone for paging bufs. */ | ||||
pbuf_zone = uma_zcreate("pbuf", sizeof(struct buf), | pbuf_zone = uma_zcreate("pbuf", | ||||
sizeof(struct buf) + PBUF_PAGES * sizeof(vm_page_t), | |||||
pbuf_ctor, pbuf_dtor, pbuf_init, NULL, UMA_ALIGN_CACHE, | pbuf_ctor, pbuf_dtor, pbuf_init, NULL, UMA_ALIGN_CACHE, | ||||
UMA_ZONE_NOFREE); | UMA_ZONE_NOFREE); | ||||
/* Few systems may still use this zone directly, so it needs a limit. */ | /* Few systems may still use this zone directly, so it needs a limit. */ | ||||
nswbuf_max += uma_zone_set_max(pbuf_zone, NSWBUF_MIN); | nswbuf_max += uma_zone_set_max(pbuf_zone, NSWBUF_MIN); | ||||
} | } | ||||
uma_zone_t | uma_zone_t | ||||
pbuf_zsecond_create(const char *name, int max) | pbuf_zsecond_create(const char *name, int max) | ||||
▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | pbuf_ctor(void *mem, int size, void *arg, int flags) | ||||
bp->b_bufobj = NULL; | bp->b_bufobj = NULL; | ||||
/* copied from initpbuf() */ | /* copied from initpbuf() */ | ||||
bp->b_rcred = NOCRED; | bp->b_rcred = NOCRED; | ||||
bp->b_wcred = NOCRED; | bp->b_wcred = NOCRED; | ||||
bp->b_qindex = 0; /* On no queue (QUEUE_NONE) */ | bp->b_qindex = 0; /* On no queue (QUEUE_NONE) */ | ||||
bp->b_data = bp->b_kvabase; | bp->b_data = bp->b_kvabase; | ||||
bp->b_xflags = 0; | bp->b_xflags = 0; | ||||
bp->b_flags = 0; | bp->b_flags = B_MAXPHYS; | ||||
bp->b_ioflags = 0; | bp->b_ioflags = 0; | ||||
bp->b_iodone = NULL; | bp->b_iodone = NULL; | ||||
bp->b_error = 0; | bp->b_error = 0; | ||||
BUF_LOCK(bp, LK_EXCLUSIVE, NULL); | BUF_LOCK(bp, LK_EXCLUSIVE, NULL); | ||||
return (0); | return (0); | ||||
} | } | ||||
Show All 14 Lines | pbuf_dtor(void *mem, int size, void *arg) | ||||
BUF_UNLOCK(bp); | BUF_UNLOCK(bp); | ||||
} | } | ||||
static int | static int | ||||
pbuf_init(void *mem, int size, int flags) | pbuf_init(void *mem, int size, int flags) | ||||
{ | { | ||||
struct buf *bp = mem; | struct buf *bp = mem; | ||||
bp->b_kvabase = (void *)kva_alloc(MAXPHYS); | bp->b_kvabase = (void *)kva_alloc(ptoa(PBUF_PAGES)); | ||||
if (bp->b_kvabase == NULL) | if (bp->b_kvabase == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
bp->b_kvasize = MAXPHYS; | bp->b_kvasize = ptoa(PBUF_PAGES); | ||||
BUF_LOCKINIT(bp); | BUF_LOCKINIT(bp); | ||||
LIST_INIT(&bp->b_dep); | LIST_INIT(&bp->b_dep); | ||||
bp->b_rcred = bp->b_wcred = NOCRED; | bp->b_rcred = bp->b_wcred = NOCRED; | ||||
bp->b_xflags = 0; | bp->b_xflags = 0; | ||||
return (0); | return (0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |