You can dynamically switch the kernel preemption mode in Alibaba Cloud Linux 3 operating systems with kernel 5.10.134-17 and later versions based on your business requirements. For example, you can switch from the none preemption mode to the voluntary preemption mode during the instance runtime to meet the latency requirements of your business. This topic describes how to switch the kernel preemption mode in Alibaba Cloud Linux 3 operating systems with kernel version 5.10.134-17 and later versions and the performance differences of the supported kernel preemption modes.
Kernel preemption modes
The following table describes the kernel preemption modes supported in the Alibaba Cloud Linux 3 operating system with kernel version 5.10.134-17 or later.
Preemption mode | Description |
none |
|
voluntary |
|
Change the kernel preemption mode
In the Alibaba Cloud Linux 3 operating system with kernel version 5.10.134-17 or later, you can use the following methods to change the kernel preemption mode.
Persistently change the kernel preemption mode
The kernel preemption mode is persistently changed and retained after an instance is restarted.
You can add the preempt=none configuration to or delete the configuration from the bootcmdline parameter to change the kernel preemption mode.
View the current kernel preemption mode.
sudo cat /sys/kernel/debug/sched_preemptView the current kernel information.
sudo grubby --info=0Change the kernel preemption mode.
Replace the
<kernel>value with the kernel version queried in Step 2. Example:/boot/vmlinuz-5.10.134-17.2.al8.x86_64.Change the kernel preemption mode to
voluntary.sudo grubby --update-kernel=<kernel> --remove-args="preempt=none"Change the kernel preemption mode to
none.sudo grubby --update-kernel=/boot/vmlinuz-<kernel> --args="preempt=none"
Restart the instance for the modification to take effect.
sudo rebootView the new kernel preemption mode.
sudo cat /sys/kernel/debug/sched_preempt
Temporarily change the kernel preemption mode
You can use the debugfs interface to temporarily and dynamically change the kernel preemption mode. The new kernel preemption mode becomes invalid after an instance is restarted.
In this example, the kernel preemption mode is temporarily changed to voluntary.
View the current kernel preemption mode.
sudo cat /sys/kernel/debug/sched_preemptThe following figure shows that the current kernel preemption mode is
none.
Change the kernel preemption mode to
voluntary.sudo sh -c 'echo voluntary > /sys/kernel/debug/sched_preempt'View the new kernel preemption mode.
sudo cat /sys/kernel/debug/sched_preemptThe following figure shows that the new kernel preemption mode is
voluntary.
Performance analysis of kernel preemption modes
In end-to-end scenarios, on MySQL, Redis, and NGINX instances that use the x86 and Arm64 architectures, the benchmark test results in none and voluntary preemption modes show that the none mode delivers better performance in most cases, and the performance gap between the two modes is relatively small. In this example, benchmark test results in the MySQL scenario are used.
In the x86 and Arm64 architectures, the oltp_write_only, oltp_read_only, and oltp_read_write metrics are tested. The test results show that greater transaction per second (TPS) and queries per second (QPS) values lead to smaller avg latency and avg 95th values, which indicates better performance.
In the following examples, the test results of the none mode are normalized to 1. The following figures show the differences in the performance data between the none and voluntary modes.
x86

Arm64

In the x86 and Arm64 architectures, the none mode outperforms the voluntary mode, as shown in the preceding figures.