Commit aa17662b authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Thomas Gleixner

ia64/salinfo: Convert to hotplug state machine

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: kbuild test robot <lkp@intel.com>
Cc: rt@linutronix.de
Cc: kbuild-all@01.org
Link: http://lkml.kernel.org/r/20161103173128.xuulg4nius46dng5@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 715c3211
...@@ -550,53 +550,41 @@ static const struct file_operations salinfo_data_fops = { ...@@ -550,53 +550,41 @@ static const struct file_operations salinfo_data_fops = {
.llseek = default_llseek, .llseek = default_llseek,
}; };
static int static int salinfo_cpu_online(unsigned int cpu)
salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
{ {
unsigned int i, cpu = (unsigned long)hcpu; unsigned int i, end = ARRAY_SIZE(salinfo_data);
unsigned long flags;
struct salinfo_data *data; struct salinfo_data *data;
switch (action) {
case CPU_ONLINE: spin_lock_irq(&data_saved_lock);
case CPU_ONLINE_FROZEN: for (i = 0, data = salinfo_data; i < end; ++i, ++data) {
spin_lock_irqsave(&data_saved_lock, flags);
for (i = 0, data = salinfo_data;
i < ARRAY_SIZE(salinfo_data);
++i, ++data) {
cpumask_set_cpu(cpu, &data->cpu_event); cpumask_set_cpu(cpu, &data->cpu_event);
wake_up_interruptible(&data->read_wait); wake_up_interruptible(&data->read_wait);
} }
spin_unlock_irqrestore(&data_saved_lock, flags); spin_unlock_irq(&data_saved_lock);
break; return 0;
case CPU_DEAD: }
case CPU_DEAD_FROZEN:
spin_lock_irqsave(&data_saved_lock, flags); static int salinfo_cpu_pre_down(unsigned int cpu)
for (i = 0, data = salinfo_data; {
i < ARRAY_SIZE(salinfo_data); unsigned int i, end = ARRAY_SIZE(salinfo_data);
++i, ++data) { struct salinfo_data *data;
spin_lock_irq(&data_saved_lock);
for (i = 0, data = salinfo_data; i < end; ++i, ++data) {
struct salinfo_data_saved *data_saved; struct salinfo_data_saved *data_saved;
int j; int j = ARRAY_SIZE(data->data_saved) - 1;
for (j = ARRAY_SIZE(data->data_saved) - 1, data_saved = data->data_saved + j;
j >= 0; for (data_saved = data->data_saved + j; j >= 0;
--j, --data_saved) { --j, --data_saved) {
if (data_saved->buffer && data_saved->cpu == cpu) { if (data_saved->buffer && data_saved->cpu == cpu)
shift1_data_saved(data, j); shift1_data_saved(data, j);
} }
}
cpumask_clear_cpu(cpu, &data->cpu_event); cpumask_clear_cpu(cpu, &data->cpu_event);
} }
spin_unlock_irqrestore(&data_saved_lock, flags); spin_unlock_irq(&data_saved_lock);
break; return 0;
}
return NOTIFY_OK;
} }
static struct notifier_block salinfo_cpu_notifier =
{
.notifier_call = salinfo_cpu_callback,
.priority = 0,
};
static int __init static int __init
salinfo_init(void) salinfo_init(void)
{ {
...@@ -604,7 +592,7 @@ salinfo_init(void) ...@@ -604,7 +592,7 @@ salinfo_init(void)
struct proc_dir_entry **sdir = salinfo_proc_entries; /* keeps track of every entry */ struct proc_dir_entry **sdir = salinfo_proc_entries; /* keeps track of every entry */
struct proc_dir_entry *dir, *entry; struct proc_dir_entry *dir, *entry;
struct salinfo_data *data; struct salinfo_data *data;
int i, j; int i;
salinfo_dir = proc_mkdir("sal", NULL); salinfo_dir = proc_mkdir("sal", NULL);
if (!salinfo_dir) if (!salinfo_dir)
...@@ -617,8 +605,6 @@ salinfo_init(void) ...@@ -617,8 +605,6 @@ salinfo_init(void)
(void *)salinfo_entries[i].feature); (void *)salinfo_entries[i].feature);
} }
cpu_notifier_register_begin();
for (i = 0; i < ARRAY_SIZE(salinfo_log_name); i++) { for (i = 0; i < ARRAY_SIZE(salinfo_log_name); i++) {
data = salinfo_data + i; data = salinfo_data + i;
data->type = i; data->type = i;
...@@ -639,10 +625,6 @@ salinfo_init(void) ...@@ -639,10 +625,6 @@ salinfo_init(void)
continue; continue;
*sdir++ = entry; *sdir++ = entry;
/* we missed any events before now */
for_each_online_cpu(j)
cpumask_set_cpu(j, &data->cpu_event);
*sdir++ = dir; *sdir++ = dir;
} }
...@@ -653,10 +635,9 @@ salinfo_init(void) ...@@ -653,10 +635,9 @@ salinfo_init(void)
salinfo_timer.function = &salinfo_timeout; salinfo_timer.function = &salinfo_timeout;
add_timer(&salinfo_timer); add_timer(&salinfo_timer);
__register_hotcpu_notifier(&salinfo_cpu_notifier); i = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "ia64/salinfo:online",
salinfo_cpu_online, salinfo_cpu_pre_down);
cpu_notifier_register_done(); WARN_ON(i < 0);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment