aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/odp_init.c
diff options
context:
space:
mode:
authorGary S. Robertson <gary.robertson@linaro.org>2016-03-31 08:08:12 -0500
committerMaxim Uvarov <maxim.uvarov@linaro.org>2016-04-11 15:40:35 +0300
commit93f0362c2d1228692f7ee8c5173d109c2029f2cf (patch)
treedf76b2f014066fed0ea4cb83aea41af1a04bf1dd /platform/linux-generic/odp_init.c
parent1d80807a2aa9b97e8fa750b00684fe2b22b80540 (diff)
linux-generic: Make cpu detection work with NO_HZ_FULL
sched_getaffinity() and pthread_getaffinity_np() do not return an accurate mask of all CPUs in the machine when the kernel is compiled with NO_HZ_FULL support. See Linaro BUG 2027 for details. https://bugs.linaro.org/show_bug.cgi?id=2027 This code replaces the 'getaffinity' based CPU discovery logic -and- removes any exclusivity between default control and worker cpumasks, based on an assumption that external cpumask specifications will segregate CPUs if needed. The results of these changes which address BUG 2027 are: (1) all CPUs known to the kernel at boot time are considered for use by ODP regardless of the default CPU affinity masks set by the kernel scheduler, (2) the default control and worker cpumasks are given reasonable values based on the set of installed CPUs Also - this code: (a) adds control and worker cpumasks to the linux-generic global data (b) adds logic to odp_cpumask.c to initialize these masks (c) calls the new cpumask initialization logic from odp_init_global() (d) reduces odp_cpumask_default_control() and odp_cpumask_default_worker() to use the content of these new cpumasks without modification. These changes provide prerequisite infrastructure for pending changes which will allow ODP to accept cpumasks passed in from external entities such as a provisioning service. Signed-off-by: Gary S. Robertson <gary.robertson@linaro.org> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'platform/linux-generic/odp_init.c')
-rw-r--r--platform/linux-generic/odp_init.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index 284cecf05..56b1e9585 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -3,11 +3,9 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-
#include <odp/api/init.h>
-#include <odp_internal.h>
-#include <odp/api/debug.h>
#include <odp_debug_internal.h>
+#include <odp/api/debug.h>
#include <unistd.h>
struct odp_global_data_s odp_global_data;
@@ -29,6 +27,12 @@ int odp_init_global(odp_instance_t *instance,
odp_global_data.abort_fn = params->abort_fn;
}
+ if (odp_cpumask_init_global()) {
+ ODP_ERR("ODP cpumask init failed.\n");
+ goto init_failed;
+ }
+ stage = CPUMASK_INIT;
+
if (odp_time_init_global()) {
ODP_ERR("ODP time init failed.\n");
goto init_failed;
@@ -222,6 +226,13 @@ int _odp_term_global(enum init_stage stage)
}
/* Fall through */
+ case CPUMASK_INIT:
+ if (odp_cpumask_term_global()) {
+ ODP_ERR("ODP cpumask term failed.\n");
+ rc = -1;
+ }
+ /* Fall through */
+
case NO_INIT:
;
}