Skip to content

Commit 9cf7243

Browse files
committed
sched: Make set_cpu_rq_start_time() a built in hotplug state
Start distangling the maze of hotplug notifiers in the scheduler. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Cc: [email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent e9d867a commit 9cf7243

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

include/linux/cpuhotplug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ enum cpuhp_state {
88
CPUHP_BRINGUP_CPU,
99
CPUHP_AP_IDLE_DEAD,
1010
CPUHP_AP_OFFLINE,
11+
CPUHP_AP_SCHED_STARTING,
1112
CPUHP_AP_NOTIFY_STARTING,
1213
CPUHP_AP_ONLINE,
1314
CPUHP_TEARDOWN_CPU,

include/linux/sched.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ extern void cpu_init (void);
372372
extern void trap_init(void);
373373
extern void update_process_times(int user);
374374
extern void scheduler_tick(void);
375+
extern int sched_cpu_starting(unsigned int cpu);
375376

376377
extern void sched_show_task(struct task_struct *p);
377378

kernel/cpu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,12 @@ static struct cpuhp_step cpuhp_ap_states[] = {
12361236
.name = "ap:offline",
12371237
.cant_stop = true,
12381238
},
1239+
/* First state is scheduler control. Interrupts are disabled */
1240+
[CPUHP_AP_SCHED_STARTING] = {
1241+
.name = "sched:starting",
1242+
.startup = sched_cpu_starting,
1243+
.teardown = NULL,
1244+
},
12391245
/*
12401246
* Low level startup/teardown notifiers. Run with interrupts
12411247
* disabled. Will be removed once the notifiers are converted to

kernel/sched/core.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5473,10 +5473,10 @@ static struct notifier_block migration_notifier = {
54735473
.priority = CPU_PRI_MIGRATION,
54745474
};
54755475

5476-
static void set_cpu_rq_start_time(void)
5476+
static void set_cpu_rq_start_time(unsigned int cpu)
54775477
{
5478-
int cpu = smp_processor_id();
54795478
struct rq *rq = cpu_rq(cpu);
5479+
54805480
rq->age_stamp = sched_clock_cpu(cpu);
54815481
}
54825482

@@ -5486,10 +5486,6 @@ static int sched_cpu_active(struct notifier_block *nfb,
54865486
int cpu = (long)hcpu;
54875487

54885488
switch (action & ~CPU_TASKS_FROZEN) {
5489-
case CPU_STARTING:
5490-
set_cpu_rq_start_time();
5491-
return NOTIFY_OK;
5492-
54935489
case CPU_DOWN_FAILED:
54945490
set_cpu_active(cpu, true);
54955491
return NOTIFY_OK;
@@ -5511,6 +5507,12 @@ static int sched_cpu_inactive(struct notifier_block *nfb,
55115507
}
55125508
}
55135509

5510+
int sched_cpu_starting(unsigned int cpu)
5511+
{
5512+
set_cpu_rq_start_time(cpu);
5513+
return 0;
5514+
}
5515+
55145516
static int __init migration_init(void)
55155517
{
55165518
void *cpu = (void *)(long)smp_processor_id();
@@ -7426,7 +7428,7 @@ void __init sched_init(void)
74267428
if (cpu_isolated_map == NULL)
74277429
zalloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT);
74287430
idle_thread_set_boot_cpu();
7429-
set_cpu_rq_start_time();
7431+
set_cpu_rq_start_time(smp_processor_id());
74307432
#endif
74317433
init_sched_fair_class();
74327434

0 commit comments

Comments
 (0)