Skip to contentSkip to conversation

intel_pstate: prevent max_perf_pct < min_perf_pct

PATCH In review Seiichi Ikarashi 3 participants 6 messages Sep 4, 2015 – Sep 9, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 intel_pstate: prevent max_perf_pct < min_perf_pct

Add some value check to prevent a reversal, max_perf_pct < min_perf_pct.

---
 drivers/cpufreq/intel_pstate.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/cpufreq/intel_pstate.c +2 -0
index fcb929e..03dda19 100644
@@ -423,6 +423,7 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
 
 	limits.max_sysfs_pct = clamp_t(int, input, 0 , 100);
 	limits.max_perf_pct = min(limits.max_policy_pct, limits.max_sysfs_pct);
+	limits.max_perf_pct = max(limits.max_perf_pct, limits.min_perf_pct);
 	limits.max_perf = div_fp(int_tofp(limits.max_perf_pct), int_tofp(100));
 
 	if (hwp_active)
@@ -442,6 +443,7 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b,
 
 	limits.min_sysfs_pct = clamp_t(int, input, 0 , 100);
 	limits.min_perf_pct = max(limits.min_policy_pct, limits.min_sysfs_pct);
+	limits.min_perf_pct = min(limits.min_perf_pct, limits.max_perf_pct);
 	limits.min_perf = div_fp(int_tofp(limits.min_perf_pct), int_tofp(100));
 
 	if (hwp_active)
#1 lore raw

Hi, Seiichi

Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:linux-pm- [email protected]] On Behalf Of Seiichi Ikarashi
Sent: Friday, September 04, 2015 6:59 PM
To: [email protected]; Wysocki, Rafael J
Cc: [email protected]
Subject: [PATCH] intel_pstate: prevent max_perf_pct < min_perf_pct

Quoted 4 lines

Add some value check to prevent a reversal, max_perf_pct < min_perf_pct.

I guess a similar patch has been sent at:
https://patchwork.kernel.org/patch/6995461/

Best Regards,
Yu

#2 lore raw
Quoted 10 lines · Yu C

Hi, Seiichi

Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:linux-pm- [email protected]] On Behalf Of Seiichi Ikarashi
Sent: Friday, September 04, 2015 6:59 PM
To: [email protected]; Wysocki, Rafael J
Cc: [email protected]
Subject: [PATCH] intel_pstate: prevent max_perf_pct < min_perf_pct

Quoted 6 lines
Quoted 4 lines

Add some value check to prevent a reversal, max_perf_pct < min_perf_pct.

I guess a similar patch has been sent at:
https://patchwork.kernel.org/patch/6995461/

I seem to have overlooked this one, most likely because it was set as an RFC.

I'll find it and respond to it now.

Thanks,
Rafael

#3 lore raw
In reply to Chen, Yu C

Hi, Yu

Quoted 10 lines · Yu C

Hi, Seiichi

Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:linux-pm- [email protected]] On Behalf Of Seiichi Ikarashi
Sent: Friday, September 04, 2015 6:59 PM
To: [email protected]; Wysocki, Rafael J
Cc: [email protected]
Subject: [PATCH] intel_pstate: prevent max_perf_pct < min_perf_pct

Quoted 6 lines
Quoted 4 lines

Add some value check to prevent a reversal, max_perf_pct < min_perf_pct.

I guess a similar patch has been sent at:
https://patchwork.kernel.org/patch/6995461/

Yes, your patch looks better than mine from the point of view of covering intel_pstate_set_policy().

Still I have a question.
Does your patch allow the following condition?

limits.max_policy_pct > limits.min_perf_pct > limits.max_perf_pct > limits.min_policy_pct

Regards,
Ikarashi

#4 lore raw

Hi, Seiichi

Quoted 29 lines

-----Original Message-----
From: Seiichi Ikarashi [mailto:[email protected]]
Sent: Tuesday, September 08, 2015 7:19 AM
To: Chen, Yu C
Cc: [email protected]; Wysocki, Rafael J; [email protected]; Zhang, Rui
Subject: Re: [PATCH] intel_pstate: prevent max_perf_pct < min_perf_pct

Hi, Yu

Quoted 11 lines · Yu C

Hi, Seiichi

Quoted 9 lines

-----Original Message-----
From: [email protected] [mailto:linux-pm- [email protected]] On Behalf Of Seiichi Ikarashi
Sent: Friday, September 04, 2015 6:59 PM
To: [email protected]; Wysocki, Rafael J
Cc: [email protected]
Subject: [PATCH] intel_pstate: prevent max_perf_pct < min_perf_pct

Add some value check to prevent a reversal, max_perf_pct <

min_perf_pct.

Quoted 5 lines
Quoted 3 lines

I guess a similar patch has been sent at:
https://patchwork.kernel.org/patch/6995461/

Quoted 9 lines

Yes, your patch looks better than mine from the point of view of covering intel_pstate_set_policy().

Still I have a question.
Does your patch allow the following condition?

limits.max_policy_pct > limits.min_perf_pct > limits.max_perf_pct >
limits.min_policy_pct

Thanks! Seems my previous patch does not guarantee
max_perf_pct >= min_perf_pct, I think following logic would be better:
Step0: normalize the user input to [min_policy, max_policy]
Step1: make sure max_perf_pct>= min_perf_pct

BTW,why I add step0 here is because we should not rely on user input, and different policy might have different (min,max), for example, max_policy_pct=40,min_policy_pct=30, and user input of
echo 50 > min_sysfs_pct would make the final min_perf_pct to 50, it's not in legal policy scope, so...

Best Regards,
Yu

#5 lore raw

Hi, Yu

Quoted 20 lines · Yu C

Hi, Seiichi

Quoted 12 lines
Quoted 2 lines

I guess a similar patch has been sent at:
https://patchwork.kernel.org/patch/6995461/

Yes, your patch looks better than mine from the point of view of covering intel_pstate_set_policy().

Still I have a question.
Does your patch allow the following condition?

limits.max_policy_pct > limits.min_perf_pct > limits.max_perf_pct >
limits.min_policy_pct

Thanks! Seems my previous patch does not guarantee
max_perf_pct >= min_perf_pct, I think following logic would be better:
Step0: normalize the user input to [min_policy, max_policy]
Step1: make sure max_perf_pct>= min_perf_pct

Quoted 5 lines

BTW,why I add step0 here is because we should not rely on user input, and different policy might have different (min,max), for example, max_policy_pct=40,min_policy_pct=30, and user input of
echo 50 > min_sysfs_pct would make the final min_perf_pct to 50, it's not in legal policy scope, so...

Those two steps will make sense.
I will review your upcoming v2 patch.

Regards,
Seiichi