Date: Tue, 22 May 2001 12:36:36 -0700 (PDT) From: Jim.Pirzyk@disney.com To: FreeBSD-gnats-submit@freebsd.org Subject: kern/27543: linprocfs:/proc/cpuinfo does not handle SMP hosts Message-ID: <200105221936.f4MJaac07081@snoopy.fan.fa.disney.com>
next in thread | raw e-mail | index | archive | help
>Number: 27543 >Category: kern >Synopsis: /proc/cpuinfo 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: Tue May 22 12:40:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Jim Pirzyk >Release: FreeBSD 4.3-RELEASE i386 >Organization: >Environment: System: FreeBSD snoopy 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: cat'ing /compat/linux/proc/cpuinfo only reports information on the first cpu, not all of them: Jim.Pirzyk@brother:/usr/local/etc/rc.d 36>cat /compat/linux/proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 15 stepping : 6 flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr xmm cpu MHz : 930.96 bogomips : 930.96 Where it should be this: Jim.Pirzyk@brother:/usr/local/etc/rc.d 36>cat /compat/linux/proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 15 stepping : 6 flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr xmm cpu MHz : 930.96 bogomips : 930.96 processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 15 stepping : 6 flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr xmm cpu MHz : 930.96 bogomips : 930.96 >How-To-Repeat: cat /compat/linux/proc/cpuinfo on an smp host. >Fix: --- linprocfs_misc.c.orig Thu Dec 7 05:17:55 2000 +++ linprocfs_misc.c Tue May 22 12:28:54 2001 @@ -52,6 +52,7 @@ #include <sys/tty.h> #include <sys/vnode.h> #include <sys/lock.h> +#include <sys/sysctl.h> #include <vm/vm.h> #include <vm/pmap.h> @@ -174,7 +175,7 @@ int xlen; char psbuf[512]; /* XXX - conservative */ int class; - int i; + int ncpu, mib[2], i, cpucnt, olen=sizeof(ncpu), plen=0; #if 0 extern char *cpu_model; /* Yuck */ #endif @@ -217,14 +218,22 @@ break; } + 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 */ + ps = psbuf; - ps += sprintf(ps, + + for (cpucnt = 0; cpucnt < ncpu; cpucnt++) { + if ( cpucnt ) ps += sprintf (ps, "\n"); + + ps += sprintf(ps, "processor\t: %d\n" "vendor_id\t: %.20s\n" "cpu family\t: %d\n" "model\t\t: %d\n" "stepping\t: %d\n", - 0, cpu_vendor, class, cpu, cpu_id & 0xf); + cpucnt, cpu_vendor, class, cpu, cpu_id & 0xf); ps += sprintf(ps, "flags\t\t:"); @@ -248,6 +257,7 @@ (tsc_freq + 4999) / 1000000, ((tsc_freq + 4999) / 10000) % 100); } + } xlen = ps - psbuf; xlen -= uio->uio_offset; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200105221936.f4MJaac07081>