hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6BB CVE: NA
--------------------------------
As 5064550d422d ("random: clear fast pool, crng, and batches in cpuhp bring up") add two elements into enum cpuhp_state, the kabi of following interfaces changed:
__cpuhp_remove_state_cpuslocked() __cpuhp_state_add_instance() __cpuhp_setup_state() __cpuhp_setup_state_cpuslocked() __cpuhp_remove_state() __cpuhp_state_remove_instance()
To fix the kabi change, Firstly, remove the newly-added elements and related code. Secondly, to meet the sequential relationship with workqueue cpuhp callbacks, put the random cpuhp online callback function into the workqueue cpuhp online callback function just before its exit, and put the random cpuhp prepare callback function into the workqueue cpuhp prepare callback function on the entry.
Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com Reviewed-by: GUO Zihua guozihua@huawei.com Reviewed-by: chenjun chenjun102@huawei.com Reviewed-by: Xiongfeng Wang wangxiongfeng2@huawei.com Reviewed-by: Xie XiuQi xiexiuqi@huawei.com Acked-by: Xie XiuQi xiexiuqi@huawei.com --- include/linux/cpuhotplug.h | 2 -- kernel/cpu.c | 11 ----------- kernel/workqueue.c | 8 ++++++++ 3 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h index 28844c7318f2..5571bfc2ec6e 100644 --- a/include/linux/cpuhotplug.h +++ b/include/linux/cpuhotplug.h @@ -62,7 +62,6 @@ enum cpuhp_state { CPUHP_LUSTRE_CFS_DEAD, CPUHP_AP_ARM_CACHE_B15_RAC_DEAD, CPUHP_PADATA_DEAD, - CPUHP_RANDOM_PREPARE, CPUHP_WORKQUEUE_PREP, CPUHP_POWER_NUMA_PREPARE, CPUHP_HRTIMERS_PREPARE, @@ -198,7 +197,6 @@ enum cpuhp_state { CPUHP_AP_PERF_POWERPC_HV_GPCI_ONLINE, CPUHP_AP_WATCHDOG_ONLINE, CPUHP_AP_WORKQUEUE_ONLINE, - CPUHP_AP_RANDOM_ONLINE, CPUHP_AP_RCUTREE_ONLINE, CPUHP_AP_BASE_CACHEINFO_ONLINE, CPUHP_AP_ONLINE_DYN, diff --git a/kernel/cpu.c b/kernel/cpu.c index 3c9ee966c56a..c06ced18f78a 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -34,7 +34,6 @@ #include <linux/scs.h> #include <linux/percpu-rwsem.h> #include <linux/cpuset.h> -#include <linux/random.h>
#include <trace/events/power.h> #define CREATE_TRACE_POINTS @@ -1582,11 +1581,6 @@ static struct cpuhp_step cpuhp_hp_states[] = { .startup.single = perf_event_init_cpu, .teardown.single = perf_event_exit_cpu, }, - [CPUHP_RANDOM_PREPARE] = { - .name = "random:prepare", - .startup.single = random_prepare_cpu, - .teardown.single = NULL, - }, [CPUHP_WORKQUEUE_PREP] = { .name = "workqueue:prepare", .startup.single = workqueue_prepare_cpu, @@ -1703,11 +1697,6 @@ static struct cpuhp_step cpuhp_hp_states[] = { .startup.single = workqueue_online_cpu, .teardown.single = workqueue_offline_cpu, }, - [CPUHP_AP_RANDOM_ONLINE] = { - .name = "random:online", - .startup.single = random_online_cpu, - .teardown.single = NULL, - }, [CPUHP_AP_RCUTREE_ONLINE] = { .name = "RCU/tree:online", .startup.single = rcutree_online_cpu, diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 6bef482a152b..14d4c072c79b 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -51,6 +51,7 @@ #include <linux/sched/isolation.h> #include <linux/nmi.h> #include <linux/kvm_para.h> +#include <linux/random.h>
#include "workqueue_internal.h"
@@ -5061,6 +5062,9 @@ int workqueue_prepare_cpu(unsigned int cpu) { struct worker_pool *pool;
+ /* put the random cpuhp callback here to workaround KABI change */ + random_prepare_cpu(cpu); + for_each_cpu_worker_pool(pool, cpu) { if (pool->nr_workers) continue; @@ -5094,6 +5098,10 @@ int workqueue_online_cpu(unsigned int cpu) wq_update_unbound_numa(wq, cpu, true);
mutex_unlock(&wq_pool_mutex); + + /* put the random cpuhp callback here to workaround KABI change */ + random_online_cpu(cpu); + return 0; }