Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've got an Intel i7 2700k here, and I'd like to know how I can tell which processors are physical and which are virtual (ie: hyperthreading). I'm currently running a Conky script to display my CPU temps, frequencies, and loads, but I'm not sure that I've done it right:

awesome

I've written my own script to get temperatures and frequencies from i7z, but these only correspond to physical cores. I'm currently displaying each core like this:

${cpu cpu1} ${lua display_temp 0} ${lua display_load 0}
${cpu cpu2}
${cpu cpu3} ${lua display_temp 1} ${lua display_load 1}
${cpu cpu4}
# ...

I'm not sure that this is right, because of the loads and temperatures I see sometimes. In /proc/cpuinfo, how are cores sorted? First all physical then all virtual? Each physical core then its virtual core(s)? How are they sorted?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

You can know about each processor core by examining each cpuinfo entry:

processor       : 0
[...]
physical id     : 0
siblings        : 8
core id         : 0
cpu cores       : 4
apicid          : 0

processor       : 1
[...]
physical id     : 0
siblings        : 8
core id         : 1
cpu cores       : 4
apicid          : 2 

processor       : 2
[...]
physical id     : 0
siblings        : 8
core id         : 2
cpu cores       : 4
apicid          : 4 

processor       : 3
[...]
physical id     : 0
siblings        : 8
core id         : 3
cpu cores       : 4
apicid          : 6

processor       : 4
[...]
physical id     : 0
siblings        : 8
core id         : 0
cpu cores       : 4
apicid          : 1

[and so on]

physical id shows the identifier of the processor. Unless you have a multiprocessor setup (having two separate, physical processor in a machine), it will always be 0.

siblings show the number of processor attached to the same physical processor.

core id show the identifier of the current core, out to a total of cpu cores. You can use this information to correlate which virtual processor goes into a single core.

acpiid (and original acpiid) show the number of the (virtual) processor, as given by the bios.

Note that there 8 siblings and 4 cores, so there is 2 virtual processor per core. There is no distinction between "virtual" or "real" in hyperthreading. but using this information you can associate which processors are from the same core.

share|improve this answer

If you see the 'ht' flag in /proc/cpuinfo then you have hyper-threading enabled and each real core is split into multiple threads, there is no concept of real thread and virtual thread: both are effectively virtual.

What you may wish to investigate is comparing cores and sockets, use the 'physical id' topology identifier to group cores together.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.