linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to get number of physical CPU in linux from user space?
@ 2002-10-24 23:02 chrisl
  2002-10-25  0:47 ` Andrew Walrond
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: chrisl @ 2002-10-24 23:02 UTC (permalink / raw)
  To: linux-kernel

It seems that /proc/cpuinfo will return the number of logical CPU.
If the machine has Intel Hyper-Thread enabled, that number is bigger
than physical CPU number. Usually twice as big.

My question is, what is the reliable way for user space program
to detect the number of physical CPU in the current machine?

If in it is in the kernel, I can read from cpu_sibling_map[]
or phys_cpu_id[]. But it seems not easy read that from
user space.

Of course I can do "gdb /proc/kcore" to get them. But is there
any better way?

Thanks in advance.

Chris




^ permalink raw reply	[flat|nested] 12+ messages in thread
* RE: How to get number of physical CPU in linux from user space?
@ 2002-10-25 18:54 Nakajima, Jun
  2002-10-25 19:12 ` chrisl
  0 siblings, 1 reply; 12+ messages in thread
From: Nakajima, Jun @ 2002-10-25 18:54 UTC (permalink / raw)
  To: chrisl, Martin J. Bligh; +Cc: linux-kernel

Recent distributions or the AC tree has additional fields in /proc/cpu,
which tell
- physical package id
- number of threads 
for each CPU.

Using this info, you should be able to detect it. The problem is that they
are not using the same keywords. I'm asking them to make those fields
consistent.

Thanks,
Jun

-----Original Message-----
From: chrisl@vmware.com [mailto:chrisl@vmware.com]
Sent: Friday, October 25, 2002 11:20 AM
To: Martin J. Bligh
Cc: linux-kernel@vger.kernel.org
Subject: Re: How to get number of physical CPU in linux from user space?



On Fri, Oct 25, 2002 at 01:27:00AM -0700, Martin J. Bligh wrote:
> Define "physical CPU number" ;-) If you want to deteact which

I mean the number of cpu chip you can count on the mother board.

> ones are paired up, I believe that if all but the last bit
> of the apicid is the same, they're siblings. You might have to
> dig the apicid out of the bootlog if the cpuinfo stuff doesn't
> tell you.

And you are right. Those apicid, after mask out the siblings,
are put in phys_cpu_id[] array in kernel.

I think about look at bootlog too, but that is not a reliable
way because bootlog might already been flush out after some
time.

Cheers

Chris



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 12+ messages in thread
* RE: How to get number of physical CPU in linux from user space?
@ 2002-10-25 19:05 Nakajima, Jun
  0 siblings, 0 replies; 12+ messages in thread
From: Nakajima, Jun @ 2002-10-25 19:05 UTC (permalink / raw)
  To: Nakajima, Jun, chrisl, Martin J. Bligh; +Cc: linux-kernel

I meant /proc/cpuinfo

Thanks,
Jun

-----Original Message-----
From: Nakajima, Jun 
Sent: Friday, October 25, 2002 11:53 AM
To: 'chrisl@vmware.com'; Martin J. Bligh
Cc: linux-kernel@vger.kernel.org
Subject: RE: How to get number of physical CPU in linux from user space?


Recent distributions or the AC tree has additional fields in /proc/cpu,
which tell
- physical package id
- number of threads 
for each CPU.

Using this info, you should be able to detect it. The problem is that they
are not using the same keywords. I'm asking them to make those fields
consistent.

Thanks,
Jun

-----Original Message-----
From: chrisl@vmware.com [mailto:chrisl@vmware.com]
Sent: Friday, October 25, 2002 11:20 AM
To: Martin J. Bligh
Cc: linux-kernel@vger.kernel.org
Subject: Re: How to get number of physical CPU in linux from user space?



On Fri, Oct 25, 2002 at 01:27:00AM -0700, Martin J. Bligh wrote:
> Define "physical CPU number" ;-) If you want to deteact which

I mean the number of cpu chip you can count on the mother board.

> ones are paired up, I believe that if all but the last bit
> of the apicid is the same, they're siblings. You might have to
> dig the apicid out of the bootlog if the cpuinfo stuff doesn't
> tell you.

And you are right. Those apicid, after mask out the siblings,
are put in phys_cpu_id[] array in kernel.

I think about look at bootlog too, but that is not a reliable
way because bootlog might already been flush out after some
time.

Cheers

Chris



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2002-10-25 19:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-24 23:02 How to get number of physical CPU in linux from user space? chrisl
2002-10-25  0:47 ` Andrew Walrond
2002-10-25  8:26 ` Gianni Tedesco
2002-10-25  8:27 ` Martin J. Bligh
2002-10-25 18:20   ` chrisl
2002-10-25 18:35     ` David T Hollis
2002-10-25 18:52     ` Martin J. Bligh
2002-10-25 12:38 ` Dave Jones
2002-10-25 19:07   ` chrisl
  -- strict thread matches above, loose matches on Subject: below --
2002-10-25 18:54 Nakajima, Jun
2002-10-25 19:12 ` chrisl
2002-10-25 19:05 Nakajima, Jun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).