Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Oct 2008 20:45:46 +0400
From:      pluknet <pluknet@gmail.com>
To:        "Edwin Groothuis" <edwin@freebsd.org>
Cc:        stable@freebsd.org, current@freebsd.org
Subject:   Re: Request for testing - top 3.8b1 in the base system
Message-ID:  <a31046fc0810210945o279d0843t7120cab90c0bfe99@mail.gmail.com>
In-Reply-To: <20080928054620.GA80250@k7.mavetju>
References:  <20080928054620.GA80250@k7.mavetju>

next in thread | previous in thread | raw e-mail | index | archive | help
2008/9/28 Edwin Groothuis <edwin@freebsd.org>:
> I have made an update for the top(1) utility in the FreeBSD base
> system to get it from the 3.5b12 version to the 3.8b1 version.
>
> I have tried them on the amd64 architecture on FreeBSD -current and
> FreeBSD 7.0 and on the i386 architecture on FreeBSD 7.0.
>
> The big new features are a line upper part with kernel statistics
> (context-switches, traps, interrupts, faults etc) and the FLG table
> (if you window is big enough)
>
> Some features specific to FreeBSD (dual display (press m)), threaded
> processes, and jails have been ported to 3.8b1.
>
> The biggest fix (AFAICT) is the TIME and CPU table for threaded
> processes, which are now calculated properly.
>
> The new code can be found on
>    http://www.mavetju.org/~edwin/freebsd-top-3.8b1-A.tar.gz
> Go to 3.8b1/usr.sbin/top and run "make" there to produce the binary,
> then run it via "./top".
>
> Please report any issues with it (compile time, run time) and a way
> to reproduce it (if possible). Thanks for your help!
>
> Edwin

btw, on my 6.2 it never changes 'Processes' count on 'S' press
and always shows all(+system ) procs (as if it in 'S' mode). Base top does it.

That is because 3.81 top has different semantics between active procs
and total ones.
'Processes' count displays active procs (+ threads in 'H' mode).

My small patch represents this. The first number displays actually
displayed procs(and threads)
and the second one displays all procs(and  threads) in system.

Index: top/freebsd-top-3.8b1-A/contrib/top/top.c
===================================================================
--- top/freebsd-top-3.8b1-A/contrib/top/top.c	(revision 5702)
+++ top/freebsd-top-3.8b1-A/contrib/top/top.c	(working copy)
@@ -567,7 +567,8 @@
 	i_loadave(system_info.last_pid, system_info.load_avg);
 	i_uptime(&(gstate->statics->boottime), &curr_time);
 	i_timeofday(&curr_time);
-	i_procstates(system_info.p_total, system_info.procstates,
gstate->pselect.threads);
+	i_procstates(system_info.p_total, system_info.p_active,
+	  system_info.procstates, gstate->pselect.threads);
 	if (gstate->show_cpustates)
 	{
 	    i_cpustates(system_info.cpustates);
@@ -601,7 +602,8 @@
 	u_loadave(system_info.last_pid, system_info.load_avg);
 	i_timeofday(&curr_time);
 	u_uptime(&(gstate->statics->boottime), &curr_time);
-	u_procstates(system_info.p_total, system_info.procstates,
gstate->pselect.threads);
+	u_procstates(system_info.p_total, system_info.p_active,
+	  system_info.procstates, gstate->pselect.threads);
 	u_cpustates(system_info.cpustates);
 	u_kernel(system_info.kernel);
 	u_memory(system_info.memory);
Index: top/freebsd-top-3.8b1-A/contrib/top/display.c
===================================================================
--- top/freebsd-top-3.8b1-A/contrib/top/display.c	(revision 5702)
+++ top/freebsd-top-3.8b1-A/contrib/top/display.c	(working copy)
@@ -1042,6 +1042,7 @@
 }

 static int ltotal = 0;
+static int lactive = 0;
 static int lthreads = 0;

 /*
@@ -1050,13 +1051,14 @@


 void
-i_procstates(int total, int *brkdn, int threads)
+i_procstates(int total, int active, int *brkdn, int threads)

 {
     /* write current number of processes and remember the value */
     display_fmt(0, y_procstate, 0, 0,
-		"%d %s: ", total, threads ? "threads" : "processes");
+		"%d/%d %s: ", active, total, threads ? "threads" : "processes");
     ltotal = total;
+    lactive = active;

     /* remember where the summary starts */
     x_procstate = virt_x;
@@ -1073,24 +1075,24 @@
 }

 void
-u_procstates(int total, int *brkdn, int threads)
+u_procstates(int total, int active, int *brkdn, int threads)

 {
     /* if threads state has changed, do a full update */
     if (lthreads != threads)
     {
-	i_procstates(total, brkdn, threads);
+	i_procstates(total, active, brkdn, threads);
 	return;
     }

     /* update number of processes only if it has changed */
-    if (ltotal != total)
+    if (ltotal != total || lactive != active)
     {
 	display_fmt(0, y_procstate, 0, 0,
-		    "%d", total);
+		    "%d/%d", active, total);

 	/* if number of digits differs, rewrite the label */
-	if (digits(total) != digits(ltotal))
+	if (digits(total) != digits(ltotal) || digits(active) != digits(lactive))
 	{
 	    display_fmt(-1, -1, 0, 0, " %s: ", threads ? "threads" : "processes");
 	    x_procstate = virt_x;
@@ -1098,6 +1100,7 @@

 	/* save new total */
 	ltotal = total;
+	lactive = active;
     }

     /* see if any of the state numbers has changed */
Index: top/freebsd-top-3.8b1-A/contrib/top/display.h
===================================================================
--- top/freebsd-top-3.8b1-A/contrib/top/display.h	(revision 5702)
+++ top/freebsd-top-3.8b1-A/contrib/top/display.h	(working copy)
@@ -49,8 +49,8 @@
 void i_uptime(time_t *bt, time_t *tod);
 void u_uptime(time_t *bt, time_t *tod);
 void i_timeofday(time_t *tod);
-void i_procstates(int total, int *brkdn, int threads);
-void u_procstates(int total, int *brkdn, int threads);
+void i_procstates(int total, int active, int *brkdn, int threads);
+void u_procstates(int total, int active, int *brkdn, int threads);
 void i_cpustates(int *states);
 void u_cpustates(int *states);
 void z_cpustates();
-- 
wbr,
pluknet



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