Re: getting processor numbers

From: Ulrich Drepper
Date: Tue Apr 03 2007 - 13:46:15 EST


Andi Kleen wrote:
>>> Topology is dependent on the number of CPUs.
>> Not all of it.
>
> What is not?

Memory banks can exist without a CPU present. The places where you can
plug in memory don't change and so the memory hierarchy can be described.


> Hmm, e.g. in OpenMP you would have another thread that just reads /proc/cpuinfo
> in a loop and starts new threads on new CPUs?
>
> That sounds ...... "expensive"

That's the cost of doing business.

There is an inexpensive solution: finally make the vdso concept a bit
more flexible. You could add a vdso call to get the processor count.
The vdso code itself can use a data page mapped in from the kernel.
This page (read-only at userlevel) would contain global information such
as processor count and topology.


But we're getting IMO off topic here. That's a separate and far more
complicated issue.

Here we now have the concrete issue that determining the CPU count is
terribly expensive and there is a simple proposal to make it faster by
keeping /sys/devices/system/cpu/ free from anything but cpu* directories.

--
â Ulrich Drepper â Red Hat, Inc. â 444 Castro St â Mountain View, CA â

Attachment: signature.asc
Description: OpenPGP digital signature