Procinfo counts incorrectly the number of processors on i386 based smp systems. /proc/cpuinfo correctly lists the number of processors, but procinfo always returns 1CPU.
The below patch should fix the problem. --- procinfo.old Wed Feb 16 16:18:43 2000 +++ procinfo.c Wed Feb 16 16:34:39 2000 @@ -786,9 +786,9 @@ while (fgets (line, sizeof (line), cpuinfofp)) if (!strncmp ("processor", line, 9)) /* intel */ nr_cpus++; - else if (strncmp ("ncpus active", line, 12)) /* sparc */ + else if (!strncmp ("ncpus active", line, 12)) /* sparc */ nr_cpus = atoi(line+19); - else if (strncmp ("cpus detected", line, 13)) /* alpha */ + else if (!strncmp ("cpus detected", line, 13)) /* alpha */ nr_cpus = atoi(line+27); fclose (cpuinfofp); }
Thanks, fixed in 17-4
On every sparc, procinfo -a reports 3 CPU [ sparc2] or [ ultra] Linux 2.2.14-5.0 (root@lisa) (gcc egcs-2.92.11) #1 3CPU [ultra1]
Fixed
Ick, this is insane. Detecting CPU count by parsing proc files. Using sysconf is both more portable, and less likely to encounter random kernel modification skewage problems.
Fixed to be portable using sysconf as mentioned above: --- procinfo-18/procinfo.c.mharris-use-sysconf 2004-01-16 15:40:37.000000000 -0500 +++ procinfo-18/procinfo.c 2004-01-17 02:01:16.000000000 -0500 @@ -837,19 +837,7 @@ } /* Count number of CPUs */ - cpuinfofp = myfopen (PROC_DIR "cpuinfo"); - if (cpuinfofp) { - while (fgets (line, sizeof (line), cpuinfofp)) - if (!strncmp ("processor", line, 9)) /* intel */ - nr_cpus++; - else if (!strncmp ("ncpus ", line, 6)) /* sparc */ - nr_cpus = atoi(line+19); - else if (!strncmp ("cpus detected", line, 13)) /* alpha */ - nr_cpus = atoi(line+27); - fclose (cpuinfofp); - } - if (nr_cpus == 0) - nr_cpus = 1; + nr_cpus = sysconf (_SC_NPROCESSORS_ONLN); /* Gets called from winsz(), but in case stdout is redirected: */ version = make_version (versionfp); Built into rawhide as procinfo-18-11