Examining the CPU topology

Red Hat Enterprise Linux 9.2 LPAR mode z/VM guest KVM guest

If supported by your real or virtual hardware, you can obtain information about the CPU topology.

Before you begin

The CPU topology information that is available to Linux® in LPAR mode relates to the physical arrangement of the CPUs in the hardware. The KVM and z/VM® hypervisors can present a virtual CPU topology to their guests. Whether this information is meaningful depends on the degree to which the hypervisor models the virtual CPU topology to the CPU topology of the host.

About this task

Use this information, for example, to optimize the Linux scheduler, which bases its decisions on which process gets scheduled to which CPU. Depending on the workload, this optimization might increase cache hits and therefore overall performance.

Note: By default CPU topology support is enabled in the Linux kernel. If it is not suitable for your workload, disable the support by specifying the kernel parameter topology=off in your parmfile or zipl.conf.
The following sysfs attributes provide information about the CPU topology:

/sys/devices/system/cpu/cpu<N>/topology/thread_siblings
/sys/devices/system/cpu/cpu<N>/topology/core_siblings
/sys/devices/system/cpu/cpu<N>/topology/book_siblings
/sys/devices/system/cpu/cpu<N>/topology/drawer_siblings
where <N> specifies a particular logical CPU number. These attributes contain masks that specify sets of CPUs.

Because the mainframe hardware is evolving over time, the terms drawer, book, core, and thread do not necessarily correspond to fixed hardware entities. What matters for the Linux scheduler is the levels of relatedness that these terms signify, not the physical embodiment of the levels. In this context, more closely related means sharing more resources, like caches.

The thread_siblings, core_siblings, book_siblings, and drawer_siblings attribute each contain a mask that specifies the CPU and its peers at a particular level of relatedness.

  1. The thread_siblings attribute covers the CPU and its closely related peers.
  2. The core_siblings attribute covers all CPUs of the thread_siblings attribute and peers related at the core level.
  3. The book_siblings attribute covers all CPUs of the core_siblings attribute and peers related at the book level.
  4. The drawer_siblings attribute covers all CPUs of the book_siblings attribute and peers related at the drawer level.

If a machine reconfiguration causes the CPU topology to change, change uevents are created for each online CPU.

If the kernel also supports standby CPU activation and deactivation, the masks also contains the CPUs that are in a configured, but offline state. Updating the masks after a reconfiguration might take some time.