From: "Pandruvada, Srinivas" <srinivas.pandruvada@intel.com>
To: "rafael@kernel.org" <rafael@kernel.org>
Cc: "lukasz.luba@arm.com" <lukasz.luba@arm.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"quic_manafm@quicinc.com" <quic_manafm@quicinc.com>,
"daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>
Subject: Re: [PATCH v2 0/7] Add thermal thresholds support
Date: Thu, 22 Aug 2024 12:52:03 +0000 [thread overview]
Message-ID: <4e06ed4bfb3f6f03eaefb73763bf3021829502ce.camel@intel.com> (raw)
In-Reply-To: <dec10692d8bf72b425509d2ea002eebbd7238ccd.camel@intel.com>
On Thu, 2024-08-22 at 12:11 +0000, Pandruvada, Srinivas wrote:
> On Thu, 2024-08-22 at 11:41 +0200, Rafael J. Wysocki wrote:
> > On Thu, Aug 22, 2024 at 12:16 AM Pandruvada, Srinivas
> > <srinivas.pandruvada@intel.com> wrote:
> > >
> > > On Wed, 2024-08-21 at 22:20 +0200, Rafael J. Wysocki wrote:
> > > > Hi Srinivas,
> > > >
> > > > On Wed, Aug 21, 2024 at 10:04 PM Pandruvada, Srinivas
> > > > <srinivas.pandruvada@intel.com> wrote:
> > > > >
> > > > > Hi Daniel,
> > > > >
> > > > > On Fri, 2024-08-16 at 10:12 +0200, Daniel Lezcano wrote:
> > > > > > The trip points are a firmware description of the
> > > > > > temperature
> > > > > > limits
> > > > > > of a specific thermal zone where we associate an action
> > > > > > whichcan't
> > > > > > is
> > > > > > done
> > > > > > by the kernel. The time resolution is low.
> > > > > >
> > > > > > The userspace has to deal with a more complex thermal
> > > > > > management
> > > > > > based
> > > > > > on heuristics from different information coming from
> > > > > > different
> > > > > > places. The logic is much more complex but based on a
> > > > > > bigger
> > > > > > time
> > > > > > resolution, usually one second based.
> > > > > >
> > > > > > The purpose of the userspace is to monitor the temperatures
> > > > > > from
> > > > > > different places and take actions. However, it can not be
> > > > > > constantly
> > > > > > reading the temperature to detect when a temperature
> > > > > > threshold
> > > > > > has
> > > > > > been reached. This is especially bad for mobile or embedded
> > > > > > system as
> > > > > > that will lead to an unacceptable number of wakeup to check
> > > > > > the
> > > > > > temperature with nothing to do.
> > > > > >
> > > > > > On the other side, the sensors are now most of the time
> > > > > > interrupt
> > > > > > driven. That means the thermal framework will use the
> > > > > > temperature
> > > > > > trip
> > > > > > points to program the sensor to trigger an interrupt when a
> > > > > > temperature limit is crossed.
> > > > > >
> > > > > > Unfortunately, the userspace can not benefit this feature
> > > > > > and
> > > > > > current
> > > > > > solutions found here and there, iow out-of-tree, are to add
> > > > > > fake
> > > > > > trip
> > > > > > points in the firmware and enable the writable trip points.
> > > > > >
> > > > > > This is bad for different reasons, the trip points are for
> > > > > > in-
> > > > > > kernel
> > > > > > actions, the semantic of their types is used by the thermal
> > > > > > framework
> > > > > > and by adding trip points in the device tree is a way to
> > > > > > overcome
> > > > > > the
> > > > > > current limitation but tampering with how the thermal
> > > > > > framework
> > > > > > is
> > > > > > supposed to work. The writable trip points is a way to
> > > > > > adjust
> > > > > > a
> > > > > > temperature limit given a specific platform if the firmware
> > > > > > is
> > > > > > not
> > > > > > accurate enough and TBH it is more a debug feature from my
> > > > > > POV.
> > > > > >
> > > > > > The thresholds mechanism is a way to have the userspace to
> > > > > > tell
> > > > > > thermal framework to send a notification when a temperature
> > > > > > limit
> > > > > > is
> > > > > > crossed. There is no id, no hysteresis, just the
> > > > > > temperature
> > > > > > and
> > > > > > the
> > > > > > direction of the limit crossing. That means we can be
> > > > > > notified
> > > > > > when a
> > > > > > threshold is crossed the way up only, or the way down only
> > > > > > or
> > > > > > both
> > > > > > ways. That allows to create hysteresis values if it is
> > > > > > needed.
> > > > > >
> > > > > > A threshold can be added, deleted or flushed. The latter
> > > > > > means
> > > > > > all
> > > > > > thresholds belonging to a thermal zone will be deleted.
> > > > > >
> > > > >
> > > > > So you are proposing to add threshold via netlink, not adding
> > > > > any
> > > > > new
> > > > > sysfs attribute? That is not clear here.
> > > > >
> > > > > I think you are adding"
> > > > > THERMAL_GENL_CMD_THRESHOLD_GET
> > > > > THERMAL_GENL_CMD_THRESHOLD_ADD
> > > > > THERMAL_GENL_CMD_THRESHOLD_DELETE
> > > > > THERMAL_GENL_CMD_THRESHOLD_FLUSH
> > > > >
> > > > > We need to document our netlink messages including old ones.
> > > > >
> > > > > Also we should add "MODIFY" as we tend to change them quite
> > > > > often.
> > > > >
> > > > > Also no hysteresis, that is practically we can't use.
> > > >
> > > > The direction thing is equivalent to hysteresis though.
> > > >
> > > > Instead of using one threshold with a given hysteresis value,
> > > > use
> > > > two
> > > > of them with different temperature values and different
> > > > directions.
> > > >
> > > > > Temperature changes so much that that will flood user space.
> > > > > You
> > > > > will get 100s of
> > > > > events on CPU temperature if you set temperature threshold in
> > > > > CPU.
> > > >
> > > > Events only trigger when thresholds are crossed in a specific
> > > > direction, but overall you have a point.
> > >
> > > This is good enough for some sensor which changes slowly like
> > > skin.
> >
> > Right, and I think that this is the driving use case.
> >
> > > But some sensors like CPU and board are not like that.
> >
> > Sure, so this interface will not be for them.
> But when we design an interface, I think this shouldn't be sensor
> dependent.
>
> >
> > > We publish both raw and filtered event count in debugfs for x86
> > > package temp.
> > > For example, I just ran a sample on a client for one threshold.
> > >
> > > Total notification from hardware: 224
> > > Notified to user space: 16
> >
> > So did you apply the Daniel's patches and run the test or did you
> > do
> > something else?
> We already use netlink to send notification to user space via
> writable
> trip. So didn't apply any patches. I don't see these patches will do
> any different.
I mean without rate limit here all 224 notifications will be passed to
user space (not 16). Temperature goes up and down over threshold for
100s of times before settling.
I can give a try with this series to confirm.
Thanks,
Srinivas
>
>
> >
> > > >
> > > > > We have a whole filtering in driver to avoid this.
> > > > > You need a rate limit here.
> > > > >
> > > > > There are multiple user processes can add threshold and there
> > > > > is no
> > > > > ownership. So one process can cause too much noise to others
> > > > > as
> > > > > it
> > > > > is
> > > > > multicast.
> > > > >
> > > > > We worked on a change to filer these as discussed during last
> > > > > LPC,
> > > > > but
> > > > > not posted yet. This will really need this as this will be
> > > > > too
> > > > > many
> > > > > messages.
> > > >
> > > > Unless there is a way to limit your subscription to events
> > > > regarding
> > > > a
> > > > specific thermal zone, for instance.
> > > That's what this change does.
> > >
> > > >
> > > > Anyway, I have to admit ignorance regarding the user space
> > > > usage
> > > > model
> > > > related to this. For example, is it expected that there will
> > > > be
> > > > one
> > > > user space entity managing the thresholds or there can be many.
> > >
> > > Good question. That's why we didn't send this change. If there is
> > > one
> > > agent this is fine.
> >
> > I think that the addition and deletion of a user threshold should
> > be
> > privileged operations.
> >
> > If that is the case, it all boils down to proper coordination in
> > user
> > space.
> >
> Some kernel API use some cookie as parameter. Here also something
> like
> that can be used to match.
>
> > > But in embedded space, there may be more than one. Hence they
> > > needed
> > > netlink multicast instead of just one char device.
> >
> > I see.
>
> Thanks,
> Srinivas
>
next prev parent reply other threads:[~2024-08-22 12:52 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-16 8:12 [PATCH v2 0/7] Add thermal thresholds support Daniel Lezcano
2024-08-16 8:12 ` [PATCH v2 1/7] thermal/core: Compute low and high boundaries in thermal_zone_device_update() Daniel Lezcano
2024-08-16 11:34 ` Rafael J. Wysocki
2024-08-16 12:06 ` Daniel Lezcano
2024-08-19 14:07 ` Rafael J. Wysocki
2024-08-16 8:12 ` [PATCH v2 2/7] thermal/core: Add thresholds support Daniel Lezcano
2024-08-21 20:05 ` Rafael J. Wysocki
2024-08-22 11:30 ` Rafael J. Wysocki
2024-09-04 8:43 ` Daniel Lezcano
2024-08-22 17:20 ` Daniel Lezcano
2024-08-22 20:09 ` Rafael J. Wysocki
2024-08-16 8:12 ` [PATCH v2 3/7] thermal/core: Connect the threshold with the core Daniel Lezcano
2024-08-16 8:12 ` [PATCH v2 4/7] thermal/netlink: Add the commands and the events for the thresholds Daniel Lezcano
2024-08-16 8:12 ` [PATCH v2 5/7] tools/lib/thermal: Make more generic the command encoding function Daniel Lezcano
2024-08-16 8:12 ` [PATCH v2 6/7] tools/lib/thermal: Add the threshold netlink ABI Daniel Lezcano
2024-08-16 8:12 ` [PATCH v2 7/7] tools/thermal/thermal-engine: Take into account the thresholds API Daniel Lezcano
2024-08-21 19:06 ` [PATCH v2 0/7] Add thermal thresholds support Rafael J. Wysocki
2024-08-21 20:04 ` Pandruvada, Srinivas
2024-08-21 20:20 ` Rafael J. Wysocki
2024-08-21 22:16 ` Pandruvada, Srinivas
2024-08-22 9:41 ` Rafael J. Wysocki
2024-08-22 12:11 ` Pandruvada, Srinivas
2024-08-22 12:52 ` Pandruvada, Srinivas [this message]
2024-08-22 13:01 ` Rafael J. Wysocki
2024-08-22 17:08 ` Daniel Lezcano
2024-08-22 18:12 ` Pandruvada, Srinivas
2024-08-22 16:51 ` Daniel Lezcano
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=4e06ed4bfb3f6f03eaefb73763bf3021829502ce.camel@intel.com \
--to=srinivas.pandruvada@intel.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=quic_manafm@quicinc.com \
--cc=rafael@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.