Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1302480 > unrolled thread
| Started by | Leo Yan <leo.yan@linaro.org> |
|---|---|
| First post | 2016-01-06 10:00 +0100 |
| Last post | 2016-01-06 16:10 +0100 |
| Articles | 9 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update sustainable power Leo Yan <leo.yan@linaro.org> - 2016-01-06 10:00 +0100
[PATCH v3 2/4] thermal: power_allocator: change k_pu_ratio/k_po_ratio as percentage Leo Yan <leo.yan@linaro.org> - 2016-01-06 10:00 +0100
[PATCH v3 4/4] thermal: power_allocator: document k_pu_ratio/k_po_ratio Leo Yan <leo.yan@linaro.org> - 2016-01-06 10:00 +0100
[PATCH v3 1/4] thermal: power_allocator: rework proportional parameter Leo Yan <leo.yan@linaro.org> - 2016-01-06 10:00 +0100
[PATCH v3 3/4] thermal: add sys node for k_pu_ratio/k_po_ratio Leo Yan <leo.yan@linaro.org> - 2016-01-06 10:00 +0100
Re: [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update sustainable power Javi Merino <javi.merino@arm.com> - 2016-01-06 11:10 +0100
Re: [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update sustainable power Leo Yan <leo.yan@linaro.org> - 2016-01-06 12:20 +0100
Re: [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update sustainable power Daniel Thompson <daniel.thompson@linaro.org> - 2016-01-06 12:30 +0100
Re: [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update sustainable power Javi Merino <javi.merino@arm.com> - 2016-01-06 16:10 +0100
| From | Leo Yan <leo.yan@linaro.org> |
|---|---|
| Date | 2016-01-06 10:00 +0100 |
| Subject | [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update sustainable power |
| Message-ID | <qNS6J-7dw-7@gated-at.bofh.it> |
k_po/k_pu are two proportional term constants and essentially they have fixed ratio compared with sustainable power. In current implementation, k_po and k_pu are absolute value after calculation and cannot represent the ratio relationship with sustainable power; as a result, when change sustainable power we cannot smoothly change proportional term constant. So this patch series introduces k_po_ratio and k_pu_ratio, which represent the ratio value compared against sustainable power. Also add sys file system nodes for them for easily update them from userspace and update a bit in documentation. Changes from v2: * According to Eduardo' comments, move code from thermal_core to power_allocator file * According to Daniel's review, v1 will introduce accumulated rounding errors; v2 patches can dismiss this issue Changes from v1: * Fix compiling error Leo Yan (4): thermal: power_allocator: rework proportional parameter thermal: power_allocator: change k_pu_ratio/k_po_ratio as percentage thermal: add sys node for k_pu_ratio/k_po_ratio thermal: power_allocator: document k_pu_ratio/k_po_ratio Documentation/thermal/power_allocator.txt | 15 +++++++++++---- drivers/thermal/power_allocator.c | 18 ++++++++++++------ drivers/thermal/thermal_core.c | 23 +++++++++++++++++++++-- include/linux/thermal.h | 4 ++-- 4 files changed, 46 insertions(+), 14 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Leo Yan <leo.yan@linaro.org> |
|---|---|
| Date | 2016-01-06 10:00 +0100 |
| Subject | [PATCH v3 2/4] thermal: power_allocator: change k_pu_ratio/k_po_ratio as percentage |
| Message-ID | <qNS6L-7dw-21@gated-at.bofh.it> |
| In reply to | #1302480 |
Change k_pu_ratio/k_po_ratio as percentage value, so can set these values from sys file nodes with high resolution. Signed-off-by: Leo Yan <leo.yan@linaro.org> --- drivers/thermal/power_allocator.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/power_allocator.c b/drivers/thermal/power_allocator.c index 76d2b47..c5f36fa 100644 --- a/drivers/thermal/power_allocator.c +++ b/drivers/thermal/power_allocator.c @@ -156,10 +156,10 @@ static void estimate_pid_constants(struct thermal_zone_device *tz, return; if (!tz->tzp->k_po_ratio || force) - tz->tzp->k_po_ratio = 1; + tz->tzp->k_po_ratio = 100; if (!tz->tzp->k_pu_ratio || force) - tz->tzp->k_pu_ratio = 2; + tz->tzp->k_pu_ratio = 200; if (!tz->tzp->k_i || force) tz->tzp->k_i = int_to_frac(10) / 1000; @@ -169,9 +169,9 @@ static void estimate_pid_constants(struct thermal_zone_device *tz, */ tz->tzp->k_po = int_to_frac(tz->tzp->k_po_ratio * sustainable_power) / - temperature_threshold; + temperature_threshold / 100; tz->tzp->k_pu = int_to_frac(tz->tzp->k_pu_ratio * sustainable_power) / - temperature_threshold; + temperature_threshold / 100; } /** -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Leo Yan <leo.yan@linaro.org> |
|---|---|
| Date | 2016-01-06 10:00 +0100 |
| Subject | [PATCH v3 4/4] thermal: power_allocator: document k_pu_ratio/k_po_ratio |
| Message-ID | <qNS6K-7dw-13@gated-at.bofh.it> |
| In reply to | #1302480 |
Document k_pu_ratio and k_po_ratio's purpose, and refine formula to demonstrate to use ratio to calculate k_pu/k_po. Signed-off-by: Leo Yan <leo.yan@linaro.org> --- Documentation/thermal/power_allocator.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Documentation/thermal/power_allocator.txt b/Documentation/thermal/power_allocator.txt index a1ce223..8958dab 100644 --- a/Documentation/thermal/power_allocator.txt +++ b/Documentation/thermal/power_allocator.txt @@ -114,13 +114,20 @@ whilst temperature is low, and may lead to temperature overshooting. The default value for `k_pu` is: - 2 * sustainable_power / (desired_temperature - switch_on_temp) + k_pu_ratio * sustainable_power / (desired_temperature - switch_on_temp) This means that at `switch_on_temp` the output of the controller's -proportional term will be 2 * `sustainable_power`. The default value -for `k_po` is: +proportional term will be k_pu_ratio * `sustainable_power`. - sustainable_power / (desired_temperature - switch_on_temp) +The default value for `k_po` is: + + k_po_ratio * sustainable_power / (desired_temperature - switch_on_temp) + +k_pu_ratio's default value is 2 and k_po_ratio's default value is 1. +These two vairants mean the ratio value compared against sustainable power, +so smaller ratio will result in thermal slower ramp. User can set these two +ratio value from sys filesystem nodes, finally k_pu and k_po will be +calculated by updated ratio value. Focusing on the proportional and feed forward values of the PID controller equation we have: -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Leo Yan <leo.yan@linaro.org> |
|---|---|
| Date | 2016-01-06 10:00 +0100 |
| Subject | [PATCH v3 1/4] thermal: power_allocator: rework proportional parameter |
| Message-ID | <qNS6L-7dw-19@gated-at.bofh.it> |
| In reply to | #1302480 |
k_po/k_pu are two proportional term constants and essentially they have
fixed ratio compared with sustainable power. In current implementation,
k_po and k_pu are absolute value after calculation and cannot represent
the ratio relationship with sustainable power; as a result, when change
sustainable power we cannot smoothly change proportional term constant.
So this patch introduces variants k_po_ratio and k_pu_ratio, which
represent the ratio value compared against sustainable power, so smaller
ratio will result in thermal slower ramp. The formulas finally are as
below:
k_pu = k_pu_ratio * sustainable_power /
(desired_temperature - switch_on_temp)
k_po = k_po_ratio * sustainable_power /
(desired_temperature - switch_on_temp)
Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
drivers/thermal/power_allocator.c | 18 ++++++++++++------
include/linux/thermal.h | 4 ++--
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/thermal/power_allocator.c b/drivers/thermal/power_allocator.c
index 1246aa6..76d2b47 100644
--- a/drivers/thermal/power_allocator.c
+++ b/drivers/thermal/power_allocator.c
@@ -155,13 +155,11 @@ static void estimate_pid_constants(struct thermal_zone_device *tz,
if (!temperature_threshold)
return;
- if (!tz->tzp->k_po || force)
- tz->tzp->k_po = int_to_frac(sustainable_power) /
- temperature_threshold;
+ if (!tz->tzp->k_po_ratio || force)
+ tz->tzp->k_po_ratio = 1;
- if (!tz->tzp->k_pu || force)
- tz->tzp->k_pu = int_to_frac(2 * sustainable_power) /
- temperature_threshold;
+ if (!tz->tzp->k_pu_ratio || force)
+ tz->tzp->k_pu_ratio = 2;
if (!tz->tzp->k_i || force)
tz->tzp->k_i = int_to_frac(10) / 1000;
@@ -169,6 +167,11 @@ static void estimate_pid_constants(struct thermal_zone_device *tz,
* The default for k_d and integral_cutoff is 0, so we can
* leave them as they are.
*/
+
+ tz->tzp->k_po = int_to_frac(tz->tzp->k_po_ratio * sustainable_power) /
+ temperature_threshold;
+ tz->tzp->k_pu = int_to_frac(tz->tzp->k_pu_ratio * sustainable_power) /
+ temperature_threshold;
}
/**
@@ -202,6 +205,9 @@ static u32 pid_controller(struct thermal_zone_device *tz,
if (tz->tzp->sustainable_power) {
sustainable_power = tz->tzp->sustainable_power;
+ estimate_pid_constants(tz, sustainable_power,
+ params->trip_switch_on, control_temp,
+ false);
} else {
sustainable_power = estimate_sustainable_power(tz);
estimate_pid_constants(tz, sustainable_power,
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 613c29b..2638f0b 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -284,13 +284,13 @@ struct thermal_zone_params {
* Proportional parameter of the PID controller when
* overshooting (i.e., when temperature is below the target)
*/
- s32 k_po;
+ s32 k_po, k_po_ratio;
/*
* Proportional parameter of the PID controller when
* undershooting
*/
- s32 k_pu;
+ s32 k_pu, k_pu_ratio;
/* Integral parameter of the PID controller */
s32 k_i;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Leo Yan <leo.yan@linaro.org> |
|---|---|
| Date | 2016-01-06 10:00 +0100 |
| Subject | [PATCH v3 3/4] thermal: add sys node for k_pu_ratio/k_po_ratio |
| Message-ID | <qNS6L-7dw-23@gated-at.bofh.it> |
| In reply to | #1302480 |
Add two sys nodes for k_pu_ratio and k_po_ratio, so user can set ratio
value from them. Also change k_pu/k_po as read only nodes, it will only
be used to show proportional term constants which are calculated by
ratio.
Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
drivers/thermal/thermal_core.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index d9e525c..bc149a67 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -955,8 +955,25 @@ static DEVICE_ATTR(sustainable_power, S_IWUSR | S_IRUGO, sustainable_power_show,
} \
static DEVICE_ATTR(name, S_IWUSR | S_IRUGO, name##_show, name##_store)
-create_s32_tzp_attr(k_po);
-create_s32_tzp_attr(k_pu);
+
+#define create_s32_tzp_attr_ro(name) \
+ static ssize_t \
+ name##_show(struct device *dev, struct device_attribute *devattr, \
+ char *buf) \
+ { \
+ struct thermal_zone_device *tz = to_thermal_zone(dev); \
+ \
+ if (tz->tzp) \
+ return sprintf(buf, "%u\n", tz->tzp->name); \
+ else \
+ return -EIO; \
+ } \
+ static DEVICE_ATTR(name, S_IRUGO, name##_show, NULL)
+
+create_s32_tzp_attr_ro(k_po);
+create_s32_tzp_attr_ro(k_pu);
+create_s32_tzp_attr(k_po_ratio);
+create_s32_tzp_attr(k_pu_ratio);
create_s32_tzp_attr(k_i);
create_s32_tzp_attr(k_d);
create_s32_tzp_attr(integral_cutoff);
@@ -968,6 +985,8 @@ static struct device_attribute *dev_tzp_attrs[] = {
&dev_attr_sustainable_power,
&dev_attr_k_po,
&dev_attr_k_pu,
+ &dev_attr_k_po_ratio,
+ &dev_attr_k_pu_ratio,
&dev_attr_k_i,
&dev_attr_k_d,
&dev_attr_integral_cutoff,
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Javi Merino <javi.merino@arm.com> |
|---|---|
| Date | 2016-01-06 11:10 +0100 |
| Subject | Re: [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update sustainable power |
| Message-ID | <qNTcu-87B-5@gated-at.bofh.it> |
| In reply to | #1302480 |
On Wed, Jan 06, 2016 at 04:53:44PM +0800, Leo Yan wrote: > k_po/k_pu are two proportional term constants and essentially they have > fixed ratio compared with sustainable power. In current implementation, > k_po and k_pu are absolute value after calculation and cannot represent > the ratio relationship with sustainable power; as a result, when change > sustainable power we cannot smoothly change proportional term constant. In v2 Daniel said that the use case was made up. Can you elaborate on why we need this? > So this patch series introduces k_po_ratio and k_pu_ratio, which > represent the ratio value compared against sustainable power. Also add > sys file system nodes for them for easily update them from userspace and > update a bit in documentation. Actually, it makes it harder to update from userspace. Now userspace can't set a k_po/k_pu any more, and it's forced to set them as ratios of sustainable power. I'd rather not do this unless there is a good reason for it. Cheers, Javi -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Leo Yan <leo.yan@linaro.org> |
|---|---|
| Date | 2016-01-06 12:20 +0100 |
| Subject | Re: [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update sustainable power |
| Message-ID | <qNUig-nA-71@gated-at.bofh.it> |
| In reply to | #1302515 |
Hi Javi, On Wed, Jan 06, 2016 at 10:07:13AM +0000, Javi Merino wrote: > On Wed, Jan 06, 2016 at 04:53:44PM +0800, Leo Yan wrote: > > k_po/k_pu are two proportional term constants and essentially they have > > fixed ratio compared with sustainable power. In current implementation, > > k_po and k_pu are absolute value after calculation and cannot represent > > the ratio relationship with sustainable power; as a result, when change > > sustainable power we cannot smoothly change proportional term constant. > > In v2 Daniel said that the use case was made up. Can you elaborate on > why we need this? When I did IPA profiling on Hikey, I tried to set different sustainable power. But after changed sustainable power, k_po and k_pu were stale value which calculated by old sustainable power. So with this patch, it's more convinence for profiling and can avoid confusion for k_po/k_pu after update sustainable power. > > So this patch series introduces k_po_ratio and k_pu_ratio, which > > represent the ratio value compared against sustainable power. Also add > > sys file system nodes for them for easily update them from userspace and > > update a bit in documentation. > > Actually, it makes it harder to update from userspace. Now userspace > can't set a k_po/k_pu any more, and it's forced to set them as ratios > of sustainable power. I'd rather not do this unless there is a good > reason for it. We use ratios of sustainable power to calculate k_po/k_pu, so if user explicitly specify ratio values we can easily to update k_po/k_pu after we change sustainable power. Otherwise, it's hard to get to know the real ratio values of sustainable power. Please review below case: - If we set new sustainable power, then actually in kernel it should update k_po/k_pu so that can keep fixed ration; - At the meantime, user can set k_po/k_pu from sys file node so that eventually change ratio; So here has race condition with updating k_po/k_pu and the code is hard to distinguish what is real real ratio. If have explicit parameters for ratios, then will be much clear. Thanks, Leo Yan -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Daniel Thompson <daniel.thompson@linaro.org> |
|---|---|
| Date | 2016-01-06 12:30 +0100 |
| Subject | Re: [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update sustainable power |
| Message-ID | <qNUrU-sc-21@gated-at.bofh.it> |
| In reply to | #1302515 |
On 06/01/16 10:07, Javi Merino wrote: > On Wed, Jan 06, 2016 at 04:53:44PM +0800, Leo Yan wrote: >> k_po/k_pu are two proportional term constants and essentially they have >> fixed ratio compared with sustainable power. In current implementation, >> k_po and k_pu are absolute value after calculation and cannot represent >> the ratio relationship with sustainable power; as a result, when change >> sustainable power we cannot smoothly change proportional term constant. > > In v2 Daniel said that the use case was made up. Can you elaborate on > why we need this? To be clear, I didn't say Leo's use case was made up. In truth I've never asked Leo what his use case is. It was simply the use case that I used to illustrate a bug in the v1 implementation which was made up (and which you asked for more details of). Daniel. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Javi Merino <javi.merino@arm.com> |
|---|---|
| Date | 2016-01-06 16:10 +0100 |
| Subject | Re: [PATCH v3 0/4] thermal: re-calculate k_po/k_pu when update sustainable power |
| Message-ID | <qNXSO-2Of-25@gated-at.bofh.it> |
| In reply to | #1302699 |
On Wed, Jan 06, 2016 at 11:21:54AM +0000, Daniel Thompson wrote: > On 06/01/16 10:07, Javi Merino wrote: > >On Wed, Jan 06, 2016 at 04:53:44PM +0800, Leo Yan wrote: > >>k_po/k_pu are two proportional term constants and essentially they have > >>fixed ratio compared with sustainable power. In current implementation, > >>k_po and k_pu are absolute value after calculation and cannot represent > >>the ratio relationship with sustainable power; as a result, when change > >>sustainable power we cannot smoothly change proportional term constant. > > > >In v2 Daniel said that the use case was made up. Can you elaborate on > >why we need this? > > To be clear, I didn't say Leo's use case was made up. In truth I've > never asked Leo what his use case is. Sorry, I didn't mean to say that Leo had made it up. I was just asking for a use case and it looked to me that the "fan inhibitor mode" was something that you guys had talked about. Cheers, Javi > It was simply the use case that I used to illustrate a bug in the v1 > implementation which was made up (and which you asked for more > details of). > > > > Daniel. > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web