From Jim.Pirzyk@disney.com  Tue May 22 12:36:41 2001
Return-Path: <Jim.Pirzyk@disney.com>
Received: from mail.disney.com (mail.disney.com [204.128.192.15])
	by hub.freebsd.org (Postfix) with ESMTP id 8C98D37B422
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 22 May 2001 12:36:41 -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 f4MJa4A27258
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 22 May 2001 12:36:05 -0700 (PDT)
Received: from louie.fa.disney.com by pain.corp.disney.com with ESMTP for FreeBSD-gnats-submit@freebsd.org; Tue, 22 May 2001 12:37:27 -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 MAA28778
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 22 May 2001 12:36:38 -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 MAA09413
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 22 May 2001 12:36:37 -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 f4MJaac07081;
	Tue, 22 May 2001 12:36:36 -0700 (PDT)
	(envelope-from Jim.Pirzyk@fa.disney.com)
Message-Id: <200105221936.f4MJaac07081@snoopy.fan.fa.disney.com>
Date: Tue, 22 May 2001 12:36:36 -0700 (PDT)
From: Jim.Pirzyk@disney.com
Reply-To: Jim.Pirzyk@disney.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: linprocfs:/proc/cpuinfo does not handle SMP hosts
X-Send-Pr-Version: 3.113

>Number:         27543
>Category:       kern
>Synopsis:       /proc/cpuinfo does not handle SMP hosts
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 22 12:40:01 PDT 2001
>Closed-Date:    Wed Oct 05 12:30:44 GMT 2005
>Last-Modified:  Wed Oct 05 12:30:44 GMT 2005
>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:
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: des 
Responsible-Changed-When: Sat May 26 10:06:42 PDT 2001 
Responsible-Changed-Why:  
linprocfs is mine. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27543 
State-Changed-From-To: open->suspended 
State-Changed-By: des 
State-Changed-When: Tue Aug 19 03:31:01 PDT 2003 
State-Changed-Why:  


http://www.freebsd.org/cgi/query-pr.cgi?pr=27543 
Responsible-Changed-From-To: des->pirzyk 
Responsible-Changed-By: des 
Responsible-Changed-When: Tue Aug 19 03:32:03 PDT 2003 
Responsible-Changed-Why:  
I committed something similar to -CURRENT, please handle -STABLE yourself. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=27543 
Responsible-Changed-From-To: pirzyk->freebsd-bugs 
Responsible-Changed-By: arved 
Responsible-Changed-When: Fri Apr 23 07:19:26 PDT 2004 
Responsible-Changed-Why:  
jim pirzyk returned his commit bit one year ago 

http://www.freebsd.org/cgi/query-pr.cgi?pr=27543 
State-Changed-From-To: suspended->closed 
State-Changed-By: rodrigc 
State-Changed-When: Wed Oct 5 12:30:11 GMT 2005 
State-Changed-Why:  
Equivalent patch is in RELENG_5 and higher. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=27543 
>Unformatted:
