public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "JA Magallón" <jamagallonn@gmail.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Question on /proc/cpuinfo
Date: Fri, 14 Sep 2012 01:18:45 +0200	[thread overview]
Message-ID: <505269D5.30601@gmail.com> (raw)

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

             reply	other threads:[~2012-09-13 23:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13 23:18 JA Magallón [this message]
2012-09-14 12:30 ` Question on /proc/cpuinfo 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=505269D5.30601@gmail.com \
    --to=jamagallonn@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox