Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Jun 2011 18:58:57 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r223095 - in stable/8: contrib/top usr.bin/top
Message-ID:  <201106141858.p5EIwvvw047635@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Tue Jun 14 18:58:57 2011
New Revision: 223095
URL: http://svn.freebsd.org/changeset/base/223095

Log:
  MFC 222530:
  Add a new option to toggle the display of the system idle process (per-CPU
  idle threads).  The process is displayed by default (subject to whether or
  not system processes are displayed) to preserve existing behavior.  The
  system idle process can be hidden via the '-z' command line argument or the
  'z' key while top is running.  When it is hidden, top more closely matches
  the behavior of FreeBSD <= 4.x where idle time was not accounted to any
  process.

Modified:
  stable/8/contrib/top/commands.c
  stable/8/contrib/top/machine.h
  stable/8/contrib/top/top.X
  stable/8/contrib/top/top.c
  stable/8/usr.bin/top/machine.c
Directory Properties:
  stable/8/contrib/top/   (props changed)
  stable/8/contrib/top/install-sh   (props changed)
  stable/8/usr.bin/top/   (props changed)

Modified: stable/8/contrib/top/commands.c
==============================================================================
--- stable/8/contrib/top/commands.c	Tue Jun 14 18:56:45 2011	(r223094)
+++ stable/8/contrib/top/commands.c	Tue Jun 14 18:58:57 2011	(r223095)
@@ -94,6 +94,7 @@ S       - toggle the displaying of syste
 a       - toggle the displaying of process titles\n\
 t       - toggle the display of this process\n\
 u       - display processes for only one user (+ selects all users)\n\
+z       - toggle the displaying of the system idle process\n\
 \n\
 \n", stdout);
     }

Modified: stable/8/contrib/top/machine.h
==============================================================================
--- stable/8/contrib/top/machine.h	Tue Jun 14 18:56:45 2011	(r223094)
+++ stable/8/contrib/top/machine.h	Tue Jun 14 18:58:57 2011	(r223095)
@@ -65,6 +65,7 @@ struct process_select
     int uid;		/* only this uid (unless uid == -1) */
     int wcpu;		/* show weighted cpu */
     int jail;		/* show jail ID */
+    int kidle;		/* show per-CPU idle threads */
     char *command;	/* only this command (unless == NULL) */
 };
 

Modified: stable/8/contrib/top/top.X
==============================================================================
--- stable/8/contrib/top/top.X	Tue Jun 14 18:56:45 2011	(r223094)
+++ stable/8/contrib/top/top.X	Tue Jun 14 18:58:57 2011	(r223095)
@@ -10,7 +10,7 @@ top \- display and update information ab
 .SH SYNOPSIS
 .B top
 [
-.B \-abCHIijnPqStuv
+.B \-abCHIijnPqStuvz
 ] [
 .BI \-d count
 ] [
@@ -146,6 +146,9 @@ Write version number information to stde
 No other processing takes place when this option is used.  To see current
 revision information while top is running, use the help command \*(lq?\*(rq.
 .TP
+.B \-z
+Do not display the system idle process.
+.TP
 .BI \-d count
 Show only
 .I count
@@ -310,6 +313,9 @@ ID.
 Toggle the display of the
 .I top
 process.
+.TP
+.B z
+Toggle the display of the system idle process.
 .SH "THE DISPLAY"
 The actual display varies depending on the specific variant of Unix
 that the machine is running.  This description may not exactly match

Modified: stable/8/contrib/top/top.c
==============================================================================
--- stable/8/contrib/top/top.c	Tue Jun 14 18:56:45 2011	(r223094)
+++ stable/8/contrib/top/top.c	Tue Jun 14 18:58:57 2011	(r223095)
@@ -196,9 +196,9 @@ char *argv[];
     fd_set readfds;
 
 #ifdef ORDER
-    static char command_chars[] = "\f qh?en#sdkriIutHmSCajo";
+    static char command_chars[] = "\f qh?en#sdkriIutHmSCajzo";
 #else
-    static char command_chars[] = "\f qh?en#sdkriIutHmSCaj";
+    static char command_chars[] = "\f qh?en#sdkriIutHmSCajz";
 #endif
 /* these defines enumerate the "strchr"s of the commands in command_chars */
 #define CMD_redraw	0
@@ -224,8 +224,9 @@ char *argv[];
 #define	CMD_wcputog	19
 #define	CMD_showargs	20
 #define	CMD_jidtog	21
+#define CMD_kidletog	22
 #ifdef ORDER
-#define CMD_order       22
+#define CMD_order       23
 #endif
 
     /* set the buffer for stdout */
@@ -258,6 +259,7 @@ char *argv[];
     ps.thread  = No;
     ps.wcpu    = 1;
     ps.jail    = No;
+    ps.kidle   = Yes;
     ps.command = NULL;
 
     /* get preset options from the environment */
@@ -283,7 +285,7 @@ char *argv[];
 	    optind = 1;
 	}
 
-	while ((i = getopt(ac, av, "CSIHPabijnquvs:d:U:m:o:t")) != EOF)
+	while ((i = getopt(ac, av, "CSIHPabijnquvzs:d:U:m:o:t")) != EOF)
 	{
 	    switch(i)
 	    {
@@ -412,10 +414,14 @@ char *argv[];
 		pcpu_stats = Yes;
 		break;
 
+	      case 'z':
+		ps.kidle = !ps.kidle;
+		break;
+
 	      default:
 		fprintf(stderr,
 "Top version %s\n"
-"Usage: %s [-abCHIijnPqStuv] [-d count] [-m io | cpu] [-o field] [-s time]\n"
+"Usage: %s [-abCHIijnPqStuvz] [-d count] [-m io | cpu] [-o field] [-s time]\n"
 "       [-U username] [number]\n",
 			version_string(), myname);
 		exit(1);
@@ -1075,7 +1081,13 @@ restart:
 				reset_display();
 				putchar('\r');
 				break;
-	    
+			    case CMD_kidletog:
+				ps.kidle = !ps.kidle;
+				new_message(MT_standout | MT_delayed,
+				    " %sisplaying system idle process.",
+				    ps.kidle ? "D" : "Not d");
+				putchar('\r');
+				break;
 			    default:
 				new_message(MT_standout, " BAD CASE IN SWITCH!");
 				putchar('\r');

Modified: stable/8/usr.bin/top/machine.c
==============================================================================
--- stable/8/usr.bin/top/machine.c	Tue Jun 14 18:56:45 2011	(r223094)
+++ stable/8/usr.bin/top/machine.c	Tue Jun 14 18:58:57 2011	(r223095)
@@ -624,6 +624,7 @@ get_process_info(struct system_info *si,
 	int show_system;
 	int show_uid;
 	int show_command;
+	int show_kidle;
 
 	/*
 	 * Save the previous process info.
@@ -664,6 +665,7 @@ get_process_info(struct system_info *si,
 	show_system = sel->system;
 	show_uid = sel->uid != -1;
 	show_command = sel->command != NULL;
+	show_kidle = sel->kidle;
 
 	/* count up process states and get pointers to interesting procs */
 	total_procs = 0;
@@ -705,6 +707,11 @@ get_process_info(struct system_info *si,
 			/* skip idle or non-running processes */
 			continue;
 
+		if (displaymode == DISP_CPU && !show_kidle &&
+		    pp->ki_tdflags & TDF_IDLETD)
+			/* skip kernel idle process */
+			continue;
+		    
 		if (displaymode == DISP_IO && !show_idle && p_io == 0)
 			/* skip processes that aren't doing I/O */
 			continue;



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