Re: For procps-ng-4.0.01: No `core id' in e.g. aarch65 or ppc64le /proc/cpuinfo

"Dr. Werner Fink" <[email protected]> Mon, 24 Oct 2022 15:35:00 +0200
Newsgroups gmane.linux.procps.devel
Message-ID <[email protected]>
Maybe the attached patch does avoud this.

On 2022/10/24 14:26:54 +0200, Dr. Werner Fink wrote:
> Hi,
> 
> vmstat fails due an assumption that the tag `core id' is common in
> /proc/cpuinfo ... but it is not ...
> 
> on aarch64 I see
> 
>  processor       : 0
>  BogoMIPS        : 50.00
>  Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
>  CPU implementer : 0x41
>  CPU architecture: 8
>  CPU variant     : 0x3
>  CPU part        : 0xd0c
>  CPU revision    : 1
> 
>  [...]
> 
>  processor       : 79
>  BogoMIPS        : 50.00
>  Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
>  CPU implementer : 0x41
>  CPU architecture: 8
>  CPU variant     : 0x3
>  CPU part        : 0xd0c
>  CPU revision    : 1
> 
> and on ppc64le I see
> 
>  processor       : 0
>  cpu             : POWER9 (architected), altivec supported
>  clock           : 3000.000000MHz
>  revision        : 2.2 (pvr 004e 0202)
> 
>  [...]
> 
>  processor       : 7
>  cpu             : POWER9 (architected), altivec supported
>  clock           : 3000.000000MHz
>  revision        : 2.2 (pvr 004e 0202)
> 
>  timebase        : 512000000
>  platform        : pSeries
>  model           : IBM,9008-22L
>  machine         : CHRP IBM,9008-22L
>  MMU             : Hash
> 
> that is on `processor' is valid.  Therefore stat_cores_verify()
> does fail
> 
>  openat(AT_FDCWD, "/proc/cpuinfo", O_RDONLY) = 4
>  newfstatat(4, "", {st_mode=S_IFREG|0444, st_size=0, ...}, AT_EMPTY_PATH) = 0
>  read(4, "processor\t: 0\nBogoMIPS\t: 50.00\nF"..., 1024) = 1024
>  read(4, "rm aes pmull sha1 sha2 crc32 ato"..., 1024) = 1024
>  read(4, "asimdrdm lrcpc dcpop asimddp ssb"..., 1024) = 1024
>  read(4, "x41\nCPU architecture: 8\nCPU vari"..., 1024) = 1024
>  read(4, " 0xd0c\nCPU revision\t: 1\n\nprocess"..., 1024) = 1024
>  read(4, "0.00\nFeatures\t: fp asimd evtstrm"..., 1024) = 1024
>  read(4, " crc32 atomics fphp asimdhp cpui"..., 1024) = 1024
>  read(4, "op asimddp ssbs\nCPU implementer\t"..., 1024) = 1024
>  read(4, "ure: 8\nCPU variant\t: 0x3\nCPU par"..., 1024) = 1024
>  read(4, "on\t: 1\n\nprocessor\t: 38\nBogoMIPS\t"..., 1024) = 1024
>  read(4, "p asimd evtstrm aes pmull sha1 s"..., 1024) = 1024
>  read(4, "hp asimdhp cpuid asimdrdm lrcpc "..., 1024) = 1024
>  read(4, "PU implementer\t: 0x41\nCPU archit"..., 1024) = 1024
>  read(4, "t\t: 0x3\nCPU part\t: 0xd0c\nCPU rev"..., 1024) = 1024
>  read(4, "\t: 59\nBogoMIPS\t: 50.00\nFeatures\t"..., 1024) = 1024
>  read(4, "es pmull sha1 sha2 crc32 atomics"..., 1024) = 1024
>  read(4, "asimdrdm lrcpc dcpop asimddp ssb"..., 1024) = 1024
>  read(4, "0x41\nCPU architecture: 8\nCPU var"..., 1024) = 1024
>  read(4, ": 0xd0c\nCPU revision\t: 1\n\nproces"..., 1024) = 998
>  read(4, "", 1024)                       = 0
>  close(4)                                = 0
>  write(2, "vmstat: ", 8vmstat: )                 = 8
>  write(2, "Unable to create system stat str"..., 38Unable to create system stat structure) = 38
>  write(2, "\n", 1
>  )                       = 1
>  close(1)                                = 0
>  close(2)                                = 0
>  exit_group(1)                           = ?
> 

Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr
procps-ng-4.0.1-threadless.patch (text/x-patch, 467 B)
--- library/stat.c
+++ library/stat.c	2022-10-24 13:27:10.696894571 +0000
@@ -519,6 +519,10 @@ static int stat_cores_verify (
                 errno = EIO;
                 return 0;
             }
+            if (buf[0] == '\n') {     /* Entry for specific processor is finished */
+                a_core = a_cpu;
+                break;
+            }
             if (buf[0] != 'c') continue;
             if (!strstr(buf, "core id"))
                 continue;
signature.asc (application/pgp-signature, 894 B)
-----BEGIN PGP SIGNATURE-----

iQJgBAABCABKFiEEGwa/WjgpkPvLonW+UOkNVR3Bay4FAmNWlIAsFIAAAAAAFQAO
cGthLWFkZHJlc3NAZ251cGcub3Jnd2VybmVyQHN1c2UuZGUACgkQUOkNVR3Bay5d
BA/+KRULtXYs9oXr7Hshl7k9DJzfjOnkP7BBbxVLfyCZE68QQHJ3fqZfKH2vNOaB
jEzvvH+UyN5Rs1Ul7uMr/0I+dAxVYMi4a3GdrWNVBAjteGRXkpvjjf7L3KddgFo2
ghSY9a1WZISyEzDZwjm81GpkWXUjk6xbJ+TKz+5u29c5CvANQ+KDD8Q5t7jWJ7HU
ahWdIry2GR/WqI/hVRiNwGVS3DMB5nrCvq9tA4wa7VKDLTNfcpmo1v+CEOvZpCVa
xtKmu6D79AOgu1nkHUkXBlkqIT8z+qvmRRduetHewcgtTFQVxhi/Zec5zgq9ogiV
dIQNARSHcDvXs2zq40CfZRtMj8Nr4iDaj4sUU3DLX2KsAg/fApJVd5TXCXQDhegq
MuC1fb7tRTD8JJmcA+25awmeVR5AnM1GmOR50gyTeD5djOqWSDXnUq9R9GwCidHd
OSfsqfUF/pnrfBpeS6V9cqYPyCh0vC3qTKq9ccV9RU/k7Hmk0bLne4V48wsn9Mo0
ApHLHGdjxbyG26wd5WN+AyG35ZXqn8a00aeGeIay7+vlsMqId6xQm7bq98DeVbps
wsehs93wQ5ZCpzqOQNXKLTeuZSrHrFdmggBsfn3KRv+XQV13JDzB5/h4iNKOGs5+
QbUhnTDX0stZzbP4dTfENbG7Cq+rmSTYyGP/KIoRkPcjizE=
=O6UK
-----END PGP SIGNATURE-----