Simultaneous Multithreading (SMT)

Simultaneous multithreading (SMT) is a technique used on current processors to improve the efficiency of the workload handling of the processor by allowing multiple independent threads to run on a single physical core at the same time.

SMT has a generally beneficial impact on performance for many applications and can increase the efficiency of most systems. For this reason, SMT is often enabled by default in the kernel where the hardware supports it. In some cases, like when an application runs threads that cause a bottleneck and the CPU design can’t handle this, performance will go down. In such a case, you may have to disable the SMT.

If SMT is enabled on the existing cluster, to avoid noisy neighbor problems, activate the full-pcpus-only CPU policy option in Kubernetes.

CPU policy (‘full-pcpus-only’)

When SMT is enabled, two logical CPUs are observed for the physical core. The CNFs ensure that both the logical CPUs are assigned to the TMMs. Noisy neighbor issue may occur if one of the logical CPUs is assigned to a TMM and the other was assigned to any application as it uses the CPU cycles.

In Kubernetes v1.26, the CPU Manager supports full-pcpus-only policy. This policy limits the CPU Manager’s core allocation algorithm to full physical cores only. This reduces noisy neighbor problems from hardware technologies that allow sharing of cores.

Activate the ‘full-pcpus-only’ CPU policy

To install CNFs with SMT enabled, it is necessary to activate the full-pcpus-only CPU policy option in Kubernetes. This can be achieved by adding the following annotation to the performance profile:

Example:

Following is an example performance-profile.yaml file to enable SMT.

Change the current performance-profile.yaml file, remove -nosmt line under the spec and apply the changes.

apiVersion: performance.openshift.io/v2
kind: PerformanceProfile
metadata:
  annotations:
  kubeletconfig.experimental: '{"cpuManagerPolicyOptions": {"full-pcpus-only": "true"}}'
labels:
  machineconfiguration.openshift.io/role: worker
  name: performance-profile
  spec:
  additionalKernelArgs:
    - nmi_watchdog=0
    - audit=0
    - mce=off
    - processor.max_cstate=1
    - idle=poll
    - intel_idle.max_cstate=0
cpu:
  balanceIsolated: false
  isolated: 4-39,44-79
  reserved: 0-3,40-43
hugepages:
  defaultHugepagesSize: 2M
  pages:
    - count: 32768
      node: 0
      size: 2M
    - count: 32768
      node: 1
      size: 2M
machineConfigPoolSelector:
  pools.operator.machineconfiguration.openshift.io/ worker: ""
nodeSelector:
  node-role.kubernetes.io/worker: ""
numa:
  topologyPolicy: single-numa-node

Warning: Enabling the full-pcpus-only option will affect any Guaranteed QoS pod in cluster. All Guaranteed QoS pods will require SMT aligned CPU requests, for example minimum of 2, then 4 and so on, to avoid ‘SMTAlignmentError’ scheduling error. more information at CPU Management Policies.

CPU Allocation for Hyperthreading (HT) Environments

DISABLE_HT Environment Variable

A new environment variable DISABLE_HT is being used along with the MAPRES argument --disable-ht variable to enhance multithreading control in CNFs.

By default, when SMT is enabled, the TMM uses both the logical CPUs of a physical core. This essentially doubles the number of TMM threads.

If you wish not to use both the logical CPUs, set the disable_ht environment variable value to true. When DISABLE_HT=true, MAPRESS will ensure the following:

  • TMM will use only the first logical CPU from each physical core.

  • This setting prevents the use of the second logical CPU from the core by other processes, ensuring predictable and optimized performance.

TMM Pod Requirements in Hyperthreading Environments

The following requirements must be set in the TMM pods when ‌hyperthreading is enabled.

Logical CPUs:
Enabling the hyperthreading environments doubles the number of logical CPUs visible on the host. For example, one physical core appears as two logical CPUs.

Resource matching:
To match the TMM performance, users must assign the same number of physical cores to the TMM as assigned before enabling ‌hyperthreading.

No Additional Hugepages required:
Hugepage assigned remains constant at 786 pages per physical core.

Automatic CPU Assignment:
Kubernetes (k3s) automatically assigns logical CPUs without requiring manual intervention.

Kubernetes Configuration Requirements

Enable the CPUManager policy option “full-pcpus-only” in your environment for optimal CPU management This policy ensures that TMM processes are assigned entire physical cores to reduce “noisy neighbor” interference caused by shared logical CPUs. The “full-pcpus-only” policy is enabled by default in Kubernetes 1.26 and later (For example, OpenShift 4.14 uses Kubernetes 1.27).

For more information on how to enable the full-pcpus-only CPUManager policy, see Kubernetes Full-PCPUS-Only Policy Documentation.

Example

Following is an example of full-pcpus-only policy:

full-pcpus-only
 
restrict the CPU Manager core allocation algorithm to full physical cores only, reducing noisy neighbor
issues from hardware technologies that allow sharing cores.

Managing Hyperthreading

By default, hyperthreading is enabled, allowing TMM to utilize both logical CPUs in deployments where Simultaneous Multithreading (SMT) is enabled in the BIOS. To disable hyperthreading for TMM, set the DISABLE_HT environment variable to True (DISABLE_HT=true) in the TMM container configuration.

Disable Hyperthreading

For disabling hyperthreading, set the environment variable as shown in the following example:

tmm:
  env:
    - name: TMM_CALICO_ROUTER
      value: default
    - name: DISABLE_HT
      value: true

For more information on how to set the environment variable, see TMM Values section.

Feedback

Provide feedback to improve this document by emailing cnfdocs@f5.com.