[cairo-bugs] [Bug 66783] cairo-perf does not deal with cpus larger then 1024 well.

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Wed Jul 10 12:36:20 PDT 2013


--- Comment #2 from Nathan Zimmer <nzimmer at sgi.com> ---
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
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:

        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);

or if someone has and aversion to _SC_NPROCESSORS_CONF

        int nrcpus = 1024;
        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) ) {
                        nrcpus <= 1;
                        goto realloc;
                fatal("sched_getaffinity", ERR_SYSCALL, "Can't get CPU
        cpu_count = CPU_COUNT_S(size, cpus);

You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo-bugs/attachments/20130710/e2984b80/attachment.html>

More information about the cairo-bugs mailing list