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