Linux Thinks It’s a CPU, But What Is It Really – Part II. Trouble With the Intel CPU Topology Tool?

Yesterday I made a blog entry about the Intel CPU topology tool to help understand Xeon 5500 SMT and how it maps to Linux OS CPUs. I received a few emails about the tool. Some folks where having trouble figuring it out on their system (the tool works on other Xeons too).

This is just a quick blog entry to explain the tool for those readers and the possible future wayward googler.

In the following session snap you’ll see that the  CPU topology tool tar file is called  topo03062009.tar. In the session I do the following:

  1. Extract the tarball
  2. Change directories into the directory created by the tar extraction
  3. Run the make for 64 bit Linux
  4. Ignore the warnings
  5. Run ls(1) to see what I picked up. Hmmm, there are no file names that appear to be executable.
  6. I look into the script that builds the tool. I see the binary is produced into cpu_topology64.out. ( Uh, I think even a.out would have been more intuitive).
  7. I use file(1) to make sure it is an executable
  8. I run it but throw away all but the last 40 lines of output.

# ls -l topo*
-rw-r--r-- 1 root root 163840 Apr 13 21:16 topo03062009.tar
# tar xvf topo03062009.tar
topo/Intel Source Code License Agreement.doc
# cd topo
# sh ./
cpu_topo.c: In function ?DumpCPUIDArray?:
cpu_topo.c:1857: warning: comparison is always false due to limited range of data type
# ls
cpu_topo.c          get_cpuid_lix32.s                        mk_32.bat  util_os.c
cpu_topology64.out  get_cpuid_lix64.o                 util_os.o
cputopology.h       get_cpuid_lix64.s                        mk_64.bat
get_cpuid.asm       Intel Source Code License Agreement.doc
# more mk*64*sh

gcc -g -c get_cpuid_lix64.s -o get_cpuid_lix64.o
gcc -g -c util_os.c
gcc -g -DBUILD_MAIN cpu_topo.c -o cpu_topology64.out get_cpuid_lix64.o util_os.o
# file cpu_topology64.out
cpu_topology64.out: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9,
 dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped

# ./cpu_topology64.out  | tail -40

Combined socket AffinityMask= 0xf0f

Package 1 Cache and Thread details

Box Description:
Cache  is cache level designator
Size   is cache size
OScpu# is cpu # as seen by OS
Core   is core#[_thread# if > 1 thread/core] inside socket
AffMsk is AffinityMask(extended hex) for core and thread
CmbMsk is Combined AffinityMask(extended hex) for hw threads sharing cache
       CmbMsk will differ from AffMsk if > 1 hw_thread/cache
Extended Hex replaces trailing zeroes with 'z#'
       where # is number of zeroes (so '8z5' is '0x800000')
Cache |  L1D      |  L1D      |  L1D      |  L1D      |
Size  |  32K      |  32K      |  32K      |  32K      |
OScpu#|    4    12|    5    13|    6    14|    7    15|
Core  |c0_t0 c0_t1|c1_t0 c1_t1|c2_t0 c2_t1|c3_t0 c3_t1|
AffMsk|   10   1z3|   20   2z3|   40   4z3|   80   8z3|
CmbMsk| 1010      | 2020      | 4040      | 8080      |

Cache |  L1I      |  L1I      |  L1I      |  L1I      |
Size  |  32K      |  32K      |  32K      |  32K      |

Cache |   L2      |   L2      |   L2      |   L2      |
Size  | 256K      | 256K      | 256K      | 256K      |

Cache |   L3                                          |
Size  |   8M                                          |
CmbMsk| f0f0                                          |

3 Responses to “Linux Thinks It’s a CPU, But What Is It Really – Part II. Trouble With the Intel CPU Topology Tool?”

  1. 1 Brett Schroeder April 24, 2009 at 3:50 am

    For 32-bit systems two things need to be fixed 1) the script is not executable and 2) the script has windows CR/LF at end of the second gcc line (this causes an object file named “util_os.o^M” to be created and then file “util_os.o” cannot be found when linking with the main executable).

    Clean up the shell script – it then compiles and creates cpu_topology32.out (which is executable)

    # chmod 740

    # ./
    : command not found
    : command not found
    gcc: util_os.o: No such file or directory
    cpu_topo.c: In function ‘DumpCPUIDArray’:
    cpu_topo.c:1857: warning: comparison is always false due to limited range of data type

    # ll
    > ….snip
    -rw-r–r– 1 root root 5304 Mar 6 13:00 util_os.c
    -rw-r–r– 1 root root 5704 Apr 23 20:39 util_os.o?

    # dos2unix
    # ./
    # ./cpu_topology32.out

    Aside: this code also (seems to) work on non-Xeon CPU’s. I ran it on a Pentium D and Core 2 Duo and the output all made sense.

    • 2 kevinclosson April 24, 2009 at 6:00 am

      Hey Brett,

      Thanks for the tips… and here I thought I was thankful for 64bit Linux solely based on address space! I guess I get to sneak by 32bit stuff that just doesn’t work and I get off scot-free!

  1. 1 Xeon E5-2600 OS CPU To Core / SMT Thread Mapping On Linux. It Matters. « Kevin Closson's Blog: Platforms, Databases and Storage Trackback on April 25, 2012 at 8:58 pm

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


I work for Amazon Web Services. The opinions I share in this blog are my own. I'm *not* communicating as a spokesperson for Amazon. In other words, I work at Amazon, but this is my own opinion.

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 2,944 other followers

Oracle ACE Program Status

Click It

website metrics

Fond Memories


All content is © Kevin Closson and "Kevin Closson's Blog: Platforms, Databases, and Storage", 2006-2015. Unauthorized use and/or duplication of this material without express and written permission from this blog’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Kevin Closson and Kevin Closson's Blog: Platforms, Databases, and Storage with appropriate and specific direction to the original content.

%d bloggers like this: