FreeBSD virtual memory subsystem code
vm_glue.c File Reference
#include <sys/cdefs.h>
#include "opt_vm.h"
#include "opt_kstack_pages.h"
#include "opt_kstack_max_pages.h"
#include "opt_kstack_usage_prof.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/asan.h>
#include <sys/domainset.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/msan.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/racct.h>
#include <sys/refcount.h>
#include <sys/resourcevar.h>
#include <sys/rwlock.h>
#include <sys/sched.h>
#include <sys/sf_buf.h>
#include <sys/shm.h>
#include <sys/smp.h>
#include <sys/vmmeter.h>
#include <sys/vmem.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/unistd.h>
#include <vm/uma.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <vm/vm_domainset.h>
#include <vm/vm_map.h>
#include <vm/vm_page.h>
#include <vm/vm_pageout.h>
#include <vm/vm_object.h>
#include <vm/vm_kern.h>
#include <vm/vm_extern.h>
#include <vm/vm_pager.h>
#include <vm/swap_pager.h>
#include <machine/cpu.h>
Include dependency graph for vm_glue.c:

Go to the source code of this file.

Functions

 __FBSDID ("$FreeBSD$")
 
int kernacc (void *addr, int len, int rw)
 
int useracc (void *addr, int len, int rw)
 
int vslock (void *addr, size_t len)
 
void vsunlock (void *addr, size_t len)
 
static vm_page_t vm_imgact_hold_page (vm_object_t object, vm_ooffset_t offset)
 
struct sf_buf * vm_imgact_map_page (vm_object_t object, vm_ooffset_t offset)
 
void vm_imgact_unmap_page (struct sf_buf *sf)
 
void vm_sync_icache (vm_map_t map, vm_offset_t va, vm_offset_t sz)
 
static int sysctl_kstack_cache_size (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_vm, OID_AUTO, kstack_cache_size, CTLTYPE_INT|CTLFLAG_MPSAFE|CTLFLAG_RW, &kstack_cache_size, 0, sysctl_kstack_cache_size, "IU", "Maximum number of cached kernel stacks")
 
static vm_offset_t vm_thread_stack_create (struct domainset *ds, int pages)
 
static void vm_thread_stack_dispose (vm_offset_t ks, int pages)
 
int vm_thread_new (struct thread *td, int pages)
 
void vm_thread_dispose (struct thread *td)
 
void vm_thread_stack_back (struct domainset *ds, vm_offset_t ks, vm_page_t ma[], int npages, int req_class)
 
static int kstack_import (void *arg, void **store, int cnt, int domain, int flags)
 
static void kstack_release (void *arg, void **store, int cnt)
 
static void kstack_cache_init (void *null)
 
 SYSINIT (vm_kstacks, SI_SUB_KMEM, SI_ORDER_ANY, kstack_cache_init, NULL)
 
int vm_forkproc (struct thread *td, struct proc *p2, struct thread *td2, struct vmspace *vm2, int flags)
 
void vm_waitproc (struct proc *p)
 
void kick_proc0 (void)
 

Variables

vm_object_t kstack_object
 
static uma_zone_t kstack_cache
 
static int kstack_cache_size
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ kernacc()

int kernacc ( void *  addr,
int  len,
int  rw 
)

Definition at line 121 of file vm_glue.c.

References kernel_map, vm_map_check_protection(), vm_map_lock_read, vm_map_max(), vm_map_unlock_read, and VM_PROT_ALL.

Here is the call graph for this function:

◆ kick_proc0()

void kick_proc0 ( void  )

Definition at line 591 of file vm_glue.c.

◆ kstack_cache_init()

static void kstack_cache_init ( void *  null)
static

◆ kstack_import()

static int kstack_import ( void *  arg,
void **  store,
int  cnt,
int  domain,
int  flags 
)
static

Definition at line 433 of file vm_glue.c.

References UMA_ANYDOMAIN, and vm_thread_stack_create().

Referenced by kstack_cache_init().

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

◆ kstack_release()

static void kstack_release ( void *  arg,
void **  store,
int  cnt 
)
static

Definition at line 452 of file vm_glue.c.

References vm_thread_stack_dispose().

Referenced by kstack_cache_init().

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

◆ sysctl_kstack_cache_size()

static int sysctl_kstack_cache_size ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 274 of file vm_glue.c.

References kstack_cache, kstack_cache_size, and uma_zone_set_maxcache().

Here is the call graph for this function:

◆ SYSCTL_PROC()

SYSCTL_PROC ( _vm  ,
OID_AUTO  ,
kstack_cache_size  ,
CTLTYPE_INT|CTLFLAG_MPSAFE|  CTLFLAG_RW,
kstack_cache_size,
,
sysctl_kstack_cache_size  ,
"IU"  ,
"Maximum number of cached kernel stacks"   
)

◆ SYSINIT()

SYSINIT ( vm_kstacks  ,
SI_SUB_KMEM  ,
SI_ORDER_ANY  ,
kstack_cache_init  ,
NULL   
)

◆ useracc()

int useracc ( void *  addr,
int  len,
int  rw 
)

Definition at line 153 of file vm_glue.c.

References vm_map_check_protection(), vm_map_lock_read, vm_map_max(), vm_map_unlock_read, and VM_PROT_ALL.

Here is the call graph for this function:

◆ vm_forkproc()

int vm_forkproc ( struct thread *  td,
struct proc *  p2,
struct thread *  td2,
struct vmspace vm2,
int  flags 
)

Definition at line 532 of file vm_glue.c.

References vm_wait_doms(), and vmspace_unshare().

Here is the call graph for this function:

◆ vm_imgact_hold_page()

static vm_page_t vm_imgact_hold_page ( vm_object_t  object,
vm_ooffset_t  offset 
)
static

Definition at line 221 of file vm_glue.c.

References OFF_TO_IDX, VM_ALLOC_NOBUSY, VM_ALLOC_NORMAL, VM_ALLOC_WIRED, and vm_page_grab_valid_unlocked().

Referenced by vm_imgact_map_page().

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

◆ vm_imgact_map_page()

struct sf_buf * vm_imgact_map_page ( vm_object_t  object,
vm_ooffset_t  offset 
)

Definition at line 237 of file vm_glue.c.

References vm_imgact_hold_page().

Here is the call graph for this function:

◆ vm_imgact_unmap_page()

void vm_imgact_unmap_page ( struct sf_buf *  sf)

Definition at line 252 of file vm_glue.c.

References PQ_ACTIVE, and vm_page_unwire().

Here is the call graph for this function:

◆ vm_sync_icache()

void vm_sync_icache ( vm_map_t  map,
vm_offset_t  va,
vm_offset_t  sz 
)

Definition at line 263 of file vm_glue.c.

References vm_map::pmap, and pmap_sync_icache().

Here is the call graph for this function:

◆ vm_thread_dispose()

void vm_thread_dispose ( struct thread *  td)

Definition at line 387 of file vm_glue.c.

References kstack_cache, uma_zfree(), and vm_thread_stack_dispose().

Here is the call graph for this function:

◆ vm_thread_new()

int vm_thread_new ( struct thread *  td,
int  pages 
)

Definition at line 352 of file vm_glue.c.

References kstack_cache, KSTACK_MAX_PAGES, uma_zalloc(), and vm_thread_stack_create().

Here is the call graph for this function:

◆ vm_thread_stack_back()

void vm_thread_stack_back ( struct domainset *  ds,
vm_offset_t  ks,
vm_page_t  ma[],
int  npages,
int  req_class 
)

Definition at line 408 of file vm_glue.c.

References vm_object::domain, kstack_object, VM_ALLOC_WAITFAIL, VM_ALLOC_WIRED, vm_ndomains, VM_OBJECT_WLOCK, VM_OBJECT_WUNLOCK, and vm_page_grab_pages().

Referenced by vm_thread_stack_create(), and vm_thread_swapin().

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

◆ vm_thread_stack_create()

static vm_offset_t vm_thread_stack_create ( struct domainset *  ds,
int  pages 
)
static

Definition at line 292 of file vm_glue.c.

References KSTACK_MAX_PAGES, kva_alloc(), pmap_qenter(), pmap_qremove(), VM_ALLOC_NORMAL, vm_page_valid(), and vm_thread_stack_back().

Referenced by kstack_import(), and vm_thread_new().

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

◆ vm_thread_stack_dispose()

static void vm_thread_stack_dispose ( vm_offset_t  ks,
int  pages 
)
static

Definition at line 324 of file vm_glue.c.

References kstack_object, kva_free(), pmap_qremove(), VM_OBJECT_WLOCK, VM_OBJECT_WUNLOCK, vm_page_free(), vm_page_lookup(), vm_page_unwire_noq(), and vm_page_xbusy_claim.

Referenced by kstack_release(), and vm_thread_dispose().

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

◆ vm_waitproc()

void vm_waitproc ( struct proc *  p)

Definition at line 583 of file vm_glue.c.

References vmspace_exitfree().

Here is the call graph for this function:

◆ vslock()

int vslock ( void *  addr,
size_t  len 
)

Definition at line 175 of file vm_glue.c.

References KERN_SUCCESS, vm_map_wire(), VM_MAP_WIRE_NOHOLES, VM_MAP_WIRE_SYSTEM, and vm_page_max_user_wired.

Here is the call graph for this function:

◆ vsunlock()

void vsunlock ( void *  addr,
size_t  len 
)

Definition at line 204 of file vm_glue.c.

References vm_map_unwire(), VM_MAP_WIRE_NOHOLES, and VM_MAP_WIRE_SYSTEM.

Here is the call graph for this function:

Variable Documentation

◆ kstack_cache

uma_zone_t kstack_cache
static

◆ kstack_cache_size

int kstack_cache_size
static

Definition at line 271 of file vm_glue.c.

Referenced by kstack_cache_init(), and sysctl_kstack_cache_size().

◆ kstack_object