Summary: | cairo-perf does not deal with cpus larger then 1024 well. | ||
---|---|---|---|
Product: | cairo | Reporter: | Nathan Zimmer <nzimmer> |
Component: | general | Assignee: | Chris Wilson <chris> |
Status: | RESOLVED MOVED | QA Contact: | cairo-bugs mailing list <cairo-bugs> |
Severity: | normal | ||
Priority: | medium | ||
Version: | 1.12.14 | ||
Hardware: | Other | ||
OS: | Linux (All) | ||
Whiteboard: | |||
i915 platform: | i915 features: |
Description
Nathan Zimmer
2013-07-10 16:32:21 UTC
If CPU_SETSIZE doesn't match the value as used by the kernel, sched_getaffinity() is meant to return -EINVAL. Is that the case on your system? I don't think check_cpu_affinity() is particularly relevant when benchmarking, the impact of thread placement is interesting to study, but it is unclear that actually suggesting a particular placement is beneficial. So I can either fixup check_cpu_affinity() to ignore EINVAL or simply move the warning into the README. Ah, you are correct I was misreading the code.
>If CPU_SETSIZE doesn't match the value as used by the kernel, sched_getaffinity() is meant >to return -EINVAL. Is that the case on your system?
They don't need to match but the user does need to provide enough space for the bitmask.
So it works fine on systems where CPU_SETSIZE is greater then or equal to the number of configured cpus.
I don't think ignoring a error status is wise.
If you don't think the check is needed that would be fine by me.
But if someone is insistent here are the two standard ways I found:
#ifdef _SC_NPROCESSORS_CONF
int nrcpus = sysconf(_SC_NPROCESSORS_CONF);
cpu_set_t * cpu_mask;
cpu_mask = CPU_ALLOC(nrcpus);
mask_size = CPU_ALLOC_SIZE(nrcpus);
sched_getaffinity(0, mask_size, &cpu_mask);
cpu_count = CPU_COUNT_S(mask_size, cpu_mask);
CPU_FREE(cpu_mask);
#endif
or if someone has and aversion to _SC_NPROCESSORS_CONF
int nrcpus = 1024;
realloc:
cpus = CPU_ALLOC(nrcpus);
size = CPU_ALLOC_SIZE(nrcpus);
CPU_ZERO_S(size, cpus);
if (sched_getaffinity(0, size, cpus)) {
if( errno == EINVAL && nrcpus < (4096<<4) ) {
CPU_FREE(cpus);
nrcpus <= 1;
goto realloc;
}
fatal("sched_getaffinity", ERR_SYSCALL, "Can't get CPU info\n");
}
cpu_count = CPU_COUNT_S(size, cpus);
CPU_FREE(cpus);
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/161. |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.