FreeBSD kernel kern code
kern_proc.c File Reference
#include <sys/cdefs.h>
#include "opt_compat.h"
#include "opt_ddb.h"
#include "opt_kdtrace.h"
#include "opt_ktrace.h"
#include "opt_kstack_pages.h"
#include "opt_stack.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/elf.h>
#include <sys/exec.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/loginclass.h>
#include <sys/malloc.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/refcount.h>
#include <sys/resourcevar.h>
#include <sys/sbuf.h>
#include <sys/sysent.h>
#include <sys/sched.h>
#include <sys/smp.h>
#include <sys/stack.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <sys/filedesc.h>
#include <sys/tty.h>
#include <sys/signalvar.h>
#include <sys/sdt.h>
#include <sys/sx.h>
#include <sys/user.h>
#include <sys/jail.h>
#include <sys/vnode.h>
#include <sys/eventhandler.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_extern.h>
#include <vm/pmap.h>
#include <vm/vm_map.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/uma.h>
Include dependency graph for kern_proc.c:

Go to the source code of this file.

Macros

#define PROC_AUXV_MAX   256 /* Safety limit on auxv size. */
 
#define GET_PS_STRINGS_CHUNK_SZ   256 /* Chunk size (bytes) for ps_strings operations. */
 

Enumerations

enum  proc_vector_type { PROC_ARG, PROC_ENV, PROC_AUX }
 

Functions

 __FBSDID ("$BSDSUniX$")
 
 SDT_PROVIDER_DEFINE (proc)
 
 SDT_PROBE_DEFINE4 (proc, kernel, ctor, entry,"struct proc *","int","void *","int")
 
 SDT_PROBE_DEFINE4 (proc, kernel, ctor, return,"struct proc *","int","void *","int")
 
 SDT_PROBE_DEFINE4 (proc, kernel, dtor, entry,"struct proc *","int","void *","struct thread *")
 
 SDT_PROBE_DEFINE3 (proc, kernel, dtor, return,"struct proc *","int","void *")
 
 SDT_PROBE_DEFINE3 (proc, kernel, init, entry,"struct proc *","int","int")
 
 SDT_PROBE_DEFINE3 (proc, kernel, init, return,"struct proc *","int","int")
 
 MALLOC_DEFINE (M_PGRP,"pgrp","process group header")
 
 MALLOC_DEFINE (M_SESSION,"session","session header")
 
static MALLOC_DEFINE (M_PROC,"proc","Proc structures")
 
 MALLOC_DEFINE (M_SUBPROC,"subproc","Proc sub-structures")
 
static void doenterpgrp (struct proc *, struct pgrp *)
 
static void orphanpg (struct pgrp *pg)
 
static void fill_kinfo_aggregate (struct proc *p, struct kinfo_proc *kp)
 
static void fill_kinfo_proc_only (struct proc *p, struct kinfo_proc *kp)
 
static void fill_kinfo_thread (struct thread *td, struct kinfo_proc *kp, int preferthread)
 
static void pgadjustjobc (struct pgrp *pgrp, int entering)
 
static void pgdelete (struct pgrp *)
 
static int proc_ctor (void *mem, int size, void *arg, int flags)
 
static void proc_dtor (void *mem, int size, void *arg)
 
static int proc_init (void *mem, int size, int flags)
 
static void proc_fini (void *mem, int size)
 
static void pargs_free (struct pargs *pa)
 
static struct proc * zpfind_locked (pid_t pid)
 
 SYSCTL_INT (_kern, OID_AUTO, kstack_pages, CTLFLAG_RD,&kstack_pages, 0,"Kernel stack size in pages")
 
 SYSCTL_INT (_kern, OID_AUTO, proc_vmmap_skip_resident_count, CTLFLAG_RW,&vmmap_skip_res_cnt, 0,"Skip calculation of the pages resident count in kern.proc.vmmap")
 
 CTASSERT (sizeof(struct kinfo_proc)==KINFO_PROC_SIZE)
 
void procinit ()
 
int inferior (struct proc *p)
 
struct proc * pfind_locked (pid_t pid)
 
struct proc * pfind (pid_t pid)
 
static struct proc * pfind_tid_locked (pid_t tid)
 
struct pgrp * pgfind (pid_t pgid)
 
int pget (pid_t pid, int flags, struct proc **pp)
 
int enterpgrp (struct proc *p, pid_t pgid, struct pgrp *pgrp, struct session *sess)
 
int enterthispgrp (struct proc *p, struct pgrp *pgrp)
 
int leavepgrp (struct proc *p)
 
void fixjobc (struct proc *p, struct pgrp *pgrp, int entering)
 
void sess_hold (struct session *s)
 
void sess_release (struct session *s)
 
void fill_kinfo_proc (struct proc *p, struct kinfo_proc *kp)
 
struct pstats * pstats_alloc (void)
 
void pstats_fork (struct pstats *src, struct pstats *dst)
 
void pstats_free (struct pstats *ps)
 
struct proc * zpfind (pid_t pid)
 
int kern_proc_out (struct proc *p, struct sbuf *sb, int flags)
 
static int sysctl_out_proc (struct proc *p, struct sysctl_req *req, int flags, int doingzomb)
 
static int sysctl_kern_proc (SYSCTL_HANDLER_ARGS)
 
struct pargs * pargs_alloc (int len)
 
void pargs_hold (struct pargs *pa)
 
void pargs_drop (struct pargs *pa)
 
static int proc_read_mem (struct thread *td, struct proc *p, vm_offset_t offset, void *buf, size_t len)
 
static int proc_read_string (struct thread *td, struct proc *p, const char *sptr, char *buf, size_t len)
 
static int get_proc_vector (struct thread *td, struct proc *p, char ***proc_vectorp, size_t *vsizep, enum proc_vector_type type)
 
static int get_ps_strings (struct thread *td, struct proc *p, struct sbuf *sb, enum proc_vector_type type)
 
int proc_getargv (struct thread *td, struct proc *p, struct sbuf *sb)
 
int proc_getenvv (struct thread *td, struct proc *p, struct sbuf *sb)
 
int proc_getauxv (struct thread *td, struct proc *p, struct sbuf *sb)
 
static int sysctl_kern_proc_args (SYSCTL_HANDLER_ARGS)
 
static int sysctl_kern_proc_env (SYSCTL_HANDLER_ARGS)
 
static int sysctl_kern_proc_auxv (SYSCTL_HANDLER_ARGS)
 
static int sysctl_kern_proc_pathname (SYSCTL_HANDLER_ARGS)
 
static int sysctl_kern_proc_sv_name (SYSCTL_HANDLER_ARGS)
 
int kern_proc_vmmap_out (struct proc *p, struct sbuf *sb)
 
static int sysctl_kern_proc_vmmap (SYSCTL_HANDLER_ARGS)
 
static int sysctl_kern_proc_groups (SYSCTL_HANDLER_ARGS)
 
static int sysctl_kern_proc_rlimit (SYSCTL_HANDLER_ARGS)
 
static int sysctl_kern_proc_ps_strings (SYSCTL_HANDLER_ARGS)
 
static int sysctl_kern_proc_umask (SYSCTL_HANDLER_ARGS)
 
static int sysctl_kern_proc_osrel (SYSCTL_HANDLER_ARGS)
 
static int sysctl_kern_proc_sigtramp (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_NODE (_kern, KERN_PROC, proc, CTLFLAG_RD, 0,"Process table")
 
 SYSCTL_PROC (_kern_proc, KERN_PROC_ALL, all, CTLFLAG_RD|CTLTYPE_STRUCT|CTLFLAG_MPSAFE, 0, 0, sysctl_kern_proc,"S,proc","Return entire process table")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_GID, gid, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_PGRP, pgrp, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_RGID, rgid, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_SESSION, sid, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_TTY, tty, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_UID, uid, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_RUID, ruid, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_PID, pid, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_PROC, proc, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Return process table, no threads")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_ARGS, args, CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE, sysctl_kern_proc_args,"Process argument list")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_ENV, env, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_env,"Process environment")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_AUXV, auxv, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_auxv,"Process ELF auxiliary vector")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_PATHNAME, pathname, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_pathname,"Process executable path")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_SV_NAME, sv_name, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_sv_name,"Process syscall vector name (ABI type)")
 
static SYSCTL_NODE (_kern_proc,(KERN_PROC_GID|KERN_PROC_INC_THREAD), gid_td, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc,(KERN_PROC_PGRP|KERN_PROC_INC_THREAD), pgrp_td, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc,(KERN_PROC_RGID|KERN_PROC_INC_THREAD), rgid_td, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc,(KERN_PROC_SESSION|KERN_PROC_INC_THREAD), sid_td, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc,(KERN_PROC_TTY|KERN_PROC_INC_THREAD), tty_td, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc,(KERN_PROC_UID|KERN_PROC_INC_THREAD), uid_td, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc,(KERN_PROC_RUID|KERN_PROC_INC_THREAD), ruid_td, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc,(KERN_PROC_PID|KERN_PROC_INC_THREAD), pid_td, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Process table")
 
static SYSCTL_NODE (_kern_proc,(KERN_PROC_PROC|KERN_PROC_INC_THREAD), proc_td, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc,"Return process table, no threads")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_VMMAP, vmmap, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_vmmap,"Process vm map entries")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_GROUPS, groups, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_groups,"Process groups")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_RLIMIT, rlimit, CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE, sysctl_kern_proc_rlimit,"Process resource limits")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_PS_STRINGS, ps_strings, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_ps_strings,"Process ps_strings location")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_UMASK, umask, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_umask,"Process umask")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_OSREL, osrel, CTLFLAG_RW|CTLFLAG_ANYBODY|CTLFLAG_MPSAFE, sysctl_kern_proc_osrel,"Process binary osreldate")
 
static SYSCTL_NODE (_kern_proc, KERN_PROC_SIGTRAMP, sigtramp, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc_sigtramp,"Process signal trampoline location")
 

Variables

struct pidhashhead * pidhashtbl
 
u_long pidhash
 
struct pgrphashhead * pgrphashtbl
 
u_long pgrphash
 
struct proclist allproc
 
struct proclist zombproc
 
struct sx allproc_lock
 
struct sx proctree_lock
 
struct mtx ppeers_lock
 
uma_zone_t proc_zone
 
int kstack_pages = KSTACK_PAGES
 
static int vmmap_skip_res_cnt = 0
 

Macro Definition Documentation

#define GET_PS_STRINGS_CHUNK_SZ   256 /* Chunk size (bytes) for ps_strings operations. */
#define PROC_AUXV_MAX   256 /* Safety limit on auxv size. */

Definition at line 1520 of file kern_proc.c.

Referenced by get_proc_vector().

Enumeration Type Documentation

Enumerator
PROC_ARG 
PROC_ENV 
PROC_AUX 

Definition at line 1522 of file kern_proc.c.

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
CTASSERT ( sizeof(struct kinfo_proc)  = =KINFO_PROC_SIZE)
static void doenterpgrp ( struct proc *  p,
struct pgrp *  pgrp 
)
static

Definition at line 515 of file kern_proc.c.

References fixjobc(), pgdelete(), and proctree_lock.

Referenced by enterpgrp(), and enterthispgrp().

Here is the call graph for this function:

Here is the caller graph for this function:

int enterpgrp ( struct proc *  p,
pid_t  pgid,
struct pgrp *  pgrp,
struct session *  sess 
)

Definition at line 423 of file kern_proc.c.

References doenterpgrp(), mtx_init(), pgfind(), proctree_lock, and sess_hold().

Referenced by sys_setpgid(), and sys_setsid().

Here is the call graph for this function:

Here is the caller graph for this function:

int enterthispgrp ( struct proc *  p,
struct pgrp *  pgrp 
)

Definition at line 488 of file kern_proc.c.

References doenterpgrp(), and proctree_lock.

Referenced by sys_setpgid().

Here is the call graph for this function:

Here is the caller graph for this function:

static void fill_kinfo_aggregate ( struct proc *  p,
struct kinfo_proc *  kp 
)
static

Definition at line 766 of file kern_proc.c.

References sched_pctcpu().

Referenced by fill_kinfo_proc().

Here is the call graph for this function:

Here is the caller graph for this function:

void fill_kinfo_proc ( struct proc *  p,
struct kinfo_proc *  kp 
)

Definition at line 1019 of file kern_proc.c.

References fill_kinfo_aggregate(), fill_kinfo_proc_only(), and fill_kinfo_thread().

Referenced by kern_proc_out().

Here is the call graph for this function:

Here is the caller graph for this function:

static void fill_kinfo_proc_only ( struct proc *  p,
struct kinfo_proc *  kp 
)
static

Definition at line 788 of file kern_proc.c.

References boottime, calccru(), calcru(), cputick2usec(), hz, jailed(), rufetch(), ticks, timevaladd(), and tty_udev().

Referenced by fill_kinfo_proc().

Here is the call graph for this function:

Here is the caller graph for this function:

static void fill_kinfo_thread ( struct thread *  td,
struct kinfo_proc *  kp,
int  preferthread 
)
static

Definition at line 935 of file kern_proc.c.

References cputick2usec(), hz, rufetchtd(), sched_pctcpu(), and ticks.

Referenced by fill_kinfo_proc(), and kern_proc_out().

Here is the call graph for this function:

Here is the caller graph for this function:

void fixjobc ( struct proc *  p,
struct pgrp *  pgrp,
int  entering 
)

Definition at line 637 of file kern_proc.c.

References pgadjustjobc(), and proctree_lock.

Referenced by doenterpgrp(), and exit1().

Here is the call graph for this function:

Here is the caller graph for this function:

static int get_proc_vector ( struct thread *  td,
struct proc *  p,
char ***  proc_vectorp,
size_t *  vsizep,
enum proc_vector_type  type 
)
static

Definition at line 1603 of file kern_proc.c.

References free(), malloc(), PROC_ARG, PROC_AUX, PROC_AUXV_MAX, PROC_ENV, and proc_read_mem().

Referenced by get_ps_strings(), and proc_getauxv().

Here is the call graph for this function:

Here is the caller graph for this function:

static int get_ps_strings ( struct thread *  td,
struct proc *  p,
struct sbuf *  sb,
enum proc_vector_type  type 
)
static

Definition at line 1696 of file kern_proc.c.

References free(), get_proc_vector(), GET_PS_STRINGS_CHUNK_SZ, proc_read_string(), and sbuf_bcat().

Referenced by proc_getargv(), and proc_getenvv().

Here is the call graph for this function:

Here is the caller graph for this function:

int inferior ( struct proc *  p)

Definition at line 266 of file kern_proc.c.

References proc_realparent(), and proctree_lock.

Referenced by sys_setpgid().

Here is the call graph for this function:

Here is the caller graph for this function:

int kern_proc_out ( struct proc *  p,
struct sbuf *  sb,
int  flags 
)

Definition at line 1189 of file kern_proc.c.

References fill_kinfo_proc(), fill_kinfo_thread(), and sbuf_bcat().

Referenced by note_procstat_proc(), and sysctl_out_proc().

Here is the call graph for this function:

Here is the caller graph for this function:

int kern_proc_vmmap_out ( struct proc *  p,
struct sbuf *  sb 
)

Definition at line 2148 of file kern_proc.c.

References free(), malloc(), sbuf_bcat(), vmmap_skip_res_cnt, vn_fullpath(), vntype_to_kinfo(), vput(), and vref().

Referenced by note_procstat_vmmap(), and sysctl_kern_proc_vmmap().

Here is the call graph for this function:

Here is the caller graph for this function:

int leavepgrp ( struct proc *  p)

Definition at line 554 of file kern_proc.c.

References pgdelete(), and proctree_lock.

Referenced by proc_reap().

Here is the call graph for this function:

Here is the caller graph for this function:

MALLOC_DEFINE ( M_PGRP  ,
"pgrp"  ,
"process group header"   
)
MALLOC_DEFINE ( M_SESSION  ,
"session"  ,
"session header"   
)
static MALLOC_DEFINE ( M_PROC  ,
"proc"  ,
"Proc structures"   
)
static
MALLOC_DEFINE ( M_SUBPROC  ,
"subproc"  ,
"Proc sub-structures"   
)
static void orphanpg ( struct pgrp *  pg)
static

Definition at line 685 of file kern_proc.c.

References kern_psignal().

Referenced by pgadjustjobc().

Here is the call graph for this function:

Here is the caller graph for this function:

struct pargs* pargs_alloc ( int  len)

Definition at line 1436 of file kern_proc.c.

References malloc().

Referenced by do_execve(), and sysctl_kern_proc_args().

Here is the call graph for this function:

Here is the caller graph for this function:

void pargs_drop ( struct pargs *  pa)

Definition at line 1464 of file kern_proc.c.

References pargs_free().

Referenced by do_execve(), proc_reap(), and sysctl_kern_proc_args().

Here is the call graph for this function:

Here is the caller graph for this function:

static void pargs_free ( struct pargs *  pa)
static

Definition at line 1448 of file kern_proc.c.

References free().

Referenced by pargs_drop(), and sysctl_kern_proc_args().

Here is the call graph for this function:

Here is the caller graph for this function:

void pargs_hold ( struct pargs *  pa)

Definition at line 1455 of file kern_proc.c.

Referenced by do_fork(), and sysctl_kern_proc_args().

Here is the caller graph for this function:

struct proc* pfind ( pid_t  pid)

Definition at line 304 of file kern_proc.c.

References allproc_lock, and pfind_locked().

Referenced by cpuset_which(), filt_procattach(), fsetown(), kern_procctl(), kern_ptrace(), sys_getpgid(), sys_getpriority(), sys_getsid(), sys_kill(), sys_ktrace(), sys_rtprio(), sys_setpgid(), sys_setpriority(), sys_sigqueue(), sys_thr_kill2(), and sysctl_out_proc().

Here is the call graph for this function:

Here is the caller graph for this function:

struct proc* pfind_locked ( pid_t  pid)

Definition at line 279 of file kern_proc.c.

References allproc_lock.

Referenced by pfind(), and pget().

Here is the caller graph for this function:

static struct proc* pfind_tid_locked ( pid_t  tid)
static

Definition at line 315 of file kern_proc.c.

References allproc_lock.

Referenced by pget().

Here is the caller graph for this function:

static void pgadjustjobc ( struct pgrp *  pgrp,
int  entering 
)
static

Definition at line 610 of file kern_proc.c.

References orphanpg().

Referenced by fixjobc().

Here is the call graph for this function:

Here is the caller graph for this function:

static void pgdelete ( struct pgrp *  pgrp)
static

Definition at line 576 of file kern_proc.c.

References free(), funsetownlst(), mtx_destroy(), proctree_lock, sess_release(), and tty_rel_pgrp().

Referenced by doenterpgrp(), and leavepgrp().

Here is the call graph for this function:

Here is the caller graph for this function:

struct pgrp* pgfind ( pid_t  pgid)

Definition at line 342 of file kern_proc.c.

References proctree_lock.

Referenced by enterpgrp(), fsetown(), gsignal(), kern_procctl(), killpg1(), sys_getpriority(), sys_ktrace(), sys_setpgid(), sys_setpriority(), sys_setsid(), and tty_generic_ioctl().

Here is the caller graph for this function:

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

Definition at line 178 of file kern_proc.c.

Referenced by procinit().

Here is the caller graph for this function:

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

Definition at line 193 of file kern_proc.c.

Referenced by procinit().

Here is the caller graph for this function:

static void proc_fini ( void *  mem,
int  size 
)
static

Definition at line 245 of file kern_proc.c.

References ksiginfo_free(), mtx_destroy(), panic(), pstats_free(), and thread_free().

Referenced by procinit().

Here is the call graph for this function:

Here is the caller graph for this function:

int proc_getargv ( struct thread *  td,
struct proc *  p,
struct sbuf *  sb 
)

Definition at line 1744 of file kern_proc.c.

References get_ps_strings(), and PROC_ARG.

Referenced by sysctl_kern_proc_args().

Here is the call graph for this function:

Here is the caller graph for this function:

int proc_getauxv ( struct thread *  td,
struct proc *  p,
struct sbuf *  sb 
)

Definition at line 1758 of file kern_proc.c.

References free(), get_proc_vector(), PROC_AUX, and sbuf_bcat().

Referenced by note_procstat_auxv(), and sysctl_kern_proc_auxv().

Here is the call graph for this function:

Here is the caller graph for this function:

int proc_getenvv ( struct thread *  td,
struct proc *  p,
struct sbuf *  sb 
)

Definition at line 1751 of file kern_proc.c.

References get_ps_strings(), and PROC_ENV.

Referenced by sysctl_kern_proc_env().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 221 of file kern_proc.c.

References cv_init(), mtx_init(), and pstats_alloc().

Referenced by procinit().

Here is the call graph for this function:

Here is the caller graph for this function:

static int proc_read_mem ( struct thread *  td,
struct proc *  p,
vm_offset_t  offset,
void *  buf,
size_t  len 
)
static

Definition at line 1474 of file kern_proc.c.

References proc_rwmem().

Referenced by get_proc_vector(), and proc_read_string().

Here is the call graph for this function:

Here is the caller graph for this function:

static int proc_read_string ( struct thread *  td,
struct proc *  p,
const char *  sptr,
char *  buf,
size_t  len 
)
static

Definition at line 1494 of file kern_proc.c.

References proc_read_mem().

Referenced by get_ps_strings().

Here is the call graph for this function:

Here is the caller graph for this function:

void procinit ( )

Definition at line 158 of file kern_proc.c.

References allproc, allproc_lock, hashinit(), maxproc, mtx_init(), pgrphash, pgrphashtbl, pidhash, pidhashtbl, ppeers_lock, proc_ctor(), proc_dtor(), proc_fini(), proc_init(), proc_zone, proctree_lock, sched_sizeof_proc(), uihashinit(), and zombproc.

Referenced by proc0_init().

Here is the call graph for this function:

Here is the caller graph for this function:

struct pstats* pstats_alloc ( void  )

Definition at line 1030 of file kern_proc.c.

References malloc().

Referenced by proc0_init(), and proc_init().

Here is the call graph for this function:

Here is the caller graph for this function:

void pstats_fork ( struct pstats *  src,
struct pstats *  dst 
)

Definition at line 1040 of file kern_proc.c.

Referenced by do_fork().

Here is the caller graph for this function:

void pstats_free ( struct pstats *  ps)

Definition at line 1050 of file kern_proc.c.

References free().

Referenced by proc_fini().

Here is the call graph for this function:

Here is the caller graph for this function:

SDT_PROBE_DEFINE3 ( proc  ,
kernel  ,
dtor  ,
return  ,
"struct proc *"  ,
"int"  ,
"void *"   
)
SDT_PROBE_DEFINE3 ( proc  ,
kernel  ,
init  ,
entry  ,
"struct proc *"  ,
"int"  ,
"int"   
)
SDT_PROBE_DEFINE3 ( proc  ,
kernel  ,
init  ,
return  ,
"struct proc *"  ,
"int"  ,
"int"   
)
SDT_PROBE_DEFINE4 ( proc  ,
kernel  ,
ctor  ,
entry  ,
"struct proc *"  ,
"int"  ,
"void *"  ,
"int"   
)
SDT_PROBE_DEFINE4 ( proc  ,
kernel  ,
ctor  ,
return  ,
"struct proc *"  ,
"int"  ,
"void *"  ,
"int"   
)
SDT_PROBE_DEFINE4 ( proc  ,
kernel  ,
dtor  ,
entry  ,
"struct proc *"  ,
"int"  ,
"void *"  ,
"struct thread *"   
)
SDT_PROVIDER_DEFINE ( proc  )
void sess_hold ( struct session *  s)

Definition at line 709 of file kern_proc.c.

Referenced by enterpgrp(), and tprintf().

Here is the caller graph for this function:

void sess_release ( struct session *  s)

Definition at line 716 of file kern_proc.c.

References free(), mtx_destroy(), and tty_rel_sess().

Referenced by pgdelete(), and tprintf().

Here is the call graph for this function:

Here is the caller graph for this function:

SYSCTL_INT ( _kern  ,
OID_AUTO  ,
kstack_pages  ,
CTLFLAG_RD  ,
kstack_pages,
,
"Kernel stack size in pages"   
)
SYSCTL_INT ( _kern  ,
OID_AUTO  ,
proc_vmmap_skip_resident_count  ,
CTLFLAG_RW  ,
vmmap_skip_res_cnt,
,
"Skip calculation of the pages resident count in kern.proc.vmmap"   
)
static int sysctl_kern_proc ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1266 of file kern_proc.c.

References allproc, allproc_lock, name, p_cansee(), pget(), sysctl_out_proc(), sysctl_wire_old_buffer(), tty_udev(), and zombproc.

Here is the call graph for this function:

static int sysctl_kern_proc_args ( SYSCTL_HANDLER_ARGS  )
static
static int sysctl_kern_proc_auxv ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1878 of file kern_proc.c.

References GET_PS_STRINGS_CHUNK_SZ, name, pget(), proc_getauxv(), sbuf_delete(), sbuf_finish(), and sbuf_new_for_sysctl().

Here is the call graph for this function:

static int sysctl_kern_proc_env ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1846 of file kern_proc.c.

References GET_PS_STRINGS_CHUNK_SZ, name, pget(), proc_getenvv(), sbuf_delete(), sbuf_finish(), and sbuf_new_for_sysctl().

Here is the call graph for this function:

static int sysctl_kern_proc_groups ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2453 of file kern_proc.c.

References crfree(), crhold(), and pget().

Here is the call graph for this function:

static int sysctl_kern_proc_osrel ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2613 of file kern_proc.c.

References pget().

Here is the call graph for this function:

static int sysctl_kern_proc_pathname ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1909 of file kern_proc.c.

References free(), pget(), vn_fullpath(), vref(), and vrele().

Here is the call graph for this function:

static int sysctl_kern_proc_ps_strings ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2545 of file kern_proc.c.

References pget().

Here is the call graph for this function:

static int sysctl_kern_proc_rlimit ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2486 of file kern_proc.c.

References kern_proc_setrlimit(), lim_rlimit(), and pget().

Here is the call graph for this function:

static int sysctl_kern_proc_sigtramp ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2655 of file kern_proc.c.

References pget().

Here is the call graph for this function:

static int sysctl_kern_proc_sv_name ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 1949 of file kern_proc.c.

References name, pget(), and sysctl_handle_string().

Here is the call graph for this function:

static int sysctl_kern_proc_umask ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2585 of file kern_proc.c.

References pget().

Here is the call graph for this function:

static int sysctl_kern_proc_vmmap ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 2337 of file kern_proc.c.

References kern_proc_vmmap_out(), name, pget(), sbuf_delete(), sbuf_finish(), and sbuf_new_for_sysctl().

Here is the call graph for this function:

SYSCTL_NODE ( _kern  ,
KERN_PROC  ,
proc  ,
CTLFLAG_RD  ,
,
"Process table"   
)
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_GID  ,
gid  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_PGRP  ,
pgrp  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_RGID  ,
rgid  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_SESSION  ,
sid  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_TTY  ,
tty  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_UID  ,
uid  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_RUID  ,
ruid  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_PID  ,
pid  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_PROC  ,
proc  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Return process  table,
no threads"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_ARGS  ,
args  ,
CTLFLAG_RW|CTLFLAG_ANYBODY|  CTLFLAG_MPSAFE,
sysctl_kern_proc_args  ,
"Process argument list"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_ENV  ,
env  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc_env  ,
"Process environment"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_AUXV  ,
auxv  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc_auxv  ,
"Process ELF auxiliary vector"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_PATHNAME  ,
pathname  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc_pathname  ,
"Process executable path  
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_SV_NAME  ,
sv_name  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc_sv_name  ,
"Process syscall vector name (ABI type)"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
(KERN_PROC_GID|KERN_PROC_INC_THREAD)  ,
gid_td  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
(KERN_PROC_PGRP|KERN_PROC_INC_THREAD)  ,
pgrp_td  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
(KERN_PROC_RGID|KERN_PROC_INC_THREAD)  ,
rgid_td  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
(KERN_PROC_SESSION|KERN_PROC_INC_THREAD)  ,
sid_td  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
(KERN_PROC_TTY|KERN_PROC_INC_THREAD)  ,
tty_td  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
(KERN_PROC_UID|KERN_PROC_INC_THREAD)  ,
uid_td  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
(KERN_PROC_RUID|KERN_PROC_INC_THREAD)  ,
ruid_td  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
(KERN_PROC_PID|KERN_PROC_INC_THREAD)  ,
pid_td  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Process table"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
(KERN_PROC_PROC|KERN_PROC_INC_THREAD)  ,
proc_td  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc  ,
"Return process  table,
no threads"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_VMMAP  ,
vmmap  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc_vmmap  ,
"Process vm map entries"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_GROUPS  ,
groups  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc_groups  ,
"Process groups"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_RLIMIT  ,
rlimit  ,
CTLFLAG_RW|CTLFLAG_ANYBODY|  CTLFLAG_MPSAFE,
sysctl_kern_proc_rlimit  ,
"Process resource limits"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_PS_STRINGS  ,
ps_strings  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc_ps_strings  ,
"Process ps_strings location"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_UMASK  ,
umask  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc_umask  ,
"Process umask"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_OSREL  ,
osrel  ,
CTLFLAG_RW|CTLFLAG_ANYBODY|  CTLFLAG_MPSAFE,
sysctl_kern_proc_osrel  ,
"Process binary osreldate"   
)
static
static SYSCTL_NODE ( _kern_proc  ,
KERN_PROC_SIGTRAMP  ,
sigtramp  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
sysctl_kern_proc_sigtramp  ,
"Process signal trampoline location"   
)
static
static int sysctl_out_proc ( struct proc *  p,
struct sysctl_req *  req,
int  flags,
int  doingzomb 
)
static

Definition at line 1230 of file kern_proc.c.

References kern_proc_out(), pfind(), sbuf_delete(), sbuf_finish(), sbuf_new_for_sysctl(), and zpfind().

Referenced by sysctl_kern_proc().

Here is the call graph for this function:

Here is the caller graph for this function:

SYSCTL_PROC ( _kern_proc  ,
KERN_PROC_ALL  ,
all  ,
CTLFLAG_RD|CTLTYPE_STRUCT|  CTLFLAG_MPSAFE,
,
,
sysctl_kern_proc  ,
S,
proc"  ,
"Return entire process table"   
)
struct proc* zpfind ( pid_t  pid)

Definition at line 1075 of file kern_proc.c.

References allproc_lock, and zpfind_locked().

Referenced by filt_procattach(), sys_kill(), sys_sigqueue(), and sysctl_out_proc().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct proc * zpfind_locked ( pid_t  pid)
static

Definition at line 1057 of file kern_proc.c.

References allproc_lock, and zombproc.

Referenced by pget(), and zpfind().

Here is the caller graph for this function:

Variable Documentation

struct proclist allproc
int kstack_pages = KSTACK_PAGES

Definition at line 141 of file kern_proc.c.

u_long pgrphash

Definition at line 133 of file kern_proc.c.

Referenced by procinit().

struct pgrphashhead* pgrphashtbl

Definition at line 132 of file kern_proc.c.

Referenced by procinit().

u_long pidhash

Definition at line 131 of file kern_proc.c.

Referenced by procinit().

struct pidhashhead* pidhashtbl

Definition at line 130 of file kern_proc.c.

Referenced by procinit().

struct mtx ppeers_lock

Definition at line 138 of file kern_proc.c.

Referenced by do_fork(), exit1(), and procinit().

uma_zone_t proc_zone

Definition at line 139 of file kern_proc.c.

Referenced by fork1(), proc_reap(), and procinit().

int vmmap_skip_res_cnt = 0
static

Definition at line 144 of file kern_proc.c.

Referenced by kern_proc_vmmap_out().

struct proclist zombproc

Definition at line 135 of file kern_proc.c.

Referenced by exit1(), fork_findpid(), procinit(), sysctl_kern_proc(), and zpfind_locked().