Find the answer to your Linux question:
Results 1 to 7 of 7
Sorry if this is the wrong place to ask this... I currently find the number of CPUs installed on a server by using sysconf(_SC_NPROCESSORS_ONLN) but when I run on certain ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2008
    Location
    North East U.S.
    Posts
    30

    How to tell if number of CPUs includes SMT


    Sorry if this is the wrong place to ask this...

    I currently find the number of CPUs installed on a server by using
    sysconf(_SC_NPROCESSORS_ONLN)
    but when I run on certain Intel processor machines, Hyper-Threading (HT, aka SMT) is enabled and artificially seems to increase the number of processors reported by sysconf(). To get around this, I grep through /proc/cpuinfo looking for "ht" in the flags. Now I find that on some AMD processors I see "ht" in the flags, but this doesn't seem to increase the number of processors being reported, so I am incorrectly reducing the number of processors I think are available for use.

    How or what causes the kernel to increase the number of real processors due to HT? Is there a way to find the true number of processors not counting HT?

    Brion

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,762
    Google pulls up Intel's answer to this?

  3. #3
    Just Joined!
    Join Date
    Jun 2008
    Location
    North East U.S.
    Posts
    30
    I guess what I was really looking for is the reason why a 2-processor Intel machine would report 4 processors using HT while a 4 core AMD processor machine reports 4 processors with HT. What makes the linux on Intel report more processors due to HT while AMD does not?

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,762
    I don't think I have seen an AMD CPU/motherboard that has an option to "enable hyperthreading."

    So while there is an HT flag, that doesn't mean it's enabled in BIOS.

    * If anyone else knows of an AMD CPU/motherboard combo that has hyper-threading options in BIOS, let us know.

    Based on what you're seeing, I would discount HT support *unless* it's an Intel CPU. Even with an Intel CPU and the HT flag, it could be disabled in BIOS which means the number of CPU's from /proc/cpuinfo = number of physical cores.

  6. #5
    Just Joined!
    Join Date
    Jun 2008
    Location
    North East U.S.
    Posts
    30
    I thought that a grep for "ht" in the flags field of /proc/cpuinfo was already filtering out the HT being disabled by BIOS. Someone had told me that 'ht' is in the flags field only if it is enabled. Since I'm seeing it in cpuinfo on a newer AMD system we installed recently and it is running RHEL 4.0 (2.6 kernel), I would assume it is enabled.

  7. #6
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,762
    Nope.

    Iíve also seen machines without active Hyperthreading but with the HT flag. My VDR machine is the prime example for how this happens: The BIOS doesnít support Hyperthreading with the CPU Iím using (Pentium E2160), though the CPU does support it.
    Your technique obviously works to detect active hyperthreading support.
    See here and here for physical ID vs. processor number.

  8. #7
    Just Joined!
    Join Date
    Jun 2008
    Location
    North East U.S.
    Posts
    30
    Well I'm totally confused about how SMT virtual CPUs are reported. We have a newly installed Intel machine with four Quad CPU chips running RHEL 4.0 kernel 2.6 and HT is enabled, but the system command reports only 16 CPUs. When I look through /proc/cpuinfo I find 16 entries, but for physical chip 0 there are cores 0-3 and apparently virtual cores 4-7, because for physical chip 1 there are cores 8-11 (and another four virtual cores 12-15). Physical chip 3 has core ids 24-27 with 29-31 not listed, but apparently reserved for the four SMT/HT virtual processors.

    For these processors the kernel appears to know there are SMT virtual processors, but the system(_SC_NPROCESSORS_ONLN) function call reports only the 16 real cores as processors, which is clearly different from what I have seen on other machines we have that use older processors, but the same kernel. I'm at a total loss as to how to figure out how many real processors are available on the machine I'm running on. Is there anyone who knows how this information is established when the system is booted or configured?

    Brion

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •