FreeBSD virtual memory subsystem code
vm_pager.c File Reference
#include <sys/cdefs.h>
#include "opt_param.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
#include <sys/bio.h>
#include <sys/buf.h>
#include <sys/ucred.h>
#include <sys/malloc.h>
#include <sys/rwlock.h>
#include <sys/user.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_kern.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_pager.h>
#include <vm/vm_extern.h>
#include <vm/uma.h>
Include dependency graph for vm_pager.c:

Go to the source code of this file.

Macros

#define FIX(n)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int pbuf_init (void *, int, int)
 
static int pbuf_ctor (void *, int, void *, int)
 
static void pbuf_dtor (void *, int, void *)
 
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, vm_ooffset_t, struct ucred *)
 
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 void dead_pager_dealloc (vm_object_t)
 
static void dead_pager_getvp (vm_object_t, struct vnode **, bool *)
 
void vm_pager_init (void)
 
void vm_pager_bufferinit (void)
 
uma_zone_t pbuf_zsecond_create (const char *name, int max)
 
static void pbuf_prealloc (void *arg __unused)
 
 SYSINIT (pbuf, SI_SUB_KTHREAD_BUF, SI_ORDER_ANY, pbuf_prealloc, NULL)
 
vm_object_t vm_pager_allocate (objtype_t type, void *handle, vm_ooffset_t size, vm_prot_t prot, vm_ooffset_t off, struct ucred *cred)
 
void vm_pager_deallocate (vm_object_t object)
 
static void vm_pager_assert_in (vm_object_t object, vm_page_t *m, int count)
 
int vm_pager_get_pages (vm_object_t object, vm_page_t *m, int count, int *rbehind, int *rahead)
 
int vm_pager_get_pages_async (vm_object_t object, vm_page_t *m, int count, int *rbehind, int *rahead, pgo_getpages_iodone_t iodone, void *arg)
 
vm_object_t vm_pager_object_lookup (struct pagerlst *pg_list, void *handle)
 
int vm_pager_alloc_dyn_type (struct pagerops *ops, int base_type)
 
void vm_pager_free_dyn_type (objtype_t type)
 
void pbgetvp (struct vnode *vp, struct buf *bp)
 
void pbgetbo (struct bufobj *bo, struct buf *bp)
 
void pbrelvp (struct buf *bp)
 
void pbrelbo (struct buf *bp)
 
void vm_object_set_writeable_dirty (vm_object_t object)
 
bool vm_object_mightbedirty (vm_object_t object)
 
int vm_object_kvme_type (vm_object_t object, struct vnode **vpp)
 

Variables

uma_zone_t pbuf_zone
 
static const struct pagerops deadpagerops
 
const struct pagerops *pagertab[16] __read_mostly
 
static struct mtx pagertab_lock
 
static int nswbuf_max
 
static const char pbuf_wmesg [] = "pbufwait"
 

Macro Definition Documentation

◆ FIX

#define FIX (   n)
Value:
if (ops->pgo_##n == NULL) \
ops->pgo_##n = pagertab[base_type]->pgo_##n

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ dead_pager_alloc()

static vm_object_t dead_pager_alloc ( void *  handle,
vm_ooffset_t  size,
vm_prot_t  prot,
vm_ooffset_t  off,
struct ucred *  cred 
)
static

Definition at line 115 of file vm_pager.c.

◆ dead_pager_dealloc()

static void dead_pager_dealloc ( vm_object_t  object)
static

Definition at line 144 of file vm_pager.c.

◆ dead_pager_getpages()

static int dead_pager_getpages ( vm_object_t  obj,
vm_page_t *  ma,
int  count,
int *  rbehind,
int *  rahead 
)
static

Definition at line 107 of file vm_pager.c.

References VM_PAGER_FAIL.

◆ dead_pager_getvp()

static void dead_pager_getvp ( vm_object_t  object,
struct vnode **  vpp,
bool *  vp_heldp 
)
static

Definition at line 150 of file vm_pager.c.

◆ dead_pager_haspage()

static int dead_pager_haspage ( vm_object_t  object,
vm_pindex_t  pindex,
int *  prev,
int *  next 
)
static

Definition at line 133 of file vm_pager.c.

◆ dead_pager_putpages()

static void dead_pager_putpages ( vm_object_t  object,
vm_page_t *  m,
int  count,
int  flags,
int *  rtvals 
)
static

Definition at line 123 of file vm_pager.c.

References VM_PAGER_AGAIN.

◆ pbgetbo()

void pbgetbo ( struct bufobj *  bo,
struct buf *  bp 
)

Definition at line 538 of file vm_pager.c.

Referenced by vnode_pager_generic_getpages(), and vnode_pager_input_smlfs().

Here is the caller graph for this function:

◆ pbgetvp()

void pbgetvp ( struct vnode *  vp,
struct buf *  bp 
)

Definition at line 519 of file vm_pager.c.

◆ pbrelbo()

void pbrelbo ( struct buf *  bp)

Definition at line 569 of file vm_pager.c.

Referenced by vnode_pager_generic_getpages(), vnode_pager_generic_getpages_done_async(), and vnode_pager_input_smlfs().

Here is the caller graph for this function:

◆ pbrelvp()

void pbrelvp ( struct buf *  bp)

Definition at line 552 of file vm_pager.c.

◆ pbuf_ctor()

static int pbuf_ctor ( void *  mem,
int  size,
void *  arg,
int  flags 
)
static

Definition at line 453 of file vm_pager.c.

Referenced by pbuf_zsecond_create(), and vm_pager_bufferinit().

Here is the caller graph for this function:

◆ pbuf_dtor()

static void pbuf_dtor ( void *  mem,
int  size,
void *  arg 
)
static

Definition at line 476 of file vm_pager.c.

Referenced by pbuf_zsecond_create(), and vm_pager_bufferinit().

Here is the caller graph for this function:

◆ pbuf_init()

static int pbuf_init ( void *  mem,
int  size,
int  flags 
)
static

Definition at line 495 of file vm_pager.c.

References kva_alloc(), PBUF_PAGES, and pbuf_wmesg.

Referenced by vm_pager_bufferinit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pbuf_prealloc()

static void pbuf_prealloc ( void *arg  __unused)
static

Definition at line 244 of file vm_pager.c.

References nswbuf_max, pbuf_zone, and uma_prealloc().

Here is the call graph for this function:

◆ pbuf_zsecond_create()

uma_zone_t pbuf_zsecond_create ( const char *  name,
int  max 
)

Definition at line 214 of file vm_pager.c.

References nswbuf_max, pbuf_ctor(), pbuf_dtor(), pbuf_zone, uma_prealloc(), uma_zone_set_max(), and uma_zsecond_create().

Referenced by swap_pager_swap_init(), and vnode_pager_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SYSINIT()

SYSINIT ( pbuf  ,
SI_SUB_KTHREAD_BUF  ,
SI_ORDER_ANY  ,
pbuf_prealloc  ,
NULL   
)

◆ vm_object_kvme_type()

int vm_object_kvme_type ( vm_object_t  object,
struct vnode **  vpp 
)

Definition at line 611 of file vm_pager.c.

References vm_object::type, VM_OBJECT_ASSERT_LOCKED, and vm_object_vnode().

Referenced by vm_object_list_handler().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vm_object_mightbedirty()

bool vm_object_mightbedirty ( vm_object_t  object)

Definition at line 594 of file vm_pager.c.

References vm_object::type.

Referenced by vm_object_page_clean(), and vm_object_sync().

Here is the caller graph for this function:

◆ vm_object_set_writeable_dirty()

void vm_object_set_writeable_dirty ( vm_object_t  object)

Definition at line 582 of file vm_pager.c.

References vm_object::type.

Referenced by vm_fault_dirty(), vm_page_insert_radixdone(), and vm_page_replace_hold().

Here is the caller graph for this function:

◆ vm_pager_alloc_dyn_type()

int vm_pager_alloc_dyn_type ( struct pagerops ops,
int  base_type 
)

Definition at line 399 of file vm_pager.c.

References FIX, OBJT_DEFAULT, OBJT_FIRST_DYN, and pagertab_lock.

◆ vm_pager_allocate()

vm_object_t vm_pager_allocate ( objtype_t  type,
void *  handle,
vm_ooffset_t  size,
vm_prot_t  prot,
vm_ooffset_t  off,
struct ucred *  cred 
)

Definition at line 259 of file vm_pager.c.

References pagerops::pgo_alloc.

Referenced by vm_mmap_cdev(), and vm_mmap_vnode().

Here is the caller graph for this function:

◆ vm_pager_assert_in()

static void vm_pager_assert_in ( vm_object_t  object,
vm_page_t *  m,
int  count 
)
static

Definition at line 280 of file vm_pager.c.

References bogus_page, VM_OBJECT_ASSERT_PAGING, VM_OBJECT_ASSERT_UNLOCKED, and vm_page_assert_xbusied.

Referenced by vm_pager_get_pages(), and vm_pager_get_pages_async().

Here is the caller graph for this function:

◆ vm_pager_bufferinit()

void vm_pager_bufferinit ( void  )

Definition at line 201 of file vm_pager.c.

References nswbuf_max, pbuf_ctor(), pbuf_dtor(), pbuf_init(), PBUF_PAGES, pbuf_zone, UMA_ALIGN_CACHE, uma_zcreate(), UMA_ZONE_NOFREE, and uma_zone_set_max().

Here is the call graph for this function:

◆ vm_pager_deallocate()

void vm_pager_deallocate ( vm_object_t  object)

Definition at line 271 of file vm_pager.c.

References vm_object::type, and VM_OBJECT_ASSERT_WLOCKED.

Referenced by vm_object_terminate(), and vnode_destroy_vobject().

Here is the caller graph for this function:

◆ vm_pager_free_dyn_type()

void vm_pager_free_dyn_type ( objtype_t  type)

Definition at line 442 of file vm_pager.c.

References OBJT_FIRST_DYN, and pagertab_lock.

◆ vm_pager_get_pages()

int vm_pager_get_pages ( vm_object_t  object,
vm_page_t *  m,
int  count,
int *  rbehind,
int *  rahead 
)

Definition at line 319 of file vm_pager.c.

References vm_object::type, vm_page_relookup(), vm_page_zero_invalid(), vm_pager_assert_in(), and VM_PAGER_OK.

Referenced by vm_fault_getpages(), vm_page_grab_valid(), and vm_thread_swapin().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vm_pager_get_pages_async()

int vm_pager_get_pages_async ( vm_object_t  object,
vm_page_t *  m,
int  count,
int *  rbehind,
int *  rahead,
pgo_getpages_iodone_t  iodone,
void *  arg 
)

Definition at line 356 of file vm_pager.c.

References vm_object::type, and vm_pager_assert_in().

Here is the call graph for this function:

◆ vm_pager_init()

void vm_pager_init ( void  )

Definition at line 181 of file vm_pager.c.

References OBJT_FIRST_DYN, and pagertab_lock.

Referenced by vm_mem_init().

Here is the caller graph for this function:

◆ vm_pager_object_lookup()

vm_object_t vm_pager_object_lookup ( struct pagerlst *  pg_list,
void *  handle 
)

Definition at line 380 of file vm_pager.c.

References vm_object::flags, vm_object::handle, OBJ_DEAD, vm_object_reference_locked(), VM_OBJECT_WLOCK, and VM_OBJECT_WUNLOCK.

Referenced by cdev_pager_allocate(), cdev_pager_lookup(), phys_pager_allocate(), and swap_pager_alloc().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ __read_mostly

const struct pagerops* pagertab [16] __read_mostly
Initial value:
= {
}
const struct pagerops defaultpagerops
Definition: default_pager.c:74
const struct pagerops mgtdevicepagerops
Definition: device_pager.c:88
const struct pagerops devicepagerops
Definition: device_pager.c:78
const struct pagerops physpagerops
Definition: phys_pager.c:302
const struct pagerops sgpagerops
Definition: sg_pager.c:63
const struct pagerops swappagerops
Definition: swap_pager.c:442
@ OBJT_DEFAULT
Definition: vm.h:92
@ OBJT_SG
Definition: vm.h:98
@ OBJT_MGTDEVICE
Definition: vm.h:99
@ OBJT_VNODE
Definition: vm.h:94
@ OBJT_PHYS
Definition: vm.h:96
@ OBJT_DEAD
Definition: vm.h:97
@ OBJT_SWAP
Definition: vm.h:93
@ OBJT_DEVICE
Definition: vm.h:95
static const struct pagerops deadpagerops
Definition: vm_pager.c:158
const struct pagerops vnodepagerops
Definition: vnode_pager.c:111

Definition at line 168 of file vm_pager.c.

◆ deadpagerops

const struct pagerops deadpagerops
static
Initial value:
= {
.pgo_kvme_type = KVME_TYPE_DEAD,
.pgo_alloc = dead_pager_alloc,
.pgo_dealloc = dead_pager_dealloc,
.pgo_getpages = dead_pager_getpages,
.pgo_putpages = dead_pager_putpages,
.pgo_haspage = dead_pager_haspage,
.pgo_getvp = dead_pager_getvp,
}
static boolean_t dead_pager_haspage(vm_object_t, vm_pindex_t, int *, int *)
Definition: vm_pager.c:133
static vm_object_t dead_pager_alloc(void *, vm_ooffset_t, vm_prot_t, vm_ooffset_t, struct ucred *)
Definition: vm_pager.c:115
static void dead_pager_getvp(vm_object_t, struct vnode **, bool *)
Definition: vm_pager.c:150
static void dead_pager_dealloc(vm_object_t)
Definition: vm_pager.c:144
static int dead_pager_getpages(vm_object_t, vm_page_t *, int, int *, int *)
Definition: vm_pager.c:107
static void dead_pager_putpages(vm_object_t, vm_page_t *, int, int, int *)
Definition: vm_pager.c:123

Definition at line 158 of file vm_pager.c.

◆ nswbuf_max

int nswbuf_max
static

Definition at line 198 of file vm_pager.c.

Referenced by pbuf_prealloc(), pbuf_zsecond_create(), and vm_pager_bufferinit().

◆ pagertab_lock

struct mtx pagertab_lock
static

Definition at line 178 of file vm_pager.c.

Referenced by vm_pager_alloc_dyn_type(), vm_pager_free_dyn_type(), and vm_pager_init().

◆ pbuf_wmesg

const char pbuf_wmesg[] = "pbufwait"
static

Definition at line 492 of file vm_pager.c.

Referenced by pbuf_init().

◆ pbuf_zone

uma_zone_t pbuf_zone

Definition at line 93 of file vm_pager.c.

Referenced by pbuf_prealloc(), pbuf_zsecond_create(), and vm_pager_bufferinit().