<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - cairo-perf does not deal with cpus larger then 1024 well."
href="https://bugs.freedesktop.org/show_bug.cgi?id=66783#c2">Comment # 2</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW --- - cairo-perf does not deal with cpus larger then 1024 well."
href="https://bugs.freedesktop.org/show_bug.cgi?id=66783">bug 66783</a>
from <span class="vcard"><a class="email" href="mailto:nzimmer@sgi.com" title="Nathan Zimmer <nzimmer@sgi.com>"> <span class="fn">Nathan Zimmer</span></a>
</span></b>
<pre>Ah, you are correct I was misreading the code.
<span class="quote">>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?</span >
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);</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
</ul>
</body>
</html>