[RFC] prototype of top(1)'s CPU current frequency display

Norikatsu Shigemura nork at FreeBSD.org
Sun Aug 20 08:24:45 UTC 2006


	I want to see CPU current frequency on top(1), because I want
	to see relation of process status (CPU usage) and cpu current
	frequency using powerd(8) on the fly.  In recently, many CPUs
	for servers like Xeon support frequency changing like Speed
	Step Technology.  I run powerd(8) on these servers.  So I
	should know performance issue, whichever program performance
	or server performance.  I wrote a little usability patch.
	But I don't think that my code is not good:-(.  So please
	improve my code.

	Wellknown problem.
	1. assume only 1 CPU.
	2. assume dev.cpu.0.freq is always exists.
	3. display position is good?

--- usr.bin/top/machine.c.orig	Wed May 18 22:42:51 2005
+++ usr.bin/top/machine.c	Sun Aug 20 16:41:59 2006
@@ -153,10 +153,10 @@
 
 /* these are for detailing the process states */
 
-int process_states[8];
+int process_states[9];
 char *procstatenames[] = {
 	"", " starting, ", " running, ", " sleeping, ", " stopped, ",
-	" zombie, ", " waiting, ", " lock, ",
+	" zombie, ", " waiting, ", " lock, ", " MHz, ",
 	NULL
 };
 
@@ -628,6 +628,9 @@
 			prev_pp->ki_pctcpu += pp->ki_pctcpu;
 		}
 	}
+
+	/* CPU current frequency */
+	GETSYSCTL("dev.cpu.0.freq", process_states[8]);
 
 	/* if requested, sort the "interesting" processes */
 	if (compare != NULL)


More information about the freebsd-hackers mailing list