From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Eduardo Valentin <evalenti@kernel.org>,
eduval@amazon.com, rafael@kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Amit Kucheria <amitk@kernel.org>, Zhang Rui <rui.zhang@intel.com>
Subject: Re: [PATCH 1/1] thermal: sysfs: avoid actual readings from sysfs
Date: Wed, 7 Jun 2023 11:24:21 +0200 [thread overview]
Message-ID: <f26ac9a9-60af-a0fe-fccc-25bcd306f5a1@linaro.org> (raw)
In-Reply-To: <20230607003721.834038-1-evalenti@kernel.org>
Hi Eduardo,
On 07/06/2023 02:37, Eduardo Valentin wrote:
> From: Eduardo Valentin <eduval@amazon.com>
>
> As the thermal zone caches the current and last temperature
> value, the sysfs interface can use that instead of
> forcing an actual update or read from the device.
If the read fails, userspace can handle that by using the previous
value. Do we really want to hide driver dysfunctions?
> This way, if multiple userspace requests are coming
> in, we avoid storming the device with multiple reads
> and potentially clogging the timing requirement
> for the governors.
Can you elaborate 'the timing requirement for the governors' ? I'm
missing the point
> Cc: "Rafael J. Wysocki" <rafael@kernel.org> (supporter:THERMAL)
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org> (supporter:THERMAL)
> Cc: Amit Kucheria <amitk@kernel.org> (reviewer:THERMAL)
> Cc: Zhang Rui <rui.zhang@intel.com> (reviewer:THERMAL)
> Cc: linux-pm@vger.kernel.org (open list:THERMAL)
> Cc: linux-kernel@vger.kernel.org (open list)
>
> Signed-off-by: Eduardo Valentin <eduval@amazon.com>
> ---
> drivers/thermal/thermal_sysfs.c | 21 ++++++++++++++++-----
> 1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
> index b6daea2398da..a240c58d9e08 100644
> --- a/drivers/thermal/thermal_sysfs.c
> +++ b/drivers/thermal/thermal_sysfs.c
> @@ -35,12 +35,23 @@ static ssize_t
> temp_show(struct device *dev, struct device_attribute *attr, char *buf)
> {
> struct thermal_zone_device *tz = to_thermal_zone(dev);
> - int temperature, ret;
> -
> - ret = thermal_zone_get_temp(tz, &temperature);
> + int temperature;
>
> - if (ret)
> - return ret;
> + /*
> + * don't force new update from external reads
> + * This way we avoid messing up with time constraints.
> + */
> + if (tz->mode == THERMAL_DEVICE_DISABLED) {
> + int r;
> +
> + r = thermal_zone_get_temp(tz, &temperature); /* holds tz->lock*/
> + if (r)
> + return r;
> + } else {
> + mutex_lock(&tz->lock);
> + temperature = tz->temperature;
> + mutex_unlock(&tz->lock);
> + }
No please, we are pushing since several weeks a lot of changes to
encapsulate the thermal zone device structure and prevent external core
components to use the internals directly. Even if we can consider the
thermal_sysfs as part of the core code, that changes is not sysfs related.
> return sprintf(buf, "%d\n", temperature);
> }
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
next prev parent reply other threads:[~2023-06-07 9:24 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 0:37 [PATCH 1/1] thermal: sysfs: avoid actual readings from sysfs Eduardo Valentin
2023-06-07 6:32 ` Zhang, Rui
2023-06-07 16:28 ` Eduardo Valentin
2023-06-07 9:24 ` Daniel Lezcano [this message]
2023-06-07 16:38 ` Eduardo Valentin
2023-06-07 18:23 ` Daniel Lezcano
2023-06-08 17:44 ` Eduardo Valentin
2023-06-12 8:17 ` Daniel Lezcano
2023-06-21 5:06 ` Eduardo Valentin
2023-06-21 11:43 ` Daniel Lezcano
2023-06-22 4:56 ` Eduardo Valentin
2023-06-23 17:31 ` Rafael J. Wysocki
2023-06-28 21:10 ` Eduardo Valentin
2023-06-30 8:16 ` Rafael J. Wysocki
2023-06-30 10:11 ` Daniel Lezcano
2023-06-30 10:46 ` Rafael J. Wysocki
2023-06-30 12:09 ` Daniel Lezcano
2023-07-01 1:49 ` Eduardo Valentin
2023-07-01 7:28 ` Daniel Lezcano
2023-07-05 22:49 ` Eduardo Valentin
2023-07-06 13:22 ` Rafael J. Wysocki
2023-07-07 17:14 ` Eduardo Valentin
2023-07-01 1:38 ` Eduardo Valentin
2023-07-01 14:20 ` Daniel Lezcano
2023-07-01 1:37 ` Eduardo Valentin
2023-07-06 13:02 ` Rafael J. Wysocki
2023-06-10 17:24 ` Russell Haley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f26ac9a9-60af-a0fe-fccc-25bcd306f5a1@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=amitk@kernel.org \
--cc=eduval@amazon.com \
--cc=evalenti@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).