From owner-freebsd-bugs Mon May 21 17: 0:10 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 42D8A37B43C for ; Mon, 21 May 2001 17:00:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f4M002C96519; Mon, 21 May 2001 17:00:02 -0700 (PDT) (envelope-from gnats) Received: from mail.disney.com (mail.disney.com [204.128.192.15]) by hub.freebsd.org (Postfix) with ESMTP id 7090C37B424 for ; Mon, 21 May 2001 16:57:55 -0700 (PDT) (envelope-from Jim.Pirzyk@disney.com) Received: from pain10.corp.disney.com (root@pain10.corp.disney.com [153.7.110.100]) by mail.disney.com (Switch-2.0.1/Switch-2.0.1) with SMTP id f4LNvIA04416 for ; Mon, 21 May 2001 16:57:18 -0700 (PDT) Received: from louie.fa.disney.com by pain.corp.disney.com with ESMTP for FreeBSD-gnats-submit@freebsd.org; Mon, 21 May 2001 16:58:42 -0700 Received: from plio.fan.fa.disney.com (plio.fan.fa.disney.com [153.7.118.2]) by louie.fa.disney.com (8.9.2/8.9.2) with ESMTP id QAA20065 for ; Mon, 21 May 2001 16:57:52 -0700 (PDT) (envelope-from Jim.Pirzyk@fa.disney.com) Received: from snoopy.fan.fa.disney.com (snoopy.fan.fa.disney.com [153.7.117.170]) by plio.fan.fa.disney.com (8.9.2/8.9.2) with ESMTP id QAA22710 for ; Mon, 21 May 2001 16:57:52 -0700 (PDT) (envelope-from Jim.Pirzyk@fa.disney.com) Received: (from Jim.Pirzyk@localhost) by snoopy.fan.fa.disney.com (8.11.3/8.9.3) id f4LNvp745724; Mon, 21 May 2001 16:57:51 -0700 (PDT) (envelope-from Jim.Pirzyk@fa.disney.com) Message-Id: <200105212357.f4LNvp745724@snoopy.fan.fa.disney.com> Date: Mon, 21 May 2001 16:57:51 -0700 (PDT) From: Jim.Pirzyk@disney.com Reply-To: Jim.Pirzyk@disney.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: kern/27522: linprocfs:/proc/stat does not handle SMP hosts Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 27522 >Category: kern >Synopsis: linprocfs:/proc/stat does not handle SMP hosts >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon May 21 17:00:02 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Jim Pirzyk >Release: FreeBSD 4.3-RELEASE i386 >Organization: >Environment: System: FreeBSD snoopy.fan.fa.disney.com 4.3-RELEASE FreeBSD 4.3-RELEASE #4: Fri Apr 27 01:14:59 PDT 2001 root@snoopy.fan.fa.disney.com:/auto/roy/dist/pub/FreeBSD/4.3-RELEASE/sys/compile/UP_WORKSTATION i386 >Description: when cat'ing /compat/linux/proc/stat on an smp host, we only get this: cpu 2678 0 1439 605126 disk 0 0 0 0 page 6384 0 swap 0 0 intr 820322 ctxt 198102 btime 990486334 but we should be getting this: cpu 2678 0 1439 605126 cpu0 1339 0 719 302563 cpu1 1339 0 719 302563 disk 0 0 0 0 page 6384 0 swap 0 0 intr 820322 ctxt 198102 btime 990486334 >How-To-Repeat: cat /compat/linux/proc/stat >Fix: --- linprocfs_misc.c.orig Thu Dec 7 05:17:55 2000 +++ linprocfs_misc.c Mon May 21 16:49:01 2001 @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -266,20 +267,39 @@ char *ps; char psbuf[512]; int xlen; + int ncpu, mib[2], i, olen=sizeof(ncpu), plen=0; ps = psbuf; ps += sprintf(ps, - "cpu %ld %ld %ld %ld\n" + "cpu %ld %ld %ld %ld\n", + T2J(cp_time[CP_USER]), + T2J(cp_time[CP_NICE]), + T2J(cp_time[CP_SYS] /*+ cp_time[CP_INTR]*/), + T2J(cp_time[CP_IDLE])); + + mib[0] = CTL_HW; mib[1] = HW_NCPU; + if (kernel_sysctl(p, mib, 2, &ncpu, &olen, NULL, 0, &plen)) + ncpu=1; /* Fake out if the sysctl failed */ + + if ( ncpu > 1 ) { + for (i = 0; i < ncpu; i++) { + ps += sprintf(ps, + "cpu%d %ld %ld %ld %ld\n", + i, + T2J(cp_time[CP_USER]/ncpu), + T2J(cp_time[CP_NICE]/ncpu), + T2J(cp_time[CP_SYS]/ncpu /*+ cp_time[CP_INTR]*/), + T2J(cp_time[CP_IDLE]/ncpu)); + } + } + + ps+= sprintf(ps, "disk 0 0 0 0\n" "page %u %u\n" "swap %u %u\n" "intr %u\n" "ctxt %u\n" "btime %ld\n", - T2J(cp_time[CP_USER]), - T2J(cp_time[CP_NICE]), - T2J(cp_time[CP_SYS] /*+ cp_time[CP_INTR]*/), - T2J(cp_time[CP_IDLE]), cnt.v_vnodepgsin, cnt.v_vnodepgsout, cnt.v_swappgsin, >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message