aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2017-04-20 10:10:03 +0200
committerLukas Larsson <[email protected]>2017-04-20 10:10:03 +0200
commitc6e15b7226fab368babb60704e863cb17ba627ba (patch)
tree70f5f8c806fe29e9724c56c3402941043378ae34 /erts
parent72e0725c30960541e1209a45f6a9e56fecc3be95 (diff)
parentbb18d3305363ed9ef9eaead6fa2d796f56b1749c (diff)
downloadotp-c6e15b7226fab368babb60704e863cb17ba627ba.tar.gz
otp-c6e15b7226fab368babb60704e863cb17ba627ba.tar.bz2
otp-c6e15b7226fab368babb60704e863cb17ba627ba.zip
Merge branch 'lukas/erts/erlexec_docker_cpuset-cpus/OTP-14352'
* lukas/erts/erlexec_docker_cpuset-cpus/OTP-14352: erts: Fix erlexec to handle mismatch in sysconf and proc fs
Diffstat (limited to 'erts')
-rw-r--r--erts/lib_src/common/erl_misc_utils.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/erts/lib_src/common/erl_misc_utils.c b/erts/lib_src/common/erl_misc_utils.c
index 8186463b9c..2ffb23bf54 100644
--- a/erts/lib_src/common/erl_misc_utils.c
+++ b/erts/lib_src/common/erl_misc_utils.c
@@ -842,7 +842,7 @@ read_topology(erts_cpu_info_t *cpuinfo)
cpuinfo->topology[ix].logical = -1;
}
- ix = -1;
+ ix = 0;
if (realpath(ERTS_SYS_NODE_PATH, npath)) {
ndir = opendir(npath);
@@ -886,6 +886,7 @@ read_topology(erts_cpu_info_t *cpuinfo)
cdir = NULL;
break;
}
+
if (sscanf(cde->d_name, "cpu%d", &cpu_id) == 1) {
char buf[50]; /* Much more than enough for an integer */
int processor_id, core_id;
@@ -906,23 +907,33 @@ read_topology(erts_cpu_info_t *cpuinfo)
if (sscanf(buf, "%d", &core_id) != 1)
continue;
+ /*
+ * The number of CPUs that proc fs presents is greater
+ * then the number of CPUs configured in sysconf.
+ * This has been known to happen in docker. When this
+ * happens we refuse to give a CPU topology.
+ */
+ if (ix >= cpuinfo->configured)
+ goto error;
+
/*
* We now know node id, processor id, and
* core id of the logical processor with
* the cpu id 'cpu_id'.
*/
- ix++;
cpuinfo->topology[ix].node = node_id;
cpuinfo->topology[ix].processor = processor_id;
cpuinfo->topology[ix].processor_node = -1; /* Fixed later */
cpuinfo->topology[ix].core = core_id;
cpuinfo->topology[ix].thread = 0; /* we'll numerate later */
cpuinfo->topology[ix].logical = cpu_id;
+ ix++;
+
}
}
} while (got_nodes);
- res = ix+1;
+ res = ix;
if (!res || res < cpuinfo->online)
res = 0;