Skip to content

Commit 932d847

Browse files
ytcoodeKAGA-KOKO
authored andcommitted
cpu/hotplug: Fix dynstate assignment in __cpuhp_setup_state_cpuslocked()
Commit 4205e47 ("cpu/hotplug: Provide dynamic range for prepare stage") added a dynamic range for the prepare states, but did not handle the assignment of the dynstate variable in __cpuhp_setup_state_cpuslocked(). This causes the corresponding startup callback not to be invoked when calling __cpuhp_setup_state_cpuslocked() with the CPUHP_BP_PREPARE_DYN parameter, even though it should be. Currently, the users of __cpuhp_setup_state_cpuslocked(), for one reason or another, have not triggered this bug. Fixes: 4205e47 ("cpu/hotplug: Provide dynamic range for prepare stage") Signed-off-by: Yuntao Wang <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 6ba59ff commit 932d847

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernel/cpu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,7 +2446,7 @@ EXPORT_SYMBOL_GPL(__cpuhp_state_add_instance);
24462446
* The caller needs to hold cpus read locked while calling this function.
24472447
* Return:
24482448
* On success:
2449-
* Positive state number if @state is CPUHP_AP_ONLINE_DYN;
2449+
* Positive state number if @state is CPUHP_AP_ONLINE_DYN or CPUHP_BP_PREPARE_DYN;
24502450
* 0 for all other states
24512451
* On failure: proper (negative) error code
24522452
*/
@@ -2469,7 +2469,7 @@ int __cpuhp_setup_state_cpuslocked(enum cpuhp_state state,
24692469
ret = cpuhp_store_callbacks(state, name, startup, teardown,
24702470
multi_instance);
24712471

2472-
dynstate = state == CPUHP_AP_ONLINE_DYN;
2472+
dynstate = state == CPUHP_AP_ONLINE_DYN || state == CPUHP_BP_PREPARE_DYN;
24732473
if (ret > 0 && dynstate) {
24742474
state = ret;
24752475
ret = 0;
@@ -2500,8 +2500,8 @@ int __cpuhp_setup_state_cpuslocked(enum cpuhp_state state,
25002500
out:
25012501
mutex_unlock(&cpuhp_state_mutex);
25022502
/*
2503-
* If the requested state is CPUHP_AP_ONLINE_DYN, return the
2504-
* dynamically allocated state in case of success.
2503+
* If the requested state is CPUHP_AP_ONLINE_DYN or CPUHP_BP_PREPARE_DYN,
2504+
* return the dynamically allocated state in case of success.
25052505
*/
25062506
if (!ret && dynstate)
25072507
return state;

0 commit comments

Comments
 (0)