diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_fork.c | 15 | ||||
-rw-r--r-- | sys/sys/vmmeter.h | 11 | ||||
-rw-r--r-- | sys/vm/vm_meter.c | 16 |
3 files changed, 42 insertions, 0 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 9dc8ec3..e8f8a60 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -65,6 +65,7 @@ #include <vm/vm_extern.h> #include <vm/vm_zone.h> +#include <sys/vmmeter.h> #include <sys/user.h> static MALLOC_DEFINE(M_ATFORK, "atfork", "atfork callback"); @@ -517,6 +518,20 @@ again: */ vm_fork(p1, p2, flags); + if (flags == (RFFDG | RFPROC)) { + cnt.v_forks++; + cnt.v_forkpages += p2->p_vmspace->vm_dsize + p2->p_vmspace->vm_ssize; + } else if (flags == (RFFDG | RFPROC | RFPPWAIT | RFMEM)) { + cnt.v_vforks++; + cnt.v_vforkpages += p2->p_vmspace->vm_dsize + p2->p_vmspace->vm_ssize; + } else if (p1 == &proc0) { + cnt.v_kthreads++; + cnt.v_kthreadpages += p2->p_vmspace->vm_dsize + p2->p_vmspace->vm_ssize; + } else { + cnt.v_rforks++; + cnt.v_rforkpages += p2->p_vmspace->vm_dsize + p2->p_vmspace->vm_ssize; + } + /* * Both processes are set up, now check if any loadable modules want * to adjust anything. diff --git a/sys/sys/vmmeter.h b/sys/sys/vmmeter.h index 0ca8432..f6e17ff 100644 --- a/sys/sys/vmmeter.h +++ b/sys/sys/vmmeter.h @@ -92,6 +92,17 @@ struct vmmeter { u_int v_pageout_free_min; /* min number pages reserved for kernel */ u_int v_interrupt_free_min; /* reserved number of pages for int code */ u_int v_free_severe; /* severe depletion of pages below this pt */ + /* + * Fork/vfork/rfork activity. + */ + u_int v_forks; /* number of fork() calls */ + u_int v_vforks; /* number of vfork() calls */ + u_int v_rforks; /* number of rfork() calls */ + u_int v_kthreads; /* number of fork() calls by kernel */ + u_int v_forkpages; /* number of VM pages affected by fork() */ + u_int v_vforkpages; /* number of VM pages affected by vfork() */ + u_int v_rforkpages; /* number of VM pages affected by rfork() */ + u_int v_kthreadpages; /* number of VM pages affected by fork() by kernel */ }; #ifdef _KERNEL diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c index 3e573d7..2fa0754 100644 --- a/sys/vm/vm_meter.c +++ b/sys/vm/vm_meter.c @@ -323,6 +323,22 @@ SYSCTL_UINT(_vm_stats_vm, OID_AUTO, v_interrupt_free_min, CTLFLAG_RD, &cnt.v_interrupt_free_min, 0, ""); SYSCTL_INT(_vm_stats_misc, OID_AUTO, zero_page_count, CTLFLAG_RD, &vm_page_zero_count, 0, ""); +SYSCTL_UINT(_vm_stats_vm, OID_AUTO, + v_forks, CTLFLAG_RD, &cnt.v_forks, 0, "Number of fork() calls"); +SYSCTL_UINT(_vm_stats_vm, OID_AUTO, + v_vforks, CTLFLAG_RD, &cnt.v_vforks, 0, "Number of vfork() calls"); +SYSCTL_UINT(_vm_stats_vm, OID_AUTO, + v_rforks, CTLFLAG_RD, &cnt.v_rforks, 0, "Number of rfork() calls"); +SYSCTL_UINT(_vm_stats_vm, OID_AUTO, + v_kthreads, CTLFLAG_RD, &cnt.v_kthreads, 0, "Number of fork() calls by kernel"); +SYSCTL_UINT(_vm_stats_vm, OID_AUTO, + v_forkpages, CTLFLAG_RD, &cnt.v_forkpages, 0, "VM pages affected by fork()"); +SYSCTL_UINT(_vm_stats_vm, OID_AUTO, + v_vforkpages, CTLFLAG_RD, &cnt.v_vforkpages, 0, "VM pages affected by vfork()"); +SYSCTL_UINT(_vm_stats_vm, OID_AUTO, + v_rforkpages, CTLFLAG_RD, &cnt.v_rforkpages, 0, "VM pages affected by rfork()"); +SYSCTL_UINT(_vm_stats_vm, OID_AUTO, + v_kthreadpages, CTLFLAG_RD, &cnt.v_kthreadpages, 0, "VM pages affected by fork() by kernel"); #if 0 SYSCTL_INT(_vm_stats_misc, OID_AUTO, page_mask, CTLFLAG_RD, &page_mask, 0, ""); |