Skip to content

x86/speculation: Disable IBRS when idle

Waiman Long requested to merge llong1/centos-stream-9:rhel8620_ibrs94 into main

JIRA: https://issues.redhat.com/browse/RHEL-8620
MR: !3177 (merged)

For Intel processors that need to turn on IBRS to protect against Spectre v2 and Retbleed, the IBRS bit in the SPEC_CTRL MSR affects the performance of the whole core even if only one thread is turning it on when running in the kernel. For user space heavy applications, the performance impact of occasionally turning IBRS on during syscalls shouldn't be significant. Unfortunately, that is not the case when the sibling thread is idling in the kernel. In that case, the performance impact can be significant.

When DPDK is running on an isolated CPU thread processing network packets in user space while its sibling thread is idle. The performance of the busy DPDK thread with IBRS on and off in the sibling idle thread are:

                            IBRS on         IBRS off
                            -------         --------
packets/second:                7.8M           10.4M
avg tsc cycles/packet:       282.26          209.86

This is a 25% performance degradation. The test system is a Intel Xeon 4114 CPU @ 2.20GHz.

Commit bf5835bcdb96 ("intel_idle: Disable IBRS during long idle") disables IBRS when the CPU enters long idle (C6 or below). However, there are existing users out there who have set "intel_idle.max_cstate=1" to decrease latency. Those users won't be able to benefit from this commit. This patch series extends this commit by providing a new "intel_idle.ibrs_off" module parameter to force disable IBRS even when "intel_idle.max_cstate=1" at the expense of increased IRQ response latency. It also includes a commit to allow the disabling of IBRS when a CPU becomes offline.

Beside backporting upstream patches, this MR also contains 2 RHEL only patches that were rejected by upstream and can still be still be useful.

Patch 5 disables IBRS entering mwait idle and enable it on wakeup. This is useful in case customers use "intel_idle.max_cstate=0". Patch 6 adds a debugfs file to show the content of the SPEC_CTRL MSRs which can be useful to check if the IBRS state is set correctly.

Signed-off-by: Waiman Long longman@redhat.com

Edited by Waiman Long

Merge request reports