diff mbox

[1/3] intel_pstate: Use pr_fmt

Message ID 710e23a9e0846d1aaa660849321e433b5f5dd4e7.1459887986.git.joe@perches.com (mailing list archive)
State Accepted, archived
Delegated to: Rafael Wysocki
Headers show

Commit Message

Joe Perches April 5, 2016, 8:28 p.m. UTC
Prefix the output using the more common kernel style.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/cpufreq/intel_pstate.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

Comments

srinivas pandruvada April 5, 2016, 9:43 p.m. UTC | #1
On Tue, 2016-04-05 at 13:28 -0700, Joe Perches wrote:
> Prefix the output using the more common kernel style.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
>  drivers/cpufreq/intel_pstate.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/cpufreq/intel_pstate.c
> b/drivers/cpufreq/intel_pstate.c
> index a382195..e674db8 100644
> --- a/drivers/cpufreq/intel_pstate.c
> +++ b/drivers/cpufreq/intel_pstate.c
> @@ -10,6 +10,8 @@
>   * of the License.
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/kernel.h>
>  #include <linux/kernel_stat.h>
>  #include <linux/module.h>
> @@ -436,7 +438,7 @@ static ssize_t store_no_turbo(struct kobject *a,
> struct attribute *b,
>  
>  	update_turbo_state();
>  	if (limits->turbo_disabled) {
> -		pr_warn("intel_pstate: Turbo disabled by BIOS or
> unavailable on processor\n");
> +		pr_warn("Turbo disabled by BIOS or unavailable on
> processor\n");
>  		return -EPERM;
>  	}
>  
> @@ -1107,7 +1109,7 @@ static int intel_pstate_init_cpu(unsigned int
> cpunum)
>  
>  	intel_pstate_busy_pid_reset(cpu);
>  
> -	pr_debug("intel_pstate: controlling: cpu %d\n", cpunum);
> +	pr_debug("controlling: cpu %d\n", cpunum);
>  
>  	return 0;
>  }
> @@ -1149,12 +1151,12 @@ static int intel_pstate_set_policy(struct
> cpufreq_policy *policy)
>  
>  	if (policy->policy == CPUFREQ_POLICY_PERFORMANCE &&
>  	    policy->max >= policy->cpuinfo.max_freq) {
> -		pr_debug("intel_pstate: set performance\n");
> +		pr_debug("set performance\n");
>  		limits = &performance_limits;
>  		goto out;
>  	}
>  
> -	pr_debug("intel_pstate: set powersave\n");
> +	pr_debug("set powersave\n");
>  	limits = &powersave_limits;
>  	limits->min_policy_pct = (policy->min * 100) / policy-
> >cpuinfo.max_freq;
>  	limits->min_policy_pct = clamp_t(int, limits-
> >min_policy_pct, 0 , 100);
> @@ -1206,7 +1208,7 @@ static void intel_pstate_stop_cpu(struct
> cpufreq_policy *policy)
>  	int cpu_num = policy->cpu;
>  	struct cpudata *cpu = all_cpu_data[cpu_num];
>  
> -	pr_debug("intel_pstate: CPU %d exiting\n", cpu_num);
> +	pr_debug("CPU %d exiting\n", cpu_num);
>  
>  	intel_pstate_clear_update_util_hook(cpu_num);
>  
> @@ -1451,7 +1453,7 @@ hwp_cpu_matched:
>  	if (intel_pstate_platform_pwr_mgmt_exists())
>  		return -ENODEV;
>  
> -	pr_info("Intel P-state driver initializing.\n");
> +	pr_info("Intel P-state driver initializing\n");
>  
>  	all_cpu_data = vzalloc(sizeof(void *) *
> num_possible_cpus());
>  	if (!all_cpu_data)
> @@ -1468,7 +1470,7 @@ hwp_cpu_matched:
>  	intel_pstate_sysfs_expose_params();
>  
>  	if (hwp_active)
> -		pr_info("intel_pstate: HWP enabled\n");
> +		pr_info("HWP enabled\n");
>  
>  	return rc;
>  out:
> @@ -1494,7 +1496,7 @@ static int __init intel_pstate_setup(char *str)
>  	if (!strcmp(str, "disable"))
>  		no_load = 1;
>  	if (!strcmp(str, "no_hwp")) {
> -		pr_info("intel_pstate: HWP disabled\n");
> +		pr_info("HWP disabled\n");
>  		no_hwp = 1;
>  	}
>  	if (!strcmp(str, "force"))
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Viresh Kumar April 6, 2016, 6:14 a.m. UTC | #2
On 05-04-16, 13:28, Joe Perches wrote:
> Prefix the output using the more common kernel style.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  drivers/cpufreq/intel_pstate.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Doug Smythies April 6, 2016, 2:51 p.m. UTC | #3
On 2016.04.05 02:44 Srinivas Pandruvada wrote:
> On Tue, 2016-04-05 at 13:28 -0700, Joe Perches wrote:
>> Prefix the output using the more common kernel style.
>> 
>> Signed-off-by: Joe Perches <joe@perches.com>
> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
>> ---
>>  drivers/cpufreq/intel_pstate.c | 18 ++++++++++--------
>>  1 file changed, 10 insertions(+), 8 deletions(-)

...[cut, example left]...

> -		pr_warn("intel_pstate: Turbo disabled by BIOS or
> unavailable on processor\n");
> +		pr_warn("Turbo disabled by BIOS or unavailable on
> processor\n");

I do  not understand.
The common and unique string "intel_pstate" was added on purpose
so as to provide a way to easily extract the related message from
an otherwise huge log file.

Reference:
commit f16255eb930173f386db0ce78ed41401aa8a94a6



--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Viresh Kumar April 6, 2016, 3:01 p.m. UTC | #4
On 06-04-16, 07:51, Doug Smythies wrote:
> On 2016.04.05 02:44 Srinivas Pandruvada wrote:
> > On Tue, 2016-04-05 at 13:28 -0700, Joe Perches wrote:
> >> Prefix the output using the more common kernel style.
> >> 
> >> Signed-off-by: Joe Perches <joe@perches.com>
> > Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> >> ---
> >>  drivers/cpufreq/intel_pstate.c | 18 ++++++++++--------
> >>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> ...[cut, example left]...
> 
> > -		pr_warn("intel_pstate: Turbo disabled by BIOS or
> > unavailable on processor\n");
> > +		pr_warn("Turbo disabled by BIOS or unavailable on
> > processor\n");
> 
> I do  not understand.
> The common and unique string "intel_pstate" was added on purpose
> so as to provide a way to easily extract the related message from
> an otherwise huge log file.

The first line of the patch does this:

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

which will automagically add name of the current file (intel_pstate)
before every print message printed using pr_*() helpers.
Joe Perches April 6, 2016, 3:12 p.m. UTC | #5
On Wed, 2016-04-06 at 07:51 -0700, Doug Smythies wrote:
> On 2016.04.05 02:44 Srinivas Pandruvada wrote:
> > 
> > On Tue, 2016-04-05 at 13:28 -0700, Joe Perches wrote:
> > > 
> > > Prefix the output using the more common kernel style.
> > > 
> > > Signed-off-by: Joe Perches <joe@perches.com>
> > Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> > > 
> > > ---
> > >  drivers/cpufreq/intel_pstate.c | 18 ++++++++++--------
> > >  1 file changed, 10 insertions(+), 8 deletions(-)
> ...[cut, example left]...
> 
> > 
> > -		pr_warn("intel_pstate: Turbo disabled by BIOS or
> > unavailable on processor\n");
> > +		pr_warn("Turbo disabled by BIOS or unavailable on
> > processor\n");
> I do  not understand.
> The common and unique string "intel_pstate" was added on purpose
> so as to provide a way to easily extract the related message from
> an otherwise huge log file.
> 

The more common kernel mechanism to prefix messages
is using a pr_fmt define like:

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

This style is used ~1000 times in the kernel tree.

All of the pr_<level> macros are defined like:

#define pr_info(fmt, ...) \
	printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)

so this prefixes all messages and means that any
new message added later will also be prefixed without
copy/paste defects or omission.

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Doug Smythies April 6, 2016, 3:47 p.m. UTC | #6
On 2106.03.06 08:13 Joe Perches wrote:
> On Wed, 2016-04-06 at 07:51 -0700, Doug Smythies wrote:
>> On 2016.04.05 02:44 Srinivas Pandruvada wrote: 
>>> On Tue, 2016-04-05 at 13:28 -0700, Joe Perches wrote:

> The more common kernel mechanism to prefix messages
> is using a pr_fmt define like:
>
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

> so this prefixes all messages and means that any
> new message added later will also be prefixed without
> copy/paste defects or omission.

Ok. Thanks for your reply and education (and Viresh also).
And sorry for my the ignorance in my patch submission last May.

... Doug


--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index a382195..e674db8 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -10,6 +10,8 @@ 
  * of the License.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/kernel.h>
 #include <linux/kernel_stat.h>
 #include <linux/module.h>
@@ -436,7 +438,7 @@  static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
 
 	update_turbo_state();
 	if (limits->turbo_disabled) {
-		pr_warn("intel_pstate: Turbo disabled by BIOS or unavailable on processor\n");
+		pr_warn("Turbo disabled by BIOS or unavailable on processor\n");
 		return -EPERM;
 	}
 
@@ -1107,7 +1109,7 @@  static int intel_pstate_init_cpu(unsigned int cpunum)
 
 	intel_pstate_busy_pid_reset(cpu);
 
-	pr_debug("intel_pstate: controlling: cpu %d\n", cpunum);
+	pr_debug("controlling: cpu %d\n", cpunum);
 
 	return 0;
 }
@@ -1149,12 +1151,12 @@  static int intel_pstate_set_policy(struct cpufreq_policy *policy)
 
 	if (policy->policy == CPUFREQ_POLICY_PERFORMANCE &&
 	    policy->max >= policy->cpuinfo.max_freq) {
-		pr_debug("intel_pstate: set performance\n");
+		pr_debug("set performance\n");
 		limits = &performance_limits;
 		goto out;
 	}
 
-	pr_debug("intel_pstate: set powersave\n");
+	pr_debug("set powersave\n");
 	limits = &powersave_limits;
 	limits->min_policy_pct = (policy->min * 100) / policy->cpuinfo.max_freq;
 	limits->min_policy_pct = clamp_t(int, limits->min_policy_pct, 0 , 100);
@@ -1206,7 +1208,7 @@  static void intel_pstate_stop_cpu(struct cpufreq_policy *policy)
 	int cpu_num = policy->cpu;
 	struct cpudata *cpu = all_cpu_data[cpu_num];
 
-	pr_debug("intel_pstate: CPU %d exiting\n", cpu_num);
+	pr_debug("CPU %d exiting\n", cpu_num);
 
 	intel_pstate_clear_update_util_hook(cpu_num);
 
@@ -1451,7 +1453,7 @@  hwp_cpu_matched:
 	if (intel_pstate_platform_pwr_mgmt_exists())
 		return -ENODEV;
 
-	pr_info("Intel P-state driver initializing.\n");
+	pr_info("Intel P-state driver initializing\n");
 
 	all_cpu_data = vzalloc(sizeof(void *) * num_possible_cpus());
 	if (!all_cpu_data)
@@ -1468,7 +1470,7 @@  hwp_cpu_matched:
 	intel_pstate_sysfs_expose_params();
 
 	if (hwp_active)
-		pr_info("intel_pstate: HWP enabled\n");
+		pr_info("HWP enabled\n");
 
 	return rc;
 out:
@@ -1494,7 +1496,7 @@  static int __init intel_pstate_setup(char *str)
 	if (!strcmp(str, "disable"))
 		no_load = 1;
 	if (!strcmp(str, "no_hwp")) {
-		pr_info("intel_pstate: HWP disabled\n");
+		pr_info("HWP disabled\n");
 		no_hwp = 1;
 	}
 	if (!strcmp(str, "force"))