[tip:smp/hotplug] cpufreq: Use cpuhp_setup_state_nocalls_cpuslocked()

2017-05-26 Thread tip-bot for Sebastian Andrzej Siewior
Commit-ID:  a92551e41d5a7b563ae440496bc5ca19d205231d
Gitweb: http://git.kernel.org/tip/a92551e41d5a7b563ae440496bc5ca19d205231d
Author: Sebastian Andrzej Siewior 
AuthorDate: Wed, 24 May 2017 10:15:20 +0200
Committer:  Thomas Gleixner 
CommitDate: Fri, 26 May 2017 10:10:38 +0200

cpufreq: Use cpuhp_setup_state_nocalls_cpuslocked()

cpufreq holds get_online_cpus() while invoking cpuhp_setup_state_nocalls()
to make subsys_interface_register() and the registration of hotplug calls
atomic versus cpu hotplug.

cpuhp_setup_state_nocalls() invokes get_online_cpus() as well. This is
correct, but prevents the conversion of the hotplug locking to a percpu
rwsem.

Use cpuhp_setup/remove_state_nocalls_cpuslocked() to avoid the nested
call. Convert *_online_cpus() to the new interfaces while at it.

Signed-off-by: Sebastian Andrzej Siewior 
Signed-off-by: Thomas Gleixner 
Tested-by: Paul E. McKenney 
Acked-by: Ingo Molnar 
Acked-by: "Rafael J. Wysocki" 
Acked-by: Viresh Kumar 
Cc: linux...@vger.kernel.org
Cc: Peter Zijlstra 
Cc: Steven Rostedt 
Link: http://lkml.kernel.org/r/20170524081547.731628...@linutronix.de

---
 drivers/cpufreq/cpufreq.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 0e3f649..6001369 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -887,7 +887,7 @@ static ssize_t store(struct kobject *kobj, struct attribute 
*attr,
struct freq_attr *fattr = to_attr(attr);
ssize_t ret = -EINVAL;
 
-   get_online_cpus();
+   cpus_read_lock();
 
if (cpu_online(policy->cpu)) {
down_write(>rwsem);
@@ -895,7 +895,7 @@ static ssize_t store(struct kobject *kobj, struct attribute 
*attr,
up_write(>rwsem);
}
 
-   put_online_cpus();
+   cpus_read_unlock();
 
return ret;
 }
@@ -2441,7 +2441,7 @@ int cpufreq_register_driver(struct cpufreq_driver 
*driver_data)
pr_debug("trying to register driver %s\n", driver_data->name);
 
/* Protect against concurrent CPU online/offline. */
-   get_online_cpus();
+   cpus_read_lock();
 
write_lock_irqsave(_driver_lock, flags);
if (cpufreq_driver) {
@@ -2473,9 +2473,10 @@ int cpufreq_register_driver(struct cpufreq_driver 
*driver_data)
goto err_if_unreg;
}
 
-   ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
-   cpuhp_cpufreq_online,
-   cpuhp_cpufreq_offline);
+   ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN,
+  "cpufreq:online",
+  cpuhp_cpufreq_online,
+  cpuhp_cpufreq_offline);
if (ret < 0)
goto err_if_unreg;
hp_online = ret;
@@ -2493,7 +2494,7 @@ err_null_driver:
cpufreq_driver = NULL;
write_unlock_irqrestore(_driver_lock, flags);
 out:
-   put_online_cpus();
+   cpus_read_unlock();
return ret;
 }
 EXPORT_SYMBOL_GPL(cpufreq_register_driver);
@@ -2516,17 +2517,17 @@ int cpufreq_unregister_driver(struct cpufreq_driver 
*driver)
pr_debug("unregistering driver %s\n", driver->name);
 
/* Protect against concurrent cpu hotplug */
-   get_online_cpus();
+   cpus_read_lock();
subsys_interface_unregister(_interface);
remove_boost_sysfs_file();
-   cpuhp_remove_state_nocalls(hp_online);
+   cpuhp_remove_state_nocalls_cpuslocked(hp_online);
 
write_lock_irqsave(_driver_lock, flags);
 
cpufreq_driver = NULL;
 
write_unlock_irqrestore(_driver_lock, flags);
-   put_online_cpus();
+   cpus_read_unlock();
 
return 0;
 }


[tip:smp/hotplug] cpufreq: Use cpuhp_setup_state_nocalls_cpuslocked()

2017-05-26 Thread tip-bot for Sebastian Andrzej Siewior
Commit-ID:  a92551e41d5a7b563ae440496bc5ca19d205231d
Gitweb: http://git.kernel.org/tip/a92551e41d5a7b563ae440496bc5ca19d205231d
Author: Sebastian Andrzej Siewior 
AuthorDate: Wed, 24 May 2017 10:15:20 +0200
Committer:  Thomas Gleixner 
CommitDate: Fri, 26 May 2017 10:10:38 +0200

cpufreq: Use cpuhp_setup_state_nocalls_cpuslocked()

cpufreq holds get_online_cpus() while invoking cpuhp_setup_state_nocalls()
to make subsys_interface_register() and the registration of hotplug calls
atomic versus cpu hotplug.

cpuhp_setup_state_nocalls() invokes get_online_cpus() as well. This is
correct, but prevents the conversion of the hotplug locking to a percpu
rwsem.

Use cpuhp_setup/remove_state_nocalls_cpuslocked() to avoid the nested
call. Convert *_online_cpus() to the new interfaces while at it.

Signed-off-by: Sebastian Andrzej Siewior 
Signed-off-by: Thomas Gleixner 
Tested-by: Paul E. McKenney 
Acked-by: Ingo Molnar 
Acked-by: "Rafael J. Wysocki" 
Acked-by: Viresh Kumar 
Cc: linux...@vger.kernel.org
Cc: Peter Zijlstra 
Cc: Steven Rostedt 
Link: http://lkml.kernel.org/r/20170524081547.731628...@linutronix.de

---
 drivers/cpufreq/cpufreq.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 0e3f649..6001369 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -887,7 +887,7 @@ static ssize_t store(struct kobject *kobj, struct attribute 
*attr,
struct freq_attr *fattr = to_attr(attr);
ssize_t ret = -EINVAL;
 
-   get_online_cpus();
+   cpus_read_lock();
 
if (cpu_online(policy->cpu)) {
down_write(>rwsem);
@@ -895,7 +895,7 @@ static ssize_t store(struct kobject *kobj, struct attribute 
*attr,
up_write(>rwsem);
}
 
-   put_online_cpus();
+   cpus_read_unlock();
 
return ret;
 }
@@ -2441,7 +2441,7 @@ int cpufreq_register_driver(struct cpufreq_driver 
*driver_data)
pr_debug("trying to register driver %s\n", driver_data->name);
 
/* Protect against concurrent CPU online/offline. */
-   get_online_cpus();
+   cpus_read_lock();
 
write_lock_irqsave(_driver_lock, flags);
if (cpufreq_driver) {
@@ -2473,9 +2473,10 @@ int cpufreq_register_driver(struct cpufreq_driver 
*driver_data)
goto err_if_unreg;
}
 
-   ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
-   cpuhp_cpufreq_online,
-   cpuhp_cpufreq_offline);
+   ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN,
+  "cpufreq:online",
+  cpuhp_cpufreq_online,
+  cpuhp_cpufreq_offline);
if (ret < 0)
goto err_if_unreg;
hp_online = ret;
@@ -2493,7 +2494,7 @@ err_null_driver:
cpufreq_driver = NULL;
write_unlock_irqrestore(_driver_lock, flags);
 out:
-   put_online_cpus();
+   cpus_read_unlock();
return ret;
 }
 EXPORT_SYMBOL_GPL(cpufreq_register_driver);
@@ -2516,17 +2517,17 @@ int cpufreq_unregister_driver(struct cpufreq_driver 
*driver)
pr_debug("unregistering driver %s\n", driver->name);
 
/* Protect against concurrent cpu hotplug */
-   get_online_cpus();
+   cpus_read_lock();
subsys_interface_unregister(_interface);
remove_boost_sysfs_file();
-   cpuhp_remove_state_nocalls(hp_online);
+   cpuhp_remove_state_nocalls_cpuslocked(hp_online);
 
write_lock_irqsave(_driver_lock, flags);
 
cpufreq_driver = NULL;
 
write_unlock_irqrestore(_driver_lock, flags);
-   put_online_cpus();
+   cpus_read_unlock();
 
return 0;
 }


[tip:smp/hotplug] cpufreq: Use cpuhp_setup_state_nocalls_cpuslocked()

2017-04-20 Thread tip-bot for Sebastian Andrzej Siewior
Commit-ID:  6d7d2f1f9e6e0c2d6fb9de82ad5fbc3aed115829
Gitweb: http://git.kernel.org/tip/6d7d2f1f9e6e0c2d6fb9de82ad5fbc3aed115829
Author: Sebastian Andrzej Siewior 
AuthorDate: Tue, 18 Apr 2017 19:04:48 +0200
Committer:  Thomas Gleixner 
CommitDate: Thu, 20 Apr 2017 13:08:52 +0200

cpufreq: Use cpuhp_setup_state_nocalls_cpuslocked()

cpufreq holds get_online_cpus() while invoking cpuhp_setup_state_nocalls()
to make subsys_interface_register() and the registration of hotplug calls
atomic versus cpu hotplug.

cpuhp_setup_state_nocalls() invokes get_online_cpus() as well. This is
correct, but prevents the conversion of the hotplug locking to a percpu
rwsem.

Use cpuhp_setup/remove_state_nocalls_cpuslocked() to avoid the nested call.

Signed-off-by: Sebastian Andrzej Siewior 
Signed-off-by: Thomas Gleixner 
Acked-by: "Rafael J. Wysocki" 
Acked-by: Viresh Kumar 
Cc: linux...@vger.kernel.org
Cc: Peter Zijlstra 
Cc: Steven Rostedt 
Link: http://lkml.kernel.org/r/20170418170552.865966...@linutronix.de

---
 drivers/cpufreq/cpufreq.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 0e3f649..67ef7ce 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2473,9 +2473,10 @@ int cpufreq_register_driver(struct cpufreq_driver 
*driver_data)
goto err_if_unreg;
}
 
-   ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
-   cpuhp_cpufreq_online,
-   cpuhp_cpufreq_offline);
+   ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN,
+  "cpufreq:online",
+  cpuhp_cpufreq_online,
+  cpuhp_cpufreq_offline);
if (ret < 0)
goto err_if_unreg;
hp_online = ret;
@@ -2519,7 +2520,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver 
*driver)
get_online_cpus();
subsys_interface_unregister(_interface);
remove_boost_sysfs_file();
-   cpuhp_remove_state_nocalls(hp_online);
+   cpuhp_remove_state_nocalls_cpuslocked(hp_online);
 
write_lock_irqsave(_driver_lock, flags);
 


[tip:smp/hotplug] cpufreq: Use cpuhp_setup_state_nocalls_cpuslocked()

2017-04-20 Thread tip-bot for Sebastian Andrzej Siewior
Commit-ID:  6d7d2f1f9e6e0c2d6fb9de82ad5fbc3aed115829
Gitweb: http://git.kernel.org/tip/6d7d2f1f9e6e0c2d6fb9de82ad5fbc3aed115829
Author: Sebastian Andrzej Siewior 
AuthorDate: Tue, 18 Apr 2017 19:04:48 +0200
Committer:  Thomas Gleixner 
CommitDate: Thu, 20 Apr 2017 13:08:52 +0200

cpufreq: Use cpuhp_setup_state_nocalls_cpuslocked()

cpufreq holds get_online_cpus() while invoking cpuhp_setup_state_nocalls()
to make subsys_interface_register() and the registration of hotplug calls
atomic versus cpu hotplug.

cpuhp_setup_state_nocalls() invokes get_online_cpus() as well. This is
correct, but prevents the conversion of the hotplug locking to a percpu
rwsem.

Use cpuhp_setup/remove_state_nocalls_cpuslocked() to avoid the nested call.

Signed-off-by: Sebastian Andrzej Siewior 
Signed-off-by: Thomas Gleixner 
Acked-by: "Rafael J. Wysocki" 
Acked-by: Viresh Kumar 
Cc: linux...@vger.kernel.org
Cc: Peter Zijlstra 
Cc: Steven Rostedt 
Link: http://lkml.kernel.org/r/20170418170552.865966...@linutronix.de

---
 drivers/cpufreq/cpufreq.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 0e3f649..67ef7ce 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2473,9 +2473,10 @@ int cpufreq_register_driver(struct cpufreq_driver 
*driver_data)
goto err_if_unreg;
}
 
-   ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "cpufreq:online",
-   cpuhp_cpufreq_online,
-   cpuhp_cpufreq_offline);
+   ret = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN,
+  "cpufreq:online",
+  cpuhp_cpufreq_online,
+  cpuhp_cpufreq_offline);
if (ret < 0)
goto err_if_unreg;
hp_online = ret;
@@ -2519,7 +2520,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver 
*driver)
get_online_cpus();
subsys_interface_unregister(_interface);
remove_boost_sysfs_file();
-   cpuhp_remove_state_nocalls(hp_online);
+   cpuhp_remove_state_nocalls_cpuslocked(hp_online);
 
write_lock_irqsave(_driver_lock, flags);