Skip to content

Commit

Permalink
hrtimer: Convert to hotplug state machine
Browse files Browse the repository at this point in the history
Split out the clockevents callbacks instead of piggybacking them on
hrtimers.

This gets rid of a POST_DEAD user. See commit:

  54e88fa ("sched: Make sure timers have migrated before killing the migration_thread")

We just move the callback state to the proper place in the state machine.

Signed-off-by: Thomas Gleixner <[email protected]>
Signed-off-by: Anna-Maria Gleixner <[email protected]>
Reviewed-by: Sebastian Andrzej Siewior <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Oleg Nesterov <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: Rusty Russell <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
KAGA-KOKO authored and Ingo Molnar committed Jul 15, 2016
1 parent ae6a8a2 commit 27590dc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 35 deletions.
1 change: 1 addition & 0 deletions include/linux/cpuhotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum cpuhp_state {
CPUHP_X86_HPET_DEAD,
CPUHP_X86_APB_DEAD,
CPUHP_WORKQUEUE_PREP,
CPUHP_HRTIMERS_PREPARE,
CPUHP_NOTIFY_PREPARE,
CPUHP_BRINGUP_CPU,
CPUHP_AP_IDLE_DEAD,
Expand Down
7 changes: 7 additions & 0 deletions include/linux/hrtimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,4 +494,11 @@ extern void __init hrtimers_init(void);
/* Show pending timers: */
extern void sysrq_timer_list_show(void);

int hrtimers_prepare_cpu(unsigned int cpu);
#ifdef CONFIG_HOTPLUG_CPU
int hrtimers_dead_cpu(unsigned int cpu);
#else
#define hrtimers_dead_cpu NULL
#endif

#endif
5 changes: 5 additions & 0 deletions kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,11 @@ static struct cpuhp_step cpuhp_bp_states[] = {
.startup = workqueue_prepare_cpu,
.teardown = NULL,
},
[CPUHP_HRTIMERS_PREPARE] = {
.name = "hrtimers prepare",
.startup = hrtimers_prepare_cpu,
.teardown = hrtimers_dead_cpu,
},
/*
* Preparatory and dead notifiers. Will be replaced once the notifiers
* are converted to states.
Expand Down
40 changes: 5 additions & 35 deletions kernel/time/hrtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
/*
* Functions related to boot-time initialization:
*/
static void init_hrtimers_cpu(int cpu)
int hrtimers_prepare_cpu(unsigned int cpu)
{
struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu);
int i;
Expand All @@ -1602,6 +1602,7 @@ static void init_hrtimers_cpu(int cpu)

cpu_base->cpu = cpu;
hrtimer_init_hres(cpu_base);
return 0;
}

#ifdef CONFIG_HOTPLUG_CPU
Expand Down Expand Up @@ -1636,7 +1637,7 @@ static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
}
}

static void migrate_hrtimers(int scpu)
int hrtimers_dead_cpu(unsigned int scpu)
{
struct hrtimer_cpu_base *old_base, *new_base;
int i;
Expand Down Expand Up @@ -1665,45 +1666,14 @@ static void migrate_hrtimers(int scpu)
/* Check, if we got expired work to do */
__hrtimer_peek_ahead_timers();
local_irq_enable();
return 0;
}

#endif /* CONFIG_HOTPLUG_CPU */

static int hrtimer_cpu_notify(struct notifier_block *self,
unsigned long action, void *hcpu)
{
int scpu = (long)hcpu;

switch (action) {

case CPU_UP_PREPARE:
case CPU_UP_PREPARE_FROZEN:
init_hrtimers_cpu(scpu);
break;

#ifdef CONFIG_HOTPLUG_CPU
case CPU_DEAD:
case CPU_DEAD_FROZEN:
migrate_hrtimers(scpu);
break;
#endif

default:
break;
}

return NOTIFY_OK;
}

static struct notifier_block hrtimers_nb = {
.notifier_call = hrtimer_cpu_notify,
};

void __init hrtimers_init(void)
{
hrtimer_cpu_notify(&hrtimers_nb, (unsigned long)CPU_UP_PREPARE,
(void *)(long)smp_processor_id());
register_cpu_notifier(&hrtimers_nb);
hrtimers_prepare_cpu(smp_processor_id());
}

/**
Expand Down

0 comments on commit 27590dc

Please sign in to comment.