[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <75eba2da-593f-f3bd-4eac-5155fcf5aee8@linaro.org>
Date: Wed, 21 Jun 2023 13:43:26 +0200
From: Daniel Lezcano <daniel.lezcano@...aro.org>
To: Eduardo Valentin <evalenti@...nel.org>
Cc: eduval@...zon.com, rafael@...nel.org, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, Amit Kucheria <amitk@...nel.org>,
Zhang Rui <rui.zhang@...el.com>
Subject: Re: [PATCH 1/1] thermal: sysfs: avoid actual readings from sysfs
On 21/06/2023 07:06, Eduardo Valentin wrote:
> On Mon, Jun 12, 2023 at 10:17:51AM +0200, Daniel Lezcano wrote:
>>
>>
>>
>> Hi Eduardo,
>>
>> On 08/06/2023 19:44, Eduardo Valentin wrote:
>>
>> [ ... ]
>>
>>>> Do you have a use case with some measurements to spot an issue or is it
>>>> a potential issue you identified ?
>>>
>>>
>>> yes, a governor that is using I2C device as input, behind I2C fast mode (100KHz)
>>> and needs to update the zone every 100ms. Each read in this bus, if done alone
>>> would be around 500us, takes 10bytes to read the device, it is 10 clocks per byte,
>>> well technically 9, but rounding for the sake of the example, which gets you
>>> 50 / 100KHz = 500 us. That is for a single read. You add one single extra
>>> userspace read triggering an unused device update, that is already a 1ms drift.
>>> Basically you looking at 0.5% for each extra userspace read competing in this
>>> sysfs node. You add extra devices in the same I2C bus, your governor is looking
>>> at more than 1% overhead. And I am talking also about a main CPU of ~800MHz.
>>> I did not even include the lock overhead considered for this CPU ;-)
>>>
>>> Again, this is not about controlling the DIE temperature of the CPU you
>>> are running the thermal subsystem. This is about controlling
>>> a target device.
>>
>> Ok. The target device is on a bus which is slow and prone to contention.
>>
>> This hardware is not designed to be monitored with a high precision, so
>> reading the temperature at a high rate does not really make sense.
>
> On the contrary, it needs even more precision and any extra delay adds to
> loss on accuracy :-)
What I meant is if the hardware designer thought there could be a
problem with the thermal zone they would have put another kind of
sensor, not one with a i2c based communication.
>> Moreover (putting apart a potential contention), the delayed read does
>> not change the time interval, which remains the same from the governor
>> point of view.
>
> It does not change the governor update interval and that is a property of
> the thermal zone. Correct. And that is the intention of the change.
> The actual temperature updates driven by the governor will always
> result in a driver call. While a userspace call will not be in the way
> of the governor update.
>
> Sysfs reads, However, with the current code as is, it may cause
> jittering on the actual execution of the governor throttle function.
> causing the computation of the desired outcome cooling device being skewed.
>
>>
>> In addition, i2c sensors are usually handled in the hwmon subsystem
>> which are registered in the thermal framework from there. Those have
>> most of their 'read' callback with a cached value in a jiffies based way
>> eg. [1].
>
> I guess what you are really saying is: go read the hwmon sysfs node,
> or, hwmon solves this for us, which unfortunately is not true for all devices.
I meant the i2c sensors are under the hwmon subsystem. This subsystem is
connected with the thermal framework, so when a hwmon sensor is created,
it register this sensor as a thermal zone.
>> So the feature already exists for slow devices and are handled in the
>> drivers directly via the hwmon subsystem.
>>
>> From my POV, the feature is not needed in the thermal framework.
>
> The fact that hwmon does it in some way is another evidence of the
> actual problem.
Not really, it shows the i2c sensors are in the hwmon subsystems.
> Telling that this has to be solved by another subsystem
> for a sysfs node that is part of thermal subsystem does not really solve
> the problem. Also as I mentioned, this is not common on all hwmon
> devices, and not all I2C devices are hwmon devices. In fact, I2C
> was just one example of a slow device. There are more I can quote
> that are not necessarily under the hwmon case.
Yes, please. Can you give examples with existing drivers in the thermal
framework and observed issues on specific platforms ? Numbers would help.
> Not sure if you missed, but an alternative for the difference of
> opinion on how this should behave is to have caching for response
> of sysfs read of tz/temp as an option/configuration. Then we let
> userspace to choose which behavior it wants.
Before that, you have to prove the feature is really needed and show how
the patches solves an issue. At this point, this is not demonstrated.
--
<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
Powered by blists - more mailing lists