Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.

Commit b7722f4

Browse files
torvaldsgregkh
authored andcommitted
init: rename and re-order boot_cpu_state_init()
commit b5b1404 upstream. This is purely a preparatory patch for upcoming changes during the 4.19 merge window. We have a function called "boot_cpu_state_init()" that isn't really about the bootup cpu state: that is done much earlier by the similarly named "boot_cpu_init()" (note lack of "state" in name). This function initializes some hotplug CPU state, and needs to run after the percpu data has been properly initialized. It even has a comment to that effect. Except it _doesn't_ actually run after the percpu data has been properly initialized. On x86 it happens to do that, but on at least arm and arm64, the percpu base pointers are initialized by the arch-specific 'smp_prepare_boot_cpu()' hook, which ran _after_ boot_cpu_state_init(). This had some unexpected results, and in particular we have a patch pending for the merge window that did the obvious cleanup of using 'this_cpu_write()' in the cpu hotplug init code: - per_cpu_ptr(&cpuhp_state, smp_processor_id())->state = CPUHP_ONLINE; + this_cpu_write(cpuhp_state.state, CPUHP_ONLINE); which is obviously the right thing to do. Except because of the ordering issue, it actually failed miserably and unexpectedly on arm64. So this just fixes the ordering, and changes the name of the function to be 'boot_cpu_hotplug_init()' to make it obvious that it's about cpu hotplug state, because the core CPU state was supposed to have already been done earlier. Marked for stable, since the (not yet merged) patch that will show this problem is marked for stable. Reported-by: Vlastimil Babka <[email protected]> Reported-by: Mian Yousaf Kaukab <[email protected]> Suggested-by: Catalin Marinas <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fa085d7 commit b7722f4

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

include/linux/cpu.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct cpu {
3030
};
3131

3232
extern void boot_cpu_init(void);
33-
extern void boot_cpu_state_init(void);
33+
extern void boot_cpu_hotplug_init(void);
3434
extern void cpu_init(void);
3535
extern void trap_init(void);
3636

init/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,8 @@ asmlinkage __visible void __init start_kernel(void)
543543
setup_command_line(command_line);
544544
setup_nr_cpu_ids();
545545
setup_per_cpu_areas();
546-
boot_cpu_state_init();
547546
smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
547+
boot_cpu_hotplug_init();
548548

549549
build_all_zonelists(NULL);
550550
page_alloc_init();

kernel/cpu.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,7 @@ void __init boot_cpu_init(void)
20222022
/*
20232023
* Must be called _AFTER_ setting up the per_cpu areas
20242024
*/
2025-
void __init boot_cpu_state_init(void)
2025+
void __init boot_cpu_hotplug_init(void)
20262026
{
20272027
per_cpu_ptr(&cpuhp_state, smp_processor_id())->state = CPUHP_ONLINE;
20282028
}

0 commit comments

Comments
 (0)