Re: getting processor numbers

From: Andrew Morton
Date: Tue Apr 03 2007 - 16:16:51 EST


On Tue, 03 Apr 2007 09:54:46 -0700
Ulrich Drepper <drepper@xxxxxxxxxx> wrote:

> More and more code depends on knowing the number of processors in the
> system to efficiently scale the code. E.g., in OpenMP it is used by
> default to determine how many threads to create. Creating more threads
> than there are processors/cores doesn't make sense.

but... It would be a mistake for an application to assume that it is
allowed to _use_ all the present CPUs. People can and do run applications
within cpusets, and under sched_setaffinity().

So I'd have thought that in general an application should be querying its
present affinity mask - something like sched_getaffinity()? That fixes the
CPU hotplug issues too, of course.

But we discussed this all a couple years back and it was decided that
sched_getaffinity() was unsuitable. I remember at the time not really
understanding why?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/