diff mbox

PowerCap / RAPL : Use async init

Message ID 1394214529-11369-1-git-send-email-srinivas.pandruvada@linux.intel.com (mailing list archive)
State RFC, archived
Headers show

Commit Message

srinivas pandruvada March 7, 2014, 5:48 p.m. UTC
The rapl_init function takes around 58ms per domain. This change
reduce this by introducing async_schedule. Only disadvanatge is
that only presence of RAPL feature is checked for succesful module
init. If there is any other error, it will simply not create powercap
sysfs files, but module will still return success.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/powercap/intel_rapl.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

Comments

Rafael J. Wysocki March 7, 2014, 10:50 p.m. UTC | #1
On Friday, March 07, 2014 09:48:49 AM Srinivas Pandruvada wrote:
> The rapl_init function takes around 58ms per domain. This change
> reduce this by introducing async_schedule. Only disadvanatge is
> that only presence of RAPL feature is checked for succesful module
> init. If there is any other error, it will simply not create powercap
> sysfs files, but module will still return success.

Well, can't we wait for the async stuff to complete and collect status from
it before returning from rapl_init()?

> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
>  drivers/powercap/intel_rapl.c | 26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c
> index 61b51e1..3b11c6f 100644
> --- a/drivers/powercap/intel_rapl.c
> +++ b/drivers/powercap/intel_rapl.c
> @@ -29,6 +29,7 @@
>  #include <linux/sysfs.h>
>  #include <linux/cpu.h>
>  #include <linux/powercap.h>
> +#include <linux/async.h>
>  
>  #include <asm/processor.h>
>  #include <asm/cpu_device_id.h>
> @@ -1364,16 +1365,10 @@ static struct notifier_block rapl_cpu_notifier = {
>  	.notifier_call = rapl_cpu_callback,
>  };
>  
> -static int __init rapl_init(void)
> +static void __init rapl_init_async(void *unused, async_cookie_t cookie)
>  {
>  	int ret = 0;
>  
> -	if (!x86_match_cpu(rapl_ids)) {
> -		pr_err("driver does not support CPU family %d model %d\n",
> -			boot_cpu_data.x86, boot_cpu_data.x86_model);
> -
> -		return -ENODEV;
> -	}
>  	/* prevent CPU hotplug during detection */
>  	get_online_cpus();
>  	ret = rapl_detect_topology();
> @@ -1382,14 +1377,27 @@ static int __init rapl_init(void)
>  
>  	if (rapl_register_powercap()) {
>  		rapl_cleanup_data();
> -		ret = -ENODEV;
>  		goto done;
>  	}
>  	register_hotcpu_notifier(&rapl_cpu_notifier);
>  done:
>  	put_online_cpus();
>  
> -	return ret;
> +}
> +
> +static int __init rapl_init(void)
> +{
> +
> +	if (!x86_match_cpu(rapl_ids)) {
> +		pr_err("driver does not support CPU family %d model %d\n",
> +			boot_cpu_data.x86, boot_cpu_data.x86_model);
> +
> +		return -ENODEV;
> +	}
> +
> +	async_schedule(rapl_init_async, NULL);
> +
> +	return 0;
>  }
>  
>  static void __exit rapl_exit(void)
>
diff mbox

Patch

diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c
index 61b51e1..3b11c6f 100644
--- a/drivers/powercap/intel_rapl.c
+++ b/drivers/powercap/intel_rapl.c
@@ -29,6 +29,7 @@ 
 #include <linux/sysfs.h>
 #include <linux/cpu.h>
 #include <linux/powercap.h>
+#include <linux/async.h>
 
 #include <asm/processor.h>
 #include <asm/cpu_device_id.h>
@@ -1364,16 +1365,10 @@  static struct notifier_block rapl_cpu_notifier = {
 	.notifier_call = rapl_cpu_callback,
 };
 
-static int __init rapl_init(void)
+static void __init rapl_init_async(void *unused, async_cookie_t cookie)
 {
 	int ret = 0;
 
-	if (!x86_match_cpu(rapl_ids)) {
-		pr_err("driver does not support CPU family %d model %d\n",
-			boot_cpu_data.x86, boot_cpu_data.x86_model);
-
-		return -ENODEV;
-	}
 	/* prevent CPU hotplug during detection */
 	get_online_cpus();
 	ret = rapl_detect_topology();
@@ -1382,14 +1377,27 @@  static int __init rapl_init(void)
 
 	if (rapl_register_powercap()) {
 		rapl_cleanup_data();
-		ret = -ENODEV;
 		goto done;
 	}
 	register_hotcpu_notifier(&rapl_cpu_notifier);
 done:
 	put_online_cpus();
 
-	return ret;
+}
+
+static int __init rapl_init(void)
+{
+
+	if (!x86_match_cpu(rapl_ids)) {
+		pr_err("driver does not support CPU family %d model %d\n",
+			boot_cpu_data.x86, boot_cpu_data.x86_model);
+
+		return -ENODEV;
+	}
+
+	async_schedule(rapl_init_async, NULL);
+
+	return 0;
 }
 
 static void __exit rapl_exit(void)