From owner-freebsd-current@FreeBSD.ORG Sat Aug 26 08:56:52 2006 Return-Path: X-Original-To: freebsd-current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A1B9D16A4DD; Sat, 26 Aug 2006 08:56:52 +0000 (UTC) (envelope-from nork@FreeBSD.org) Received: from sakura.ninth-nine.com (sakura.ninth-nine.com [219.127.74.120]) by mx1.FreeBSD.org (Postfix) with ESMTP id 10AE043D49; Sat, 26 Aug 2006 08:56:51 +0000 (GMT) (envelope-from nork@FreeBSD.org) Received: from nadesico.ninth-nine.com (nadesico.ninth-nine.com [219.127.74.122]) by sakura.ninth-nine.com (8.13.6/8.13.6/NinthNine) with ESMTP id k7Q8uofx062889; Sat, 26 Aug 2006 17:56:50 +0900 (JST) (envelope-from nork@FreeBSD.org) Date: Sat, 26 Aug 2006 17:56:50 +0900 From: Norikatsu Shigemura To: freebsd-hackers@FreeBSD.org, freebsd-current@FreeBSD.org Message-Id: <20060826175650.c6897fa1.nork@FreeBSD.org> In-Reply-To: <20060820172435.26c4cc2a.nork@FreeBSD.org> References: <20060820172435.26c4cc2a.nork@FreeBSD.org> X-Mailer: Sylpheed version 2.2.7 (GTK+ 2.8.20; i386-portbld-freebsd6.1) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Sat__26_Aug_2006_17_56_50_+0900_B3LIhfNEWJ2tmbRO" X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (sakura.ninth-nine.com [219.127.74.121]); Sat, 26 Aug 2006 17:56:51 +0900 (JST) Cc: imp@FreeBSD.org Subject: Re: [RFC] prototype of top(1)'s CPU current frequency display X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Aug 2006 08:56:52 -0000 This is a multi-part message in MIME format. --Multipart=_Sat__26_Aug_2006_17_56_50_+0900_B3LIhfNEWJ2tmbRO Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 20 Aug 2006 17:24:35 +0900 Norikatsu Shigemura wrote: > 1. assume only 1 CPU. > 2. assume dev.cpu.0.freq is always exists. > 3. display position is good? I modified 1 and 2. Please check attached diff. I couldn't fix 3 issue. So I assumed support max 2CPUs. I confirmed following environments. - - PentiumIII-S dual - - - - - - - - - - - - - dev.cpu.0.%desc: ACPI CPU dev.cpu.0.%driver: cpu dev.cpu.0.%location: handle=\_PR_.CPU0 dev.cpu.0.%pnpinfo: _HID=none _UID=0 dev.cpu.0.%parent: acpi0 dev.cpu.1.%desc: ACPI CPU dev.cpu.1.%driver: cpu dev.cpu.1.%location: handle=\_PR_.CPU1 dev.cpu.1.%pnpinfo: _HID=none _UID=0 dev.cpu.1.%parent: acpi0 - - PentiumIII-S dual - - - - - - - - - - - - - - - Pentium-M Dothan - - - - - - - - - - - - - - dev.cpu.0.%desc: ACPI CPU dev.cpu.0.%driver: cpu dev.cpu.0.%location: handle=\_PR_.CPU0 dev.cpu.0.%pnpinfo: _HID=none _UID=0 dev.cpu.0.%parent: acpi0 dev.cpu.0.freq: 1200 dev.cpu.0.freq_levels: 1200/-1 1100/-1 1000/-1 900/-1 800/-1 700/-1 600/-1 525/-1 450/-1 375/-1 300/-1 225/-1 150/-1 75/-1 - - Pentium-M Dothan - - - - - - - - - - - - - - - - Xeon 2.8GHz - - - - - - - - - - - - - - - - dev.cpu.0.%desc: ACPI CPU dev.cpu.0.%driver: cpu dev.cpu.0.%location: handle=\_PR_.CPU0 dev.cpu.0.%pnpinfo: _HID=none _UID=0 dev.cpu.0.%parent: acpi0 dev.cpu.0.freq: 2807 dev.cpu.0.freq_levels: 2807/-1 2456/-1 2105/-1 1754/-1 1403/-1 1052/-1 701/-1 350/-1 - - Xeon 2.8GHz - - - - - - - - - - - - - - - - --Multipart=_Sat__26_Aug_2006_17_56_50_+0900_B3LIhfNEWJ2tmbRO Content-Type: text/plain; name="6-stable.usr-bin.top.machine.c.diff" Content-Disposition: attachment; filename="6-stable.usr-bin.top.machine.c.diff" Content-Transfer-Encoding: 7bit Index: machine.c =================================================================== RCS file: /home/ncvs/src/usr.bin/top/machine.c,v retrieving revision 1.74 diff -u -r1.74 machine.c --- machine.c 18 May 2005 13:42:51 -0000 1.74 +++ machine.c 26 Aug 2006 08:41:50 -0000 @@ -61,6 +61,8 @@ extern char* printable(char *); int swapmode(int *retavail, int *retfree); static int smpmode; +static int ncpu; +#define NCPU 2 /* support max 2cpu to display frequency */ enum displaymodes displaymode; static int namelength = 8; static int cmdlengthdelta; @@ -153,10 +155,10 @@ /* these are for detailing the process states */ -int process_states[8]; +int process_states[8+NCPU]; char *procstatenames[] = { "", " starting, ", " running, ", " sleeping, ", " stopped, ", - " zombie, ", " waiting, ", " lock, ", + " zombie, ", " waiting, ", " lock, ", " MHz, ", " MHz, ", NULL }; @@ -235,6 +237,13 @@ modelen != sizeof(smpmode)) smpmode = 0; + for (ncpu = -1; ncpu < NCPU; ncpu++) { + char buf[32]; + snprintf(buf, sizeof buf-1, "dev.cpu.%d.freq", ncpu+1); + if (sysctlbyname(buf, NULL, NULL, NULL, 0) < 0) + break; + } + while ((pw = getpwent()) != NULL) { if (strlen(pw->pw_name) > namelength) namelength = strlen(pw->pw_name); @@ -629,6 +638,16 @@ } } + /* CPU current frequency */ + if (ncpu != -1) { + int j; + for(j = 0; j <= ncpu; j++) { + char buf[32]; + snprintf(buf, sizeof buf-1, "dev.cpu.%d.freq", j); + GETSYSCTL(buf, process_states[j+8]); + } + } + /* if requested, sort the "interesting" processes */ if (compare != NULL) qsort(pref, active_procs, sizeof(*pref), compare); --Multipart=_Sat__26_Aug_2006_17_56_50_+0900_B3LIhfNEWJ2tmbRO Content-Type: text/plain; name="7-current.usr-bin.top.machine.c.diff" Content-Disposition: attachment; filename="7-current.usr-bin.top.machine.c.diff" Content-Transfer-Encoding: 7bit Index: machine.c =================================================================== RCS file: /home/ncvs/src/usr.bin/top/machine.c,v retrieving revision 1.77 diff -u -r1.77 machine.c --- machine.c 11 Jun 2006 19:18:39 -0000 1.77 +++ machine.c 26 Aug 2006 08:41:29 -0000 @@ -58,6 +58,8 @@ extern struct process_select ps; extern char* printable(char *); static int smpmode; +static int ncpu; +#define NCPU 2 /* support max 2cpu to display frequency */ enum displaymodes displaymode; static int namelength = 8; static int cmdlengthdelta; @@ -147,10 +149,10 @@ /* these are for detailing the process states */ -int process_states[8]; +int process_states[8+NCPU]; char *procstatenames[] = { "", " starting, ", " running, ", " sleeping, ", " stopped, ", - " zombie, ", " waiting, ", " lock, ", + " zombie, ", " waiting, ", " lock, ", " MHz, ", " MHz, ", NULL }; @@ -234,6 +236,13 @@ modelen != sizeof(smpmode)) smpmode = 0; + for (ncpu = -1; ncpu < NCPU; ncpu++) { + char buf[32]; + snprintf(buf, sizeof buf-1, "dev.cpu.%d.freq", ncpu+1); + if (sysctlbyname(buf, NULL, NULL, NULL, 0) < 0) + break; + } + while ((pw = getpwent()) != NULL) { if (strlen(pw->pw_name) > namelength) namelength = strlen(pw->pw_name); @@ -632,6 +641,16 @@ } } + /* CPU current frequency */ + if (ncpu != -1) { + int j; + for(j = 0; j <= ncpu; j++) { + char buf[32]; + snprintf(buf, sizeof buf-1, "dev.cpu.%d.freq", j); + GETSYSCTL(buf, process_states[j+8]); + } + } + /* if requested, sort the "interesting" processes */ if (compare != NULL) qsort(pref, active_procs, sizeof(*pref), compare); --Multipart=_Sat__26_Aug_2006_17_56_50_+0900_B3LIhfNEWJ2tmbRO--