/* * perf_event_open does an IPI internally to the target CPU. * It is more efficient to change perf's affinity to the target * CPU and then set up all events on that CPU, so we amortize * CPU communication.
*/ void affinity__set(struct affinity *a, int cpu)
{ int cpu_set_size = get_cpu_set_size();
/* * Return: * - if cpu is -1 * - restrict out of bound access to sched_cpus
*/ if (cpu == -1 || ((cpu >= (cpu_set_size * 8)))) return;
a->changed = true;
__set_bit(cpu, a->sched_cpus); /* * We ignore errors because affinity is just an optimization. * This could happen for example with isolated CPUs or cpusets. * In this case the IPIs inside the kernel's perf API still work.
*/
sched_setaffinity(0, cpu_set_size, (cpu_set_t *)a->sched_cpus);
__clear_bit(cpu, a->sched_cpus);
}
staticvoid __affinity__cleanup(struct affinity *a)
{ int cpu_set_size = get_cpu_set_size();
if (a->changed)
sched_setaffinity(0, cpu_set_size, (cpu_set_t *)a->orig_cpus);
zfree(&a->sched_cpus);
zfree(&a->orig_cpus);
}
void affinity__cleanup(struct affinity *a)
{ if (a != NULL)
__affinity__cleanup(a);
}
void cpu_map__set_affinity(conststruct perf_cpu_map *cpumap)
{ int cpu_set_size = get_cpu_set_size(); unsignedlong *cpuset = bitmap_zalloc(cpu_set_size * 8); struct perf_cpu cpu; int idx;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.