* Question on /proc/cpuinfo
@ 2012-09-13 22:37 JA Magallón
0 siblings, 0 replies; 4+ messages in thread
From: JA Magallón @ 2012-09-13 22:37 UTC (permalink / raw)
To: Linux Kernel
Hi...
Probably it is a stupid question, but... I wan to count the number of
processors, cores and threads on a linux system. I do it by reading /proc/cpuinfo.
The problem is that the meaning of 'cpu cores' and 'siblings' seems to have changed
over time. Nowadays, it looks like this:
Dual P4 Xeon with HT:
processor : 0
siblings : 1
cpu cores : 1
processor : 1
siblings : 1
cpu cores : 1
processor : 2
siblings : 1
cpu cores : 0
processor : 3
siblings : 1
cpu cores : 0
Single Atom N450
processor : 0
siblings : 1
cpu cores : 1
processor : 1
siblings : 1
cpu cores : 0
So it just sets logical 'fake' processors that have no core but one thread.
And process would just be count 'processor' lines, add up 'cpu cores' lines
and also add 'siblings' lines. Values of the latter ones are associated
with the ligical processor, no the physical one.
Bu I have seen in google that in old docs and mail threads the values were
associated with physical_id's, so in fact for the atom you would get something
like
processor : 0
siblings : 2
cpu cores : 1
processor : 1
siblings : 2
cpu cores : 1
because both processors were in the same physical one.
Since when is it safe to read things the modern way (kernel version ?).
Is there a better procedure to get this info ?
--
J.A. Magallon <jamagallon()ono!com> \ Winter is coming...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Question on /proc/cpuinfo
@ 2012-09-13 23:18 JA Magallón
2012-09-14 12:30 ` Cong Wang
0 siblings, 1 reply; 4+ messages in thread
From: JA Magallón @ 2012-09-13 23:18 UTC (permalink / raw)
To: Linux Kernel
Hi...
Probably it is a stupid question, but... I wan to count the number of
processors, cores and threads on a linux system. I do it by reading /proc/cpuinfo.
The problem is that the meaning of 'cpu cores' and 'siblings' seems to have changed
over time. Nowadays, it looks like this:
Dual P4 Xeon with HT:
processor : 0
siblings : 1
cpu cores : 1
processor : 1
siblings : 1
cpu cores : 1
processor : 2
siblings : 1
cpu cores : 0
processor : 3
siblings : 1
cpu cores : 0
Single Atom N450
processor : 0
siblings : 1
cpu cores : 1
processor : 1
siblings : 1
cpu cores : 0
So it just sets logical 'fake' processors that have no core but one thread.
And process would just be count 'processor' lines, add up 'cpu cores' lines
and also add 'siblings' lines. Values of the latter ones are associated
with the ligical processor, no the physical one.
Bu I have seen in google that in old docs and mail threads the values were
associated with physical_id's, so in fact for the atom you would get something
like
processor : 0
siblings : 2
cpu cores : 1
processor : 1
siblings : 2
cpu cores : 1
because both processors were in the same physical one.
Since when is it safe to read things the modern way (kernel version ?).
Is there a better procedure to get this info ?
--
J.A. Magallon <jamagallonn()gmail!com> \ Winter is coming...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Question on /proc/cpuinfo
2012-09-13 23:18 Question on /proc/cpuinfo JA Magallón
@ 2012-09-14 12:30 ` Cong Wang
2012-09-23 11:52 ` Jan Engelhardt
0 siblings, 1 reply; 4+ messages in thread
From: Cong Wang @ 2012-09-14 12:30 UTC (permalink / raw)
To: JA Magallón; +Cc: Linux Kernel
On 09/14/2012 07:18 AM, JA Magallón wrote:
> Hi...
>
> Probably it is a stupid question, but... I wan to count the number of
> processors, cores and threads on a linux system. I do it by reading
> /proc/cpuinfo.
>
...
>
> Since when is it safe to read things the modern way (kernel version ?).
> Is there a better procedure to get this info ?
>
Probably lscpu(1) is better for you, on my laptop it outputs:
% lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0,1
Thread(s) per core: 1
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 23
Stepping: 10
CPU MHz: 2401.000
BogoMIPS: 4788.03
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 3072K
NUMA node0 CPU(s): 0,1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Question on /proc/cpuinfo
2012-09-14 12:30 ` Cong Wang
@ 2012-09-23 11:52 ` Jan Engelhardt
0 siblings, 0 replies; 4+ messages in thread
From: Jan Engelhardt @ 2012-09-23 11:52 UTC (permalink / raw)
To: Cong Wang; +Cc: JA Magallón, Linux Kernel
On Friday 2012-09-14 14:30, Cong Wang wrote:
> On 09/14/2012 07:18 AM, JA Magallón wrote:
>> Hi...
>>
>> Probably it is a stupid question, but... I wan to count the number of
>> processors, cores and threads on a linux system. I do it by reading
>> /proc/cpuinfo.
>
> Probably lscpu(1) is better for you, on my laptop it outputs:
Programmatically (for scripts), you want to count the number
of /sys/devices/system/cpu/cpu[0-9]*. Grepping around output
meant for humans (cpuinfo, lscpu) is always a bad idea.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-23 11:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-13 23:18 Question on /proc/cpuinfo JA Magallón
2012-09-14 12:30 ` Cong Wang
2012-09-23 11:52 ` Jan Engelhardt
-- strict thread matches above, loose matches on Subject: below --
2012-09-13 22:37 JA Magallón
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox