/* Copyright (c) 2015, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include #include #include #include #include #include int odp_cpumask_default_worker(odp_cpumask_t *mask, int num) { int cpu, i; cpu_set_t cpuset; odp_cpumask_zero(mask); cpuset = _odp_cpuset(); /* * If no user supplied number or it's too large, then attempt * to use all CPUs */ if (0 == num || CPU_SETSIZE < num) num = CPU_COUNT(&cpuset); /* build the mask, allocating down from highest numbered CPU */ for (cpu = 0, i = CPU_SETSIZE - 1; i >= 0 && cpu < num; --i) { if (CPU_ISSET(i, &cpuset)) { odp_cpumask_set(mask, i); cpu++; } } if (odp_cpumask_isset(mask, 0)) ODP_DBG("\n\tCPU0 will be used for both control and worker threads,\n" "\tthis will likely have a performance impact on the worker thread.\n"); return cpu; } int odp_cpumask_default_control(odp_cpumask_t *mask, int num ODP_UNUSED) { odp_cpumask_zero(mask); /* By default all control threads on CPU 0 */ odp_cpumask_set(mask, 0); return 1; }