Re: getting processor numbers

From: Andi Kleen
Date: Tue Apr 03 2007 - 13:58:45 EST


On Tue, Apr 03, 2007 at 10:45:35AM -0700, Ulrich Drepper wrote:
> 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.

There are systems that support node hotplug, like Altix or the larger
IBM or Unisys x86 systems. Basically they are a bunch of
smaller systems connected with cables running a cache coherent network
protocol. With that memory can appear (and disappear but we don't handle
that yet) unexpectedly.

That said we might have some idea of that in advance -- it can
be described in ACPI SRAT -- but the trouble is that many quite
ordinary x86 server systems always describe hotplug zones even though
it is unlikely they will ever get any. Trusting that can be quite
inefficient.

> 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.

The ELF aux vector is exactly that already.

> This page (read-only at userlevel) would contain global information such
> as processor count and topology.

You would still need an event notification mechanism, won't you?
>
>
> But we're getting IMO off topic here. That's a separate and far more
> complicated issue.

Yes I agree. Hotplug is best ignored for now


> 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.

The cost will be still large. Accessing sysfs will be never cheap.
For once anything going through the VFS tens to take a two sometimes
three digit number of locks.

If you want it cheap look for some other way.


-Andi
-
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/