Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Jan 2001 22:34:20 +0100
From:      Daniel Rock <D.Rock@t-online.de>
To:        Hajimu UMEMOTO <ume@FreeBSD.ORG>
Cc:        current@FreeBSD.ORG, hackers@FreeBSD.ORG
Subject:   Re: number of processes forked since boot
Message-ID:  <3A660FDC.ABAB10F5@t-online.de>
References:  <20010116.025742.74757685.ume@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <sys/shm.h>
 #include <sys/sysctl.h>
 #include <sys/vnode.h>
+#include <sys/vmmeter.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
@@ -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 <sys/ktr.h>
 #include <sys/ktrace.h>
 #include <sys/unistd.h>	
+#include <sys/vmmeter.h>
 #include <sys/jail.h>	
 
 #include <vm/vm.h>
@@ -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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A660FDC.ABAB10F5>