blob: 43a5281d4376ee1e43bae8d004998ebb436d7e84 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/* Copyright (c) 2015, Linaro Limited
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <odp_posix_extensions.h>
#include <sched.h>
#include <pthread.h>
#include <odp/cpumask.h>
#include <odp_internal.h>
#include <odp_debug_internal.h>
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;
}
|