Skip to content

Commit

Permalink
kernel/softirq: Convert to hotplug state machine
Browse files Browse the repository at this point in the history
Install the callbacks via the state machine.

Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Thomas Gleixner <[email protected]>
  • Loading branch information
Sebastian Andrzej Siewior authored and KAGA-KOKO committed Sep 6, 2016
1 parent 1d7ac6a commit c4544db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
1 change: 1 addition & 0 deletions include/linux/cpuhotplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum cpuhp_state {
CPUHP_VIRT_NET_DEAD,
CPUHP_SLUB_DEAD,
CPUHP_MM_WRITEBACK_DEAD,
CPUHP_SOFTIRQ_DEAD,
CPUHP_WORKQUEUE_PREP,
CPUHP_POWER_NUMA_PREPARE,
CPUHP_HRTIMERS_PREPARE,
Expand Down
27 changes: 6 additions & 21 deletions kernel/softirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ void tasklet_kill_immediate(struct tasklet_struct *t, unsigned int cpu)
BUG();
}

static void takeover_tasklets(unsigned int cpu)
static int takeover_tasklets(unsigned int cpu)
{
/* CPU is dead, so no lock needed. */
local_irq_disable();
Expand All @@ -723,27 +723,12 @@ static void takeover_tasklets(unsigned int cpu)
raise_softirq_irqoff(HI_SOFTIRQ);

local_irq_enable();
return 0;
}
#else
#define takeover_tasklets NULL
#endif /* CONFIG_HOTPLUG_CPU */

static int cpu_callback(struct notifier_block *nfb, unsigned long action,
void *hcpu)
{
switch (action) {
#ifdef CONFIG_HOTPLUG_CPU
case CPU_DEAD:
case CPU_DEAD_FROZEN:
takeover_tasklets((unsigned long)hcpu);
break;
#endif /* CONFIG_HOTPLUG_CPU */
}
return NOTIFY_OK;
}

static struct notifier_block cpu_nfb = {
.notifier_call = cpu_callback
};

static struct smp_hotplug_thread softirq_threads = {
.store = &ksoftirqd,
.thread_should_run = ksoftirqd_should_run,
Expand All @@ -753,8 +738,8 @@ static struct smp_hotplug_thread softirq_threads = {

static __init int spawn_ksoftirqd(void)
{
register_cpu_notifier(&cpu_nfb);

cpuhp_setup_state_nocalls(CPUHP_SOFTIRQ_DEAD, "softirq:dead", NULL,
takeover_tasklets);
BUG_ON(smpboot_register_percpu_thread(&softirq_threads));

return 0;
Expand Down

0 comments on commit c4544db

Please sign in to comment.