Monday, March 29, 2010

See With Your Own Eyes

We ran into an interesting problem today. We have a new piece of hardware in house that we're running some tests on. It has been around long enough that we know things pretty much work, but not long enough that we've looked at everything we're interested in, or know all the details of. Someone asked, "Does this machine have one processor or two?"

Well, now, that's an interesting question. There are a number of different ways we can look at this:

cat /proc/cpuinfo | grep "processor"
That tells us how many processors we have, but processors here really means cores of any type, real or virtual. It could be two quad-core CPUs, or one quad-core CPU with hyperthreading enabled, or two dual-cores CPUs with hyperthreading. Better keep looking....

cat /proc/cpuinfo | grep "core id"
This one sounds good, at first. However, it returned us 0 1 2 3 0 1 2 3. Hmm... that could be one quad-core with hyperthreading, or two quad-cores. Shoot.

cat /proc/cpuinfo | grep "physical id"
This one might work. In theory it shows the socket into which the processor was put (0 or 1). Hope there's no bug there...

The problem with all of these is that we're not talking to the hardware; we're talking to the OS. That's a level of abstraction that introduces all sorts of possible bugs. Maybe we've configured the OS to use one CPU even though there are two physically present. Maybe we've disabled hyperthreading so its counting physical CPUs properly but we could have more.

Sometimes, the only way to be sure is to open the box and see with your own eyes (it turned out to be one quad-core processor with hyperthreading enabled). Believe your evidence, but check your tools with your own eyes just to confirm.

No comments:

Post a Comment