public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Hyperthreading: easiest userland method?
@ 2003-09-12 14:41 Dan Behman
  2003-09-12 14:55 ` dada1
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dan Behman @ 2003-09-12 14:41 UTC (permalink / raw)
  To: linux-kernel

Hi,

I have a need to programmatically determine whether or not hyperthreading
is enabled (and in use) for licensing reasons in my application.
Currently, I know of two ways to do this:

1) parse /proc/cpuinfo for "processor id"
2) port Intel's documented method (written for Windows) to directly query
the CPUs

Both methods have drawbacks - 1) relying on specific text that could change
is a bad idea; 2) this doesn't take into account whether or not Linux
and/or the BIOS is making use of the hyperthreading.

>From scouring the archives and the net, it doesn't seem like there's any
API that currently exists, but perhaps I've missed something.
/proc/cpuinfo gathers its information from somewhere - is there a way in
userland to bypass /proc/cpuinfo and directly get this data manually?

I'm interested in both 2.4 and 2.6 implementations and would like to be
personally CC'ed on any repsonses.

Thanks in advance!

Dan Behman.
IBM Canada Ltd.


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

* Re: Hyperthreading: easiest userland method?
  2003-09-12 14:41 Hyperthreading: easiest userland method? Dan Behman
@ 2003-09-12 14:55 ` dada1
  2003-09-12 15:10 ` Chris Friesen
  2003-09-12 16:12 ` Dave Hansen
  2 siblings, 0 replies; 5+ messages in thread
From: dada1 @ 2003-09-12 14:55 UTC (permalink / raw)
  To: linux-kernel, Dan Behman

Hi

Have you checked x86info ? http://www.codemonkey.org.uk/projects/x86info/

You may ask Dave Jones to add a single option that could never change, and
returns TRUE or FALSE, depending on HT enabled CPUS.


From: "Dan Behman" <dbehman@ca.ibm.com>
> Hi,
>
> I have a need to programmatically determine whether or not hyperthreading
> is enabled (and in use) for licensing reasons in my application.
> Currently, I know of two ways to do this:
>
> 1) parse /proc/cpuinfo for "processor id"
> 2) port Intel's documented method (written for Windows) to directly query
> the CPUs
>
> Both methods have drawbacks - 1) relying on specific text that could
change
> is a bad idea; 2) this doesn't take into account whether or not Linux
> and/or the BIOS is making use of the hyperthreading.
>
> >From scouring the archives and the net, it doesn't seem like there's any
> API that currently exists, but perhaps I've missed something.
> /proc/cpuinfo gathers its information from somewhere - is there a way in
> userland to bypass /proc/cpuinfo and directly get this data manually?
>
> I'm interested in both 2.4 and 2.6 implementations and would like to be
> personally CC'ed on any repsonses.
>
> Thanks in advance!
>
> Dan Behman.
> IBM Canada Ltd.


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

* Re: Hyperthreading: easiest userland method?
  2003-09-12 14:41 Hyperthreading: easiest userland method? Dan Behman
  2003-09-12 14:55 ` dada1
@ 2003-09-12 15:10 ` Chris Friesen
  2003-09-12 16:12 ` Dave Hansen
  2 siblings, 0 replies; 5+ messages in thread
From: Chris Friesen @ 2003-09-12 15:10 UTC (permalink / raw)
  To: Dan Behman; +Cc: linux-kernel

Dan Behman wrote:
> Hi,
> 
> I have a need to programmatically determine whether or not hyperthreading
> is enabled (and in use) for licensing reasons in my application.
> Currently, I know of two ways to do this:


> From scouring the archives and the net, it doesn't seem like there's any
> API that currently exists, but perhaps I've missed something.
> /proc/cpuinfo gathers its information from somewhere - is there a way in
> userland to bypass /proc/cpuinfo and directly get this data manually?

You could probably load a kernel module to check this stuff.

For 2.4, in arch/i386/kernel/setup.c, look for the code that checks for 
X86_FEATURE_HT.  You should be able to just copy that logic into a 
kernel module and export the result via /proc.

Chris

-- 
Chris Friesen                    | MailStop: 043/33/F10
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com


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

* Re: Hyperthreading: easiest userland method?
  2003-09-12 14:41 Hyperthreading: easiest userland method? Dan Behman
  2003-09-12 14:55 ` dada1
  2003-09-12 15:10 ` Chris Friesen
@ 2003-09-12 16:12 ` Dave Hansen
  2 siblings, 0 replies; 5+ messages in thread
From: Dave Hansen @ 2003-09-12 16:12 UTC (permalink / raw)
  To: Dan Behman; +Cc: Linux Kernel Mailing List

And, here's another way:
http://sourceforge.net/projects/cpucounter/
-- 
Dave Hansen
haveblue@us.ibm.com


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

* RE: Hyperthreading: easiest userland method?
@ 2003-09-12 17:00 Nakajima, Jun
  0 siblings, 0 replies; 5+ messages in thread
From: Nakajima, Jun @ 2003-09-12 17:00 UTC (permalink / raw)
  To: Dan Behman, linux-kernel

For licensing purposes, we recommend the number of the physical
packages, rather than the number of logical processors. We can provide a
tool (with source code) that counts the number of the physical packages
in the system.

Thanks,
Jun

> -----Original Message-----
> From: Dan Behman [mailto:dbehman@ca.ibm.com]
> Sent: Friday, September 12, 2003 7:41 AM
> To: linux-kernel@vger.kernel.org
> Subject: Hyperthreading: easiest userland method?
> 
> Hi,
> 
> I have a need to programmatically determine whether or not
hyperthreading
> is enabled (and in use) for licensing reasons in my application.
> Currently, I know of two ways to do this:
> 
> 1) parse /proc/cpuinfo for "processor id"
> 2) port Intel's documented method (written for Windows) to directly
query
> the CPUs
> 
> Both methods have drawbacks - 1) relying on specific text that could
> change
> is a bad idea; 2) this doesn't take into account whether or not Linux
> and/or the BIOS is making use of the hyperthreading.
> 
> From scouring the archives and the net, it doesn't seem like there's
any
> API that currently exists, but perhaps I've missed something.
> /proc/cpuinfo gathers its information from somewhere - is there a way
in
> userland to bypass /proc/cpuinfo and directly get this data manually?
> 
> I'm interested in both 2.4 and 2.6 implementations and would like to
be
> personally CC'ed on any repsonses.
> 
> Thanks in advance!
> 
> Dan Behman.
> IBM Canada Ltd.
> 
> -
> 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] 5+ messages in thread

end of thread, other threads:[~2003-09-12 17:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-12 14:41 Hyperthreading: easiest userland method? Dan Behman
2003-09-12 14:55 ` dada1
2003-09-12 15:10 ` Chris Friesen
2003-09-12 16:12 ` Dave Hansen
  -- strict thread matches above, loose matches on Subject: below --
2003-09-12 17:00 Nakajima, Jun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox