CONFIG_PARAVIRT_SPINLOCK is a Linux kernel option that adds a paravirtualization layer for spinlocks. In Alibaba Cloud Linux, this option is disabled by default. If you are unsure about the risks, do not enable it. This document explains why enabling CONFIG_PARAVIRT_SPINLOCK on an Elastic Compute Service (ECS) instance can degrade performance and shows you how to check and disable it.
Problem description
On an ECS instance with multiple vCPUs, enabling CONFIG_PARAVIRT_SPINLOCK significantly reduces application performance when applications compete intensively for locks. For example, the throughput of NGINX when processing short-lived connections drops noticeably.
Cause
Enabling CONFIG_PARAVIRT_SPINLOCK introduces additional overhead and increases the complexity of the kernel spinlock mechanism, causing kernel performance to degrade.
A spinlock is a synchronization mechanism that prevents multiple threads or processes from accessing shared resources simultaneously, which helps ensure data consistency.
Solution
Step 1: Check whether CONFIG_PARAVIRT_SPINLOCK is enabled
Run the following command to check the kernel configuration:
grep CONFIG_PARAVIRT_SPINLOCK /boot/config-$(uname -r)Interpret the output:
| Output | Meaning |
|---|---|
CONFIG_PARAVIRT_SPINLOCKS=y | The option is enabled |
CONFIG_PARAVIRT_SPINLOCKS is not set | The option is disabled — no action needed |
If the option is disabled, stop here. If it is enabled, proceed to step 2.
Step 2: Recompile the kernel with the option disabled
Changing the kernel configuration and recompiling the kernel involves low-level system components. If you are unfamiliar with kernel compilation or installation, submit a ticket to contact Alibaba Cloud technical support before proceeding.
Recompile and reinstall the kernel with CONFIG_PARAVIRT_SPINLOCK disabled.