hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID3F7S CVE: NA ------------------------------------------------- When executing `echo off > /sys/devices/system/cpu/smt/control`, if `cpuhp_smt_disable` fails, a "resource busy" error is reported. However, the global variable `cpu_smt_num_threads` is incorrectly updated to the target value despite the failure. If SMT is subsequently disabled again, the command will not take effect due to a state machine inconsistency. To recover functionality, `echo on > /sys/devices/system/cpu/smt/control` must be executed manually. This commit adds exception handling to restore `cpu_smt_num_threads` to its original value when `cpuhp_smt_disable` fails, ensuring proper state management. Signed-off-by: Bowen You <youbowen2@huawei.com> --- kernel/cpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/cpu.c b/kernel/cpu.c index 88e81b8b1700..e5ebc498e328 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -2934,6 +2934,9 @@ __store_smt_control(struct device *dev, struct device_attribute *attr, else if (num_threads < orig_threads || force_off) ret = cpuhp_smt_disable(ctrlval); + if (ret) + cpu_smt_num_threads = orig_threads; + unlock_device_hotplug(); return ret ? ret : count; } -- 2.34.1