×

Search anything:

lstopo command in Linux

Binary Tree book by OpenGenus

Open-Source Internship opportunity by OpenGenus for programmers. Apply now.

In this article, we discuss the lstopo Linux command used for showing the topology of a system.

Table of contents.

  1. Introduction.
  2. Syntax.
  3. Commands.
  4. Summary.
  5. References.

Introduction.

lstopo command is used to show the topology of the system. It gives information about the NUMA memory nodes, shared caches, CPU packages, processor cores and threads and much more.

Syntax.

It renders the machine topology as discovered by hwloc, there are two main modes textual rendering or graphical rendering.

For textual rendering, the syntax is as follows,

lstopo-no-graphics [OPTIONS]...[FILENAME]

and for graphical rendering,

lstopo [OPTIONS]...[FILENAME]

Commands.

To display machine topology graphically we write,

lstopo

topo

PU P# is Processing Unit Processor# - These are the processing elements within the cores of the CPU, from the image we can see 4 cores each with 2 processing elements(hyperthreaded) making a total of 8 but physically 4.

  • L#i represents the instruction cache.
  • L#d represents the data cache,
  • L1 represents level 1 cache.
  • L2 represents level 2 cache.
  • L3 represents level 3 cache.

Socket P# means that there are 4 physical sockets on the motherboard, A socket describes the container which holds the processor.

An example

socket-1

We can also see 8 cores each with a single processing unit which are in 4 physical CPU packages.

PCI bridges

The PCI hierarchy is drawn as a tree of bridges with links between them.
The tree starts with small square on the left of the host bridge or root complex and ends with PCI device boxes on the right.
Additional small squares may appear in the middle which represent intermediate PCI bridges/switches.

PCI devices

These are on the right hand side. They are the boxes which contain their bus ID, They may also contain smaller boxes within them for OS device objects such as network interfaces e.g eth0.

The data-rate of a PCI link can be written in GBs assuming the OS can report this information.

This can change during execution because some devices can be able to slow down their PCI links when they are idle.

A horizontal line to the right of a PCI bridge means that a single device or bridge is connected on a secondary PCI bus behind the bridge, on the other hand a vertical line means multiple devices and/or bridges are connected to the same secondary PCI bus.

colors

A red color means that the CPU or NUMA node is not in the allowed set.

A white color means that the CPU or NUMA node is in the allowed set.

A green color means that a topology can be seen by a specified process and the given CPU or NUMA node is in this process' CPU or memory binding mask.

An allowed set is the set of CPUs or NUMA nodes a process is allowed to bind to, it is either inherited from a parent process or set by the system's administrative policies.

For textual rendering we write,

lstopo-no-graphics

We can also view it in ascii-art mode by writing,

lstopo-no-graphics -.ascii

To view the summary we use the -s option

lstopo -s

To display physical indexes, we use the -p option as follows,

lstopo -p

For logical indexes we write,

lstopo -l

There are many output formats for lstop such as pdf, xml, svg etc.

To write the topology to a PNG file by writing,

lstopo file.png

Now file.png will have the system topology image.

We can also export it to an XML file so as to save it and reload it on another machine as follows,

lstopo file.xml

To export to pdf, we write,

lstopo file.pdf

To view cores only, we write,

lstopo --only core

and to view only cpusets, we write,

lstopo --cpuset

To view the logical processors we write,

lstopo --only pu

Summary.

In this article we have discussed a very useful way to get information about a computer system.
lstopo command can display a topological map of the system using various formats such as pdf, png etc.

With this article at OpenGenus, you must have the complete idea of lstopo command in Linux.

lstopo command in Linux
Share this