summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorJim Warner <james.warner@comcast.net>2022-10-25 00:00:00 -0500
committerCraig Small <csmall@dropbear.xyz>2022-10-25 20:16:12 +1100
commitb89e3230b2baa5b82a2961b240731db95a887f26 (patch)
tree42df1a98d3dc7d94eb9d90f004a9d35cc2198ea7 /library
parenta42336745071f536d5da3c28628d4b5bf7d45b3d (diff)
downloadprocps-ng-b89e3230b2baa5b82a2961b240731db95a887f26.tar.gz
library: adapted for absent 'core id' in /proc/cpuinfo
A big oops on my part - with a big thanks to Dr. Fink. [ this version eliminates an extraneous startup call ] [ to the 'stat_cores_verify' function as superfluous ] Reference(s): https://www.freelists.org/post/procps/For-procpsng4001-No-core-id-in-eg-aarch65-or-ppc64le-proccpuinfo Prototyped by: Dr. Werner Fink <werner@suse.de> Signed-off-by: Jim Warner <james.warner@comcast.net>
Diffstat (limited to 'library')
-rw-r--r--library/stat.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/library/stat.c b/library/stat.c
index 60d7364..a8e0d46 100644
--- a/library/stat.c
+++ b/library/stat.c
@@ -455,7 +455,8 @@ static int stat_core_add (
static void stat_cores_check (
struct stat_info *info)
{
- struct stat_core *core = info->cores;
+ struct stat_core *core;
+#ifndef PRETEND_E_CORES
int p_core = 0;
core = info->cores;
@@ -473,6 +474,16 @@ static void stat_cores_check (
core->type = E_CORE;
} while ((core = core->next));
}
+#else
+ core = info->cores;
+ while (core) {
+ core->type = P_CORE;
+ if (core->thread_1 > ECORE_BEGIN
+ || (core->thread_2 > ECORE_BEGIN))
+ core->type = E_CORE;
+ core = core->next;
+ }
+#endif
} // end: stat_cores_check
#undef E_CORE
@@ -519,19 +530,16 @@ 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;
sscanf(buf, "core id : %d", &a_core);
break;
}
-#ifdef PRETEND_E_CORES
- { static int fake_core;
- if (a_cpu > ECORE_BEGIN) {
- if (!fake_core) fake_core = a_core + 1;
- a_core = fake_core++;
- } }
-#endif
if (!stat_core_add(info, a_core, a_cpu)) {
fclose(fp);
return 0;
@@ -831,8 +839,13 @@ reap_em_again:
/* whoa, if a new cpu was brought online, we better
ensure that no new cores have now become visible */
if (info->cpu_count_hwm < info->cpus.total) {
- if (!stat_cores_verify(info))
- return 1;
+ /* next means it's not the first time, so we'll re-verify.
+ otherwise, procps_stat_new() already setup any cores so
+ that they could be linked above during tics processing. */
+ if (info->cpu_count_hwm) {
+ if (!stat_cores_verify(info))
+ return 1;
+ }
info->cpu_count_hwm = info->cpus.total;
}