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

ia64/palinfo: Convert to hotplug state machine

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.

The removal of the files happens now in the prepare down stage as there is
no reason to keep them around until the cpu has actually died.
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: rt@linutronix.de
Link: http://lkml.kernel.org/r/20161103145021.28528-16-bigeasy@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 12223144
...@@ -932,8 +932,7 @@ static const struct file_operations proc_palinfo_fops = { ...@@ -932,8 +932,7 @@ static const struct file_operations proc_palinfo_fops = {
.release = single_release, .release = single_release,
}; };
static void static int palinfo_add_proc(unsigned int cpu)
create_palinfo_proc_entries(unsigned int cpu)
{ {
pal_func_cpu_u_t f; pal_func_cpu_u_t f;
struct proc_dir_entry *cpu_dir; struct proc_dir_entry *cpu_dir;
...@@ -943,7 +942,7 @@ create_palinfo_proc_entries(unsigned int cpu) ...@@ -943,7 +942,7 @@ create_palinfo_proc_entries(unsigned int cpu)
cpu_dir = proc_mkdir(cpustr, palinfo_dir); cpu_dir = proc_mkdir(cpustr, palinfo_dir);
if (!cpu_dir) if (!cpu_dir)
return; return -EINVAL;
f.req_cpu = cpu; f.req_cpu = cpu;
...@@ -952,42 +951,21 @@ create_palinfo_proc_entries(unsigned int cpu) ...@@ -952,42 +951,21 @@ create_palinfo_proc_entries(unsigned int cpu)
proc_create_data(palinfo_entries[j].name, 0, cpu_dir, proc_create_data(palinfo_entries[j].name, 0, cpu_dir,
&proc_palinfo_fops, (void *)f.value); &proc_palinfo_fops, (void *)f.value);
} }
return 0;
} }
static void static int palinfo_del_proc(unsigned int hcpu)
remove_palinfo_proc_entries(unsigned int hcpu)
{ {
char cpustr[3+4+1]; /* cpu numbers are up to 4095 on itanic */ char cpustr[3+4+1]; /* cpu numbers are up to 4095 on itanic */
sprintf(cpustr, "cpu%d", hcpu); sprintf(cpustr, "cpu%d", hcpu);
remove_proc_subtree(cpustr, palinfo_dir); remove_proc_subtree(cpustr, palinfo_dir);
return 0;
} }
static int palinfo_cpu_callback(struct notifier_block *nfb, static enum cpuhp_state hp_online;
unsigned long action, void *hcpu)
{
unsigned int hotcpu = (unsigned long)hcpu;
switch (action) {
case CPU_ONLINE:
case CPU_ONLINE_FROZEN:
create_palinfo_proc_entries(hotcpu);
break;
case CPU_DEAD:
case CPU_DEAD_FROZEN:
remove_palinfo_proc_entries(hotcpu);
break;
}
return NOTIFY_OK;
}
static struct notifier_block __refdata palinfo_cpu_notifier =
{
.notifier_call = palinfo_cpu_callback,
.priority = 0,
};
static int __init static int __init palinfo_init(void)
palinfo_init(void)
{ {
int i = 0; int i = 0;
...@@ -996,25 +974,19 @@ palinfo_init(void) ...@@ -996,25 +974,19 @@ palinfo_init(void)
if (!palinfo_dir) if (!palinfo_dir)
return -ENOMEM; return -ENOMEM;
cpu_notifier_register_begin(); i = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "ia64/palinfo:online",
palinfo_add_proc, palinfo_del_proc);
/* Create palinfo dirs in /proc for all online cpus */ if (i < 0) {
for_each_online_cpu(i) { remove_proc_subtree("pal", NULL);
create_palinfo_proc_entries(i); return i;
} }
hp_online = i;
/* Register for future delivery via notify registration */
__register_hotcpu_notifier(&palinfo_cpu_notifier);
cpu_notifier_register_done();
return 0; return 0;
} }
static void __exit static void __exit palinfo_exit(void)
palinfo_exit(void)
{ {
unregister_hotcpu_notifier(&palinfo_cpu_notifier); cpuhp_remove_state(hp_online);
remove_proc_subtree("pal", NULL); remove_proc_subtree("pal", NULL);
} }
......
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