Re: getting processor numbers

From: Ulrich Drepper
Date: Tue Apr 03 2007 - 14:06:35 EST


Andi Kleen wrote:
>> 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.

No. The aux vector cannot be changed after the process is changed. The
memory belong to the process and not the kernel. It must be possible at
any time to get the correct information even if the system changed.


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

No, why? The vdso call would be so inexpensive (just a simple function
call) that it can be done whenever a topology-based decision has to be
made. Use cookies to determine whether nothing has been changed since
the last call etc.


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

That stat solution actually ain't that bad. It takes ~7400 cycles on my
machine.


> If you want it cheap look for some other way.

Well, who's brace enough to submit sys_sysconf() again?

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

Attachment: signature.asc
Description: OpenPGP digital signature