[PATCH OLK-6.6] cpu/SMT: recover global num_threads after disable smt switch fail
 
            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. Fixes: 7f48405c3c34 ("cpu/SMT: Allow enabling partial SMT states via sysfs") 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
 
            反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/18550 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/P6A... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/18550 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/P6A...
participants (2)
- 
                 Bowen You Bowen You
- 
                 patchwork bot patchwork bot