From owner-freebsd-current Wed Jan 17 13:35:19 2001 Delivered-To: freebsd-current@freebsd.org Received: from mailout02.sul.t-online.com (mailout02.sul.t-online.com [194.25.134.17]) by hub.freebsd.org (Postfix) with ESMTP id CDA1B37B6E7; Wed, 17 Jan 2001 13:34:30 -0800 (PST) Received: from fwd03.sul.t-online.com by mailout02.sul.t-online.com with smtp id 14J0Dt-0007nN-07; Wed, 17 Jan 2001 22:34:29 +0100 Received: from server.rock.net (340029380333-0001@[62.226.181.116]) by fmrl03.sul.t-online.com with esmtp id 14J0Dk-0IAsQCC; Wed, 17 Jan 2001 22:34:20 +0100 Received: from t-online.de (server [172.23.7.1]) by server.rock.net (8.9.3+Sun/8.9.3/Rock) with ESMTP id WAA16369; Wed, 17 Jan 2001 22:34:20 +0100 (MET) Message-ID: <3A660FDC.ABAB10F5@t-online.de> Date: Wed, 17 Jan 2001 22:34:20 +0100 From: Daniel Rock X-Mailer: Mozilla 4.7 [de] (X11; U; SunOS 5.8 i86pc) X-Accept-Language: de, en MIME-Version: 1.0 To: Hajimu UMEMOTO Cc: current@FreeBSD.ORG, hackers@FreeBSD.ORG Subject: Re: number of processes forked since boot References: <20010116.025742.74757685.ume@FreeBSD.org> Content-Type: multipart/mixed; boundary="------------ACBB2467DA3F232ACF48A671" X-Sender: 340029380333-0001@t-dialin.net Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Dies ist eine mehrteilige Nachricht im MIME-Format. --------------ACBB2467DA3F232ACF48A671 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hajimu UMEMOTO schrieb: > > Hi, > > I wish to obtain number of processes forked since boot from userland. > So, I made a patch to intend to commit. > Any comment? I have done a similar approach. I was inspired by the "vmstat -s" output of Solaris. Therefor my solution was integrated into the vmmeter structure. Adding sysctl variables would be trivial though. Warning: The diff is from a very old source tree. It may not apply cleanly. But the modifications are trivial and should be easily spotted. -- Daniel --------------ACBB2467DA3F232ACF48A671 Content-Type: text/plain; charset=us-ascii; name="src.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="src.diff" Index: sys/kern/kern_exec.c =================================================================== RCS file: /data/cvs/src/sys/kern/kern_exec.c,v retrieving revision 1.116 diff -u -r1.116 kern_exec.c --- sys/kern/kern_exec.c 2000/09/21 09:04:17 1.116 +++ sys/kern/kern_exec.c 2000/09/21 17:34:09 @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -374,7 +375,10 @@ } if (error == 0) + { + ++cnt.v_exec; return (0); + } exec_fail: if (imgp->vmspace_destroyed) { Index: sys/kern/kern_fork.c =================================================================== RCS file: /data/cvs/src/sys/kern/kern_fork.c,v retrieving revision 1.82 diff -u -r1.82 kern_fork.c --- sys/kern/kern_fork.c 2000/09/14 23:07:39 1.82 +++ sys/kern/kern_fork.c 2000/09/15 23:07:29 @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -105,6 +106,7 @@ if (error == 0) { p->p_retval[0] = p2->p_pid; p->p_retval[1] = 0; + ++cnt.v_fork; } return error; } @@ -122,6 +124,7 @@ if (error == 0) { p->p_retval[0] = p2->p_pid; p->p_retval[1] = 0; + ++cnt.v_vfork; } return error; } Index: sys/sys/vmmeter.h =================================================================== RCS file: /data/cvs/src/sys/sys/vmmeter.h,v retrieving revision 1.21 diff -u -r1.21 vmmeter.h --- sys/sys/vmmeter.h 1999/12/29 04:24:49 1.21 +++ sys/sys/vmmeter.h 1999/12/31 02:41:29 @@ -92,6 +92,9 @@ 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 */ + u_int v_fork; + u_int v_vfork; + u_int v_exec; }; #ifdef _KERNEL Index: usr.bin/vmstat/vmstat.c =================================================================== RCS file: /data/cvs/src/usr.bin/vmstat/vmstat.c,v retrieving revision 1.39 diff -u -r1.39 vmstat.c --- usr.bin/vmstat/vmstat.c 2000/05/05 16:07:10 1.39 +++ usr.bin/vmstat/vmstat.c 2000/05/07 21:11:18 @@ -599,6 +599,12 @@ (void)printf("%9u cpu context switches\n", sum.v_swtch); (void)printf("%9u device interrupts\n", sum.v_intr); (void)printf("%9u software interrupts\n", sum.v_soft); + (void)printf("%9u forks\n", sum.v_fork); + (void)printf("%9u vforks\n", sum.v_vfork); + (void)printf("%9u execs\n", sum.v_exec); +#ifdef vax + (void)printf("%9u pseudo-dma dz interrupts\n", sum.v_pdma); +#endif (void)printf("%9u traps\n", sum.v_trap); (void)printf("%9u system calls\n", sum.v_syscall); (void)printf("%9u swap pager pageins\n", sum.v_swapin); @@ -731,7 +737,7 @@ errx(1, "malloc"); kread(X_INTRCNT, intrcnt, (size_t)nintr); kread(X_INTRNAMES, intrname, (size_t)inamlen); - (void)printf("interrupt total rate\n"); + (void)printf("interrupt total rate\n"); inttotal = 0; nintr /= sizeof(long); while (--nintr >= 0) { --------------ACBB2467DA3F232ACF48A671-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message