Lines Matching +full:8 +full:- +full:cpu
1 // SPDX-License-Identifier: GPL-2.0
14 int sz = cpu__max_cpu().cpu + 8 - 1; in get_cpu_set_size()
21 return sz / 8; in get_cpu_set_size()
28 a->orig_cpus = bitmap_zalloc(cpu_set_size * 8); in affinity__setup()
29 if (!a->orig_cpus) in affinity__setup()
30 return -1; in affinity__setup()
31 sched_getaffinity(0, cpu_set_size, (cpu_set_t *)a->orig_cpus); in affinity__setup()
32 a->sched_cpus = bitmap_zalloc(cpu_set_size * 8); in affinity__setup()
33 if (!a->sched_cpus) { in affinity__setup()
34 zfree(&a->orig_cpus); in affinity__setup()
35 return -1; in affinity__setup()
37 bitmap_zero((unsigned long *)a->sched_cpus, cpu_set_size); in affinity__setup()
38 a->changed = false; in affinity__setup()
43 * perf_event_open does an IPI internally to the target CPU.
45 * CPU and then set up all events on that CPU, so we amortize
46 * CPU communication.
48 void affinity__set(struct affinity *a, int cpu) in affinity__set() argument
54 * - if cpu is -1 in affinity__set()
55 * - restrict out of bound access to sched_cpus in affinity__set()
57 if (cpu == -1 || ((cpu >= (cpu_set_size * 8)))) in affinity__set()
60 a->changed = true; in affinity__set()
61 __set_bit(cpu, a->sched_cpus); in affinity__set()
67 sched_setaffinity(0, cpu_set_size, (cpu_set_t *)a->sched_cpus); in affinity__set()
68 __clear_bit(cpu, a->sched_cpus); in affinity__set()
75 if (a->changed) in __affinity__cleanup()
76 sched_setaffinity(0, cpu_set_size, (cpu_set_t *)a->orig_cpus); in __affinity__cleanup()
77 zfree(&a->sched_cpus); in __affinity__cleanup()
78 zfree(&a->orig_cpus); in __affinity__cleanup()