On Wed, Jul 23, 2003 at 02:59:25PM -0700, Robert Walsh wrote:
> On Wed, 2003-07-23 at 14:22, Rick Mohr wrote:
> > So it looks like the recipe should be:
> > 
> > Is the ht flag set?  If not, there is no hyperthreading.  If yes, check
> > for the physical id field.  If it is not present, then assume that each
> > CPU is distinct.  If physical id is present, looking at sibling number to
> > determine if there are multipple hyperthreading cores. (Is it even 
> > possible to have a physical id with no sibling field??)
> > 
> > Maybe a sanity check would be, if siblings=2, make sure there are 2 CPUs
> > with the same physical id.
> 
> I would do it like this:
> 
>   HT flag exists?
>     No: no hyperthreading, so count this as one CPU
>     Yes:
>       Physical id field _exists_?
>         No: need to figure out something else...
>         Yes: count this as one CPU if we already haven't seen this physical id
> 
> The difficult bit is figuring out what to do if you're running on a
> kernel that doesn't have the magic patch that RedHat is using. 
> Theoretically, you could use the CPUID instruction yourself to figure
> out what they're figuring out, but the problem with that is that you
> have no control over what CPU you're running it on unless you're running
> on 2.5.  A compromise might be to assume that all CPUs in the box are
> identical so that you don't care what CPU it does run on - just get the
> number of siblings from one CPU, count the number of entries in
> /proc/cpuinfo and divide by the number of siblings.
> 
> Of course this has the disadvantage that it's fugly and might actually
> break on some real-world oddly-configured systems.

I don't think you need to worry about this too much since all MP capable
cpus with the HT flag set are Xeons which actually support two siblings.
I would point out that if you go to all the trouble of removing the
logical CPUs from the output, someone is probalby going to get annoyed
that you did that because they wanted to see them in the output.  After
all, for some applictions, treating each logical CPU as a physical CPU
is a good fit.

-- Brooks

-- 
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

Attachment: pgp1RTzkjG9nt.pgp
Description: PGP signature

Reply via email to