intel_powerclamp: Fix cstate counter detection.
PATCH 1/1 intel_powerclamp: Fix cstate counter detection.
Having all zero cstate count doesn't necesserily mean the cstate counter is no functional.
--- drivers/thermal/intel_powerclamp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/thermal/intel_powerclamp.c +10 -1
@@ -206,6 +206,15 @@ static void find_target_mwait(void) } +static bool has_pkg_state_counter (void ) +{ +u64 tmp; +return !rdmsrl_safe (MSR_PKG_C2_RESIDENCY , &tmp) || + !rdmsrl_safe (MSR_PKG_C3_RESIDENCY , &tmp) || + !rdmsrl_safe (MSR_PKG_C6_RESIDENCY , &tmp) || + !rdmsrl_safe (MSR_PKG_C7_RESIDENCY , &tmp); +} +static u64 pkg_state_counter (void ) {u64 val;
@@ -500,7 +509,7 @@ static int start_power_clamp(void)struct task_struct *thread;/* check if pkg cstate counter is completely 0, abort in this case */ -if (!pkg_state_counter ()) { +if (!has_pkg_state_counter ()) {pr_err ("pkg cstate counter not functional, abort\n" );return -EINVAL ; }
Signature · 1 line
1.8.4.2
Quoted 3 lines · Yuxuan Shui
Having all zero cstate count doesn't necesserily mean the cstate counter is no functional.
... but it does mean that powerclamp will be non-functional
but you had a reason to make this patch.
Can you expand a little bit on what you were seeing that made you decide this patch was needed ?
There are possibilities that the system is busy from boot so that it doesn't enter C-state at all, right? In that situation powerclamp won't work.
Also, pkg_state_counter is used to calculate a cstate ratio, and I can't find any reason why powerclamp will be non-funtional when that ratio is zero.
Quoted 12 lines · Arjan van de Ven
Quoted 4 lines · Yuxuan Shui
Having all zero cstate count doesn't necesserily mean the cstate counter is no functional.
... but it does mean that powerclamp will be non-functional
but you had a reason to make this patch.
Can you expand a little bit on what you were seeing that made you decide this patch was needed ?
A message that is not in the archive (sent off-list or not yet received): CAGqt0zw2wEM_4SqMA8tqzABe0M1-ZXxM6X3rh4OezfnS9-eXJg@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 18 lines · Arjan van de Ven
Quoted 17 lines · Yuxuan Shui
Quoted 14 lines · Arjan van de Ven
Quoted 5 lines · Yuxuan Shui
Having all zero cstate count doesn't necesserily mean the cstate counter is no functional.
... but it does mean that powerclamp will be non-functional
but you had a reason to make this patch.
Can you expand a little bit on what you were seeing that made you decide this patch was needed ?
Quoted 7 lines
Quoted 3 lines
There are possibilities that the system is busy from boot so that it doesn't enter C-state at all, right? In that situation powerclamp won't work.
that is... extremely unlikely. Have you seen that happen?
Sure I've seen this, that's why I wrote this patch in the first place. It's my (rather old) laptop. After boot powertop show zero percent in C3 and C6, and powerclamp complaining pkg cstate counter is not functional.
Quoted 8 lines
Quoted 5 lines
Also,
pkg_state_counteris used to calculate a cstate ratio, and I can't find any reason why powerclamp will be non-funtional when that ratio is zero.if the counters we use are zero.. we can't use them in our control loop
I skimmed through the code. pkg_state_counter is called twice (except that once in start_power_clamp). Once in poll_pkg_cstate to calculate pkg_cstate_ratio_cur which is used for sysfs. The other time is in powerclamp_adjust_controls, which is used to calculate a ratio which is stored in a global variable current_ratio.
The current_ratio is also used twice. Once in the same function, to check if we have done enough idle injection. The other is in adjust_compensation, where it's used to calculate a delta. In neither case current_ratio being zero will matter.
Also, I'm using this patch myself, and it seems to be totally functional.
So I failed to see why the counter can't be zero. If I made any mistakes, can you point them out?
Quoted 2 lines
again, what were you actually seeing?
Quoted 26 lines · On Wed, 20 Nov 2013 02:09:12 +0800 Yuxuan Shui <[email protected]> wrote:
Quoted 24 lines · Arjan van de Ven
Quoted 20 lines · Yuxuan Shui
Quoted 8 lines · Arjan van de Ven
Quoted 5 lines · Yuxuan Shui
Having all zero cstate count doesn't necesserily mean the cstate counter is no functional.
Quoted 6 lines
... but it does mean that powerclamp will be non-functional
but you had a reason to make this patch.
Can you expand a little bit on what you were seeing that made you decide this patch was needed ?There are possibilities that the system is busy from boot so that it doesn't enter C-state at all, right? In that situation powerclamp won't work.
Quoted 7 lines
Quoted 1 line
that is... extremely unlikely. Have you seen that happen?
Sure I've seen this, that's why I wrote this patch in the first place. It's my (rather old) laptop. After boot powertop show zero percent in C3 and C6, and powerclamp complaining pkg cstate counter is not functional.
I see, this is indeed a corner case where the sanity check by powerclamp driver is too strict and refused to load. I am OK with your patch and perhaps add a sanity check later while idle injection is in action?
Quoted 29 lines
Quoted 9 lines
Quoted 5 lines
Also,
pkg_state_counteris used to calculate a cstate ratio, and I can't find any reason why powerclamp will be non-funtional when that ratio is zero.if the counters we use are zero.. we can't use them in our control loop
I skimmed through the code.
pkg_state_counteris called twice (except that once instart_power_clamp). Once inpoll_pkg_cstateto calculatepkg_cstate_ratio_curwhich is used for sysfs. The other time is inpowerclamp_adjust_controls, which is used to calculate a ratio which is stored in a global variablecurrent_ratio.The
current_ratiois also used twice. Once in the same function, to check if we have done enough idle injection. The other is inadjust_compensation, where it's used to calculate a delta. In neither casecurrent_ratiobeing zero will matter.Also, I'm using this patch myself, and it seems to be totally functional.
So I failed to see why the counter can't be zero. If I made any mistakes, can you point them out?
Quoted 1 line
Quoted 5 lines
Quoted 1 line
again, what were you actually seeing?
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Jacob Pan]
Zhang Rui
reviewerQuoted 31 lines · Jacob Pan
Quoted 28 lines · On Wed, 20 Nov 2013 02:09:12 +0800 Yuxuan Shui <[email protected]> wrote:
Quoted 25 lines · Arjan van de Ven
Quoted 13 lines · Yuxuan Shui
Quoted 10 lines · Arjan van de Ven
Quoted 5 lines · Yuxuan Shui
Having all zero cstate count doesn't necesserily mean the cstate counter is no functional.
... but it does mean that powerclamp will be non-functional
Quoted 7 lines
Quoted 4 lines
but you had a reason to make this patch.
Can you expand a little bit on what you were seeing that made you decide this patch was needed ?There are possibilities that the system is busy from boot so that it doesn't enter C-state at all, right? In that situation powerclamp won't work.
that is... extremely unlikely. Have you seen that happen?
Quoted 9 lines
Quoted 5 lines
Sure I've seen this, that's why I wrote this patch in the first place. It's my (rather old) laptop. After boot powertop show zero percent in C3 and C6, and powerclamp complaining pkg cstate counter is not functional.
I see, this is indeed a corner case where the sanity check by powerclamp driver is too strict and refused to load. I am OK with your patch and perhaps add a sanity check later while idle injection is in action?
so do you want me to include this patch for 3.14?
thanks,
rui
Quoted 40 lines
Quoted 29 lines
Quoted 9 lines
Quoted 5 lines
Also,
pkg_state_counteris used to calculate a cstate ratio, and I can't find any reason why powerclamp will be non-funtional when that ratio is zero.if the counters we use are zero.. we can't use them in our control loop
I skimmed through the code.
pkg_state_counteris called twice (except that once instart_power_clamp). Once inpoll_pkg_cstateto calculatepkg_cstate_ratio_curwhich is used for sysfs. The other time is inpowerclamp_adjust_controls, which is used to calculate a ratio which is stored in a global variablecurrent_ratio.The
current_ratiois also used twice. Once in the same function, to check if we have done enough idle injection. The other is inadjust_compensation, where it's used to calculate a delta. In neither casecurrent_ratiobeing zero will matter.Also, I'm using this patch myself, and it seems to be totally functional.
So I failed to see why the counter can't be zero. If I made any mistakes, can you point them out?
Quoted 1 line
Quoted 5 lines
Quoted 1 line
again, what were you actually seeing?
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html[Jacob Pan]
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 37 lines · On Thu, 02 Jan 2014 11:03:32 +0800 Zhang Rui <[email protected]> wrote:
Quoted 36 lines · Jacob Pan
Quoted 33 lines · On Wed, 20 Nov 2013 02:09:12 +0800 Yuxuan Shui <[email protected]> wrote:
Quoted 18 lines · Arjan van de Ven
Quoted 17 lines · Yuxuan Shui
Quoted 14 lines · Arjan van de Ven
Quoted 5 lines · Yuxuan Shui
Having all zero cstate count doesn't necesserily mean the cstate counter is no functional.
... but it does mean that powerclamp will be non-functional
but you had a reason to make this patch.
Can you expand a little bit on what you were seeing that made you decide this patch was needed ?Quoted 7 lines
Quoted 3 lines
There are possibilities that the system is busy from boot so that it doesn't enter C-state at all, right? In that situation powerclamp won't work.
that is... extremely unlikely. Have you seen that happen?
Sure I've seen this, that's why I wrote this patch in the first place. It's my (rather old) laptop. After boot powertop show zero percent in C3 and C6, and powerclamp complaining pkg cstate counter is not functional.
Quoted 7 lines
Quoted 5 lines
I see, this is indeed a corner case where the sanity check by powerclamp driver is too strict and refused to load. I am OK with your patch and perhaps add a sanity check later while idle injection is in action?
so do you want me to include this patch for 3.14?
yes.
Thanks,
Jacob
Quoted 46 lines
thanks,
ruiQuoted 41 lines
Quoted 30 lines
Quoted 9 lines
Quoted 5 lines
Also,
pkg_state_counteris used to calculate a cstate ratio, and I can't find any reason why powerclamp will be non-funtional when that ratio is zero.if the counters we use are zero.. we can't use them in our control loop
I skimmed through the code.
pkg_state_counteris called twice (except that once instart_power_clamp). Once inpoll_pkg_cstateto calculatepkg_cstate_ratio_curwhich is used for sysfs. The other time is inpowerclamp_adjust_controls, which is used to calculate a ratio which is stored in a global variablecurrent_ratio.The
current_ratiois also used twice. Once in the same function, to check if we have done enough idle injection. The other is inadjust_compensation, where it's used to calculate a delta. In neither casecurrent_ratiobeing zero will matter.Also, I'm using this patch myself, and it seems to be totally functional.
So I failed to see why the counter can't be zero. If I made any mistakes, can you point them out?
Quoted 1 line
Quoted 5 lines
Quoted 1 line
again, what were you actually seeing?
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html[Jacob Pan]
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html