Bug 9497
Summary: | Procinfo incorrectly lists number of CPUs on i386 SMP | ||
---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | Travis Shugarts <shugarts> |
Component: | procinfo | Assignee: | Mike A. Harris <mharris> |
Status: | CLOSED RAWHIDE | QA Contact: | David Lawrence <dkl> |
Severity: | low | Docs Contact: | |
Priority: | medium | ||
Version: | 6.2 | ||
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i386 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | procinfo-18-11 | Doc Type: | Bug Fix |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2004-01-17 07:16:20 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Travis Shugarts
2000-02-16 20:44:35 UTC
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 |