Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Aug 2006 17:24:35 +0900
From:      Norikatsu Shigemura <nork@FreeBSD.org>
To:        freebsd-hackers@FreeBSD.org
Cc:        freebsd-current@FreeBSD.org
Subject:   [RFC] prototype of top(1)'s CPU current frequency display
Message-ID:  <20060820172435.26c4cc2a.nork@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
	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)



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