Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/vm_pager.c
Show First 20 Lines • Show All 177 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 |