linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: How to get number of physical CPU in linux from user space?
@ 2002-10-25 18:54 Nakajima, Jun
  2002-10-25 19:09 ` [PATCH] " Robert Love
  2002-10-25 19:12 ` chrisl
  0 siblings, 2 replies; 10+ 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] 10+ messages in thread
* RE: [PATCH] How to get number of physical CPU in linux from user  space?
@ 2002-10-25 19:48 Nakajima, Jun
  0 siblings, 0 replies; 10+ messages in thread
From: Nakajima, Jun @ 2002-10-25 19:48 UTC (permalink / raw)
  To: Robert Love, Dave Jones, akpm
  Cc: linux-kernel, Nakajima, Jun, chrisl, Martin J. Bligh

One more request :-)

Actually "processor" keyword was not good in "physical processor ID"
(someone may be grepping it to find out the number of processors), and it
was one of the reasons it was changed/fixed in the AC tree. 

Since (H/W) threads (rather than "siblings") in a CPU is generic (i.e. not
just an Intel thing), I would like to propose this ("physical id" is from
AC). Alan also simplified "number of simblings" to  "siblings". 

+#ifdef CONFIG_SMP
+	if (cpu_has_ht) {
+		seq_printf(m, "physical id\t: %d\n", phys_proc_id[n]);
+		seq_printf(m, "threads\t\t: %d\n", smp_num_siblings);
+	}
+#endif

Thanks,
Jun

-----Original Message-----
From: Robert Love [mailto:rml@tech9.net]
Sent: Friday, October 25, 2002 12:21 PM
To: Dave Jones; akpm@digeo.com
Cc: linux-kernel@vger.kernel.org; Nakajima, Jun; chrisl@vmware.com;
Martin J. Bligh
Subject: Re: [PATCH] How to get number of physical CPU in linux from
user space?


On Fri, 2002-10-25 at 15:13, Dave Jones wrote:

> Should this be wrapped in a if (cpu_has_ht(c)) { }  ?
> Seems silly to be displaying HT information on non-HT CPUs.

I am neutral, but is fine with me. It is just "cpu_has_ht", btw.

Take two...

This displays the physical processor id and number of siblings of each
processor in /proc/cpuinfo.

	Robert Love

 .proc.c.swp |binary
 proc.c      |    7 +++++++
 2 files changed, 7 insertions(+)

diff -urN linux-2.5.44/arch/i386/kernel/cpu/proc.c
linux/arch/i386/kernel/cpu/proc.c
--- linux-2.5.44/arch/i386/kernel/cpu/proc.c	2002-10-19
00:02:29.000000000 -0400
+++ linux/arch/i386/kernel/cpu/proc.c	2002-10-25 15:18:03.000000000 -0400
@@ -17,6 +17,7 @@
 	 * applications want to get the raw CPUID data, they should access
 	 * /dev/cpu/<cpu_nr>/cpuid instead.
 	 */
+	extern int phys_proc_id[NR_CPUS];
 	static char *x86_cap_flags[] = {
 		/* Intel-defined */
 	        "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
@@ -74,6 +75,12 @@
 	/* Cache size */
 	if (c->x86_cache_size >= 0)
 		seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
+#ifdef CONFIG_SMP
+	if (cpu_has_ht) {
+		seq_printf(m, "physical processor ID\t: %d\n",
phys_proc_id[n]);
+		seq_printf(m, "number of siblings\t: %d\n",
smp_num_siblings);
+	}
+#endif
 	
 	/* We use exception 16 if we have hardware math and we've either
seen it or the CPU claims it is internal */
 	fpu_exception = c->hard_math && (ignore_irq13 || cpu_has_fpu);

-
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] 10+ messages in thread
* RE: [PATCH] How to get number of physical CPU in linux from user  space?
@ 2002-10-25 20:38 Nakajima, Jun
  0 siblings, 0 replies; 10+ messages in thread
From: Nakajima, Jun @ 2002-10-25 20:38 UTC (permalink / raw)
  To: 'Robert Love', 'Dave Jones',
	'akpm@digeo.com'
  Cc: 'linux-kernel@vger.kernel.org',
	'chrisl@vmware.com', 'Martin J. Bligh'

You might want to remove __initdata (in smpboot.c):
int __initdata phys_proc_id[NR_CPUS];

Jun Nakajima

-----Original Message-----
From: Nakajima, Jun 
Sent: Friday, October 25, 2002 12:49 PM
To: Robert Love; Dave Jones; akpm@digeo.com
Cc: linux-kernel@vger.kernel.org; Nakajima, Jun; chrisl@vmware.com;
Martin J. Bligh
Subject: RE: [PATCH] How to get number of physical CPU in linux from
user space?


One more request :-)

Actually "processor" keyword was not good in "physical processor ID"
(someone may be grepping it to find out the number of processors), and it
was one of the reasons it was changed/fixed in the AC tree. 

Since (H/W) threads (rather than "siblings") in a CPU is generic (i.e. not
just an Intel thing), I would like to propose this ("physical id" is from
AC). Alan also simplified "number of simblings" to  "siblings". 

+#ifdef CONFIG_SMP
+	if (cpu_has_ht) {
+		seq_printf(m, "physical id\t: %d\n", phys_proc_id[n]);
+		seq_printf(m, "threads\t\t: %d\n", smp_num_siblings);
+	}
+#endif

Thanks,
Jun

-----Original Message-----
From: Robert Love [mailto:rml@tech9.net]
Sent: Friday, October 25, 2002 12:21 PM
To: Dave Jones; akpm@digeo.com
Cc: linux-kernel@vger.kernel.org; Nakajima, Jun; chrisl@vmware.com;
Martin J. Bligh
Subject: Re: [PATCH] How to get number of physical CPU in linux from
user space?


On Fri, 2002-10-25 at 15:13, Dave Jones wrote:

> Should this be wrapped in a if (cpu_has_ht(c)) { }  ?
> Seems silly to be displaying HT information on non-HT CPUs.

I am neutral, but is fine with me. It is just "cpu_has_ht", btw.

Take two...

This displays the physical processor id and number of siblings of each
processor in /proc/cpuinfo.

	Robert Love

 .proc.c.swp |binary
 proc.c      |    7 +++++++
 2 files changed, 7 insertions(+)

diff -urN linux-2.5.44/arch/i386/kernel/cpu/proc.c
linux/arch/i386/kernel/cpu/proc.c
--- linux-2.5.44/arch/i386/kernel/cpu/proc.c	2002-10-19
00:02:29.000000000 -0400
+++ linux/arch/i386/kernel/cpu/proc.c	2002-10-25 15:18:03.000000000 -0400
@@ -17,6 +17,7 @@
 	 * applications want to get the raw CPUID data, they should access
 	 * /dev/cpu/<cpu_nr>/cpuid instead.
 	 */
+	extern int phys_proc_id[NR_CPUS];
 	static char *x86_cap_flags[] = {
 		/* Intel-defined */
 	        "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
@@ -74,6 +75,12 @@
 	/* Cache size */
 	if (c->x86_cache_size >= 0)
 		seq_printf(m, "cache size\t: %d KB\n", c->x86_cache_size);
+#ifdef CONFIG_SMP
+	if (cpu_has_ht) {
+		seq_printf(m, "physical processor ID\t: %d\n",
phys_proc_id[n]);
+		seq_printf(m, "number of siblings\t: %d\n",
smp_num_siblings);
+	}
+#endif
 	
 	/* We use exception 16 if we have hardware math and we've either
seen it or the CPU claims it is internal */
 	fpu_exception = c->hard_math && (ignore_irq13 || cpu_has_fpu);

-
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] 10+ messages in thread

end of thread, other threads:[~2002-11-08 21:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-25 18:54 How to get number of physical CPU in linux from user space? Nakajima, Jun
2002-10-25 19:09 ` [PATCH] " Robert Love
2002-10-25 19:13   ` Dave Jones
2002-01-16 19:35     ` Pavel Machek
2002-10-25 19:21     ` Robert Love
2002-10-25 20:03       ` chrisl
2002-10-25 21:13   ` Alan Cox
2002-10-25 19:12 ` chrisl
  -- strict thread matches above, loose matches on Subject: below --
2002-10-25 19:48 [PATCH] " Nakajima, Jun
2002-10-25 20:38 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).