Skip to content

Commit 27590dc

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
hrtimer: Convert to hotplug state machine
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 <tglx@linutronix.de> Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de> Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: rt@linutronix.de Link: http://lkml.kernel.org/r/20160713153337.485419196@linutronix.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent ae6a8a2 commit 27590dc

File tree

4 files changed

+18
-35
lines changed

4 files changed

+18
-35
lines changed

include/linux/cpuhotplug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ enum cpuhp_state {
1515
CPUHP_X86_HPET_DEAD,
1616
CPUHP_X86_APB_DEAD,
1717
CPUHP_WORKQUEUE_PREP,
18+
CPUHP_HRTIMERS_PREPARE,
1819
CPUHP_NOTIFY_PREPARE,
1920
CPUHP_BRINGUP_CPU,
2021
CPUHP_AP_IDLE_DEAD,

include/linux/hrtimer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,4 +494,11 @@ extern void __init hrtimers_init(void);
494494
/* Show pending timers: */
495495
extern void sysrq_timer_list_show(void);
496496

497+
int hrtimers_prepare_cpu(unsigned int cpu);
498+
#ifdef CONFIG_HOTPLUG_CPU
499+
int hrtimers_dead_cpu(unsigned int cpu);
500+
#else
501+
#define hrtimers_dead_cpu NULL
502+
#endif
503+
497504
#endif

kernel/cpu.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,11 @@ static struct cpuhp_step cpuhp_bp_states[] = {
11901190
.startup = workqueue_prepare_cpu,
11911191
.teardown = NULL,
11921192
},
1193+
[CPUHP_HRTIMERS_PREPARE] = {
1194+
.name = "hrtimers prepare",
1195+
.startup = hrtimers_prepare_cpu,
1196+
.teardown = hrtimers_dead_cpu,
1197+
},
11931198
/*
11941199
* Preparatory and dead notifiers. Will be replaced once the notifiers
11951200
* are converted to states.

kernel/time/hrtimer.c

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
15901590
/*
15911591
* Functions related to boot-time initialization:
15921592
*/
1593-
static void init_hrtimers_cpu(int cpu)
1593+
int hrtimers_prepare_cpu(unsigned int cpu)
15941594
{
15951595
struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu);
15961596
int i;
@@ -1602,6 +1602,7 @@ static void init_hrtimers_cpu(int cpu)
16021602

16031603
cpu_base->cpu = cpu;
16041604
hrtimer_init_hres(cpu_base);
1605+
return 0;
16051606
}
16061607

16071608
#ifdef CONFIG_HOTPLUG_CPU
@@ -1636,7 +1637,7 @@ static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
16361637
}
16371638
}
16381639

1639-
static void migrate_hrtimers(int scpu)
1640+
int hrtimers_dead_cpu(unsigned int scpu)
16401641
{
16411642
struct hrtimer_cpu_base *old_base, *new_base;
16421643
int i;
@@ -1665,45 +1666,14 @@ static void migrate_hrtimers(int scpu)
16651666
/* Check, if we got expired work to do */
16661667
__hrtimer_peek_ahead_timers();
16671668
local_irq_enable();
1669+
return 0;
16681670
}
16691671

16701672
#endif /* CONFIG_HOTPLUG_CPU */
16711673

1672-
static int hrtimer_cpu_notify(struct notifier_block *self,
1673-
unsigned long action, void *hcpu)
1674-
{
1675-
int scpu = (long)hcpu;
1676-
1677-
switch (action) {
1678-
1679-
case CPU_UP_PREPARE:
1680-
case CPU_UP_PREPARE_FROZEN:
1681-
init_hrtimers_cpu(scpu);
1682-
break;
1683-
1684-
#ifdef CONFIG_HOTPLUG_CPU
1685-
case CPU_DEAD:
1686-
case CPU_DEAD_FROZEN:
1687-
migrate_hrtimers(scpu);
1688-
break;
1689-
#endif
1690-
1691-
default:
1692-
break;
1693-
}
1694-
1695-
return NOTIFY_OK;
1696-
}
1697-
1698-
static struct notifier_block hrtimers_nb = {
1699-
.notifier_call = hrtimer_cpu_notify,
1700-
};
1701-
17021674
void __init hrtimers_init(void)
17031675
{
1704-
hrtimer_cpu_notify(&hrtimers_nb, (unsigned long)CPU_UP_PREPARE,
1705-
(void *)(long)smp_processor_id());
1706-
register_cpu_notifier(&hrtimers_nb);
1676+
hrtimers_prepare_cpu(smp_processor_id());
17071677
}
17081678

17091679
/**

0 commit comments

Comments
 (0)