linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Valentin <edubezval@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Zhang Rui <rui.zhang@intel.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH V3] thermal: Add cooling device's statistics in sysfs
Date: Mon, 15 Jan 2018 08:32:23 -0800	[thread overview]
Message-ID: <20180115163221.GA3756@localhost.localdomain> (raw)
In-Reply-To: <20180115044616.GC22978@vireshk-i7>

On Mon, Jan 15, 2018 at 10:16:16AM +0530, Viresh Kumar wrote:
> On 12-01-18, 09:46, Eduardo Valentin wrote:
> > On Thu, Jan 11, 2018 at 03:06:09PM +0530, Viresh Kumar wrote:
> > > $ ls -R /sys/class/thermal/cooling_device0/
> > > /sys/class/thermal/cooling_device0/:
> > > cur_state  max_state  power  stats  subsystem  type  uevent
> > > 
> > > /sys/class/thermal/cooling_device0/power:
> > > autosuspend_delay_ms  runtime_active_time  runtime_suspended_time
> > > control               runtime_status
> > > 
> > > /sys/class/thermal/cooling_device0/stats:
> > > reset  time_in_state_ms  total_trans
> > > 
> > 
> > I guess the only missing node from the cpufreq design copy was the
> > transition table.
> 
> I don't think it would be very useful here and so didn't add it.
> 

It is actually quite useful, on both, thermal zones and cooling devices,
to detect misbehaving policies. Typically the transitions recorded
by a well behaving policy is very well defined, typically very smooth
from one state to the nearby states. When you see jumps, which is very
clear on a transition table, that is hint for misbehaving scenarios.

Or, when jumps are expected, they are typically rare situation in which
the system engineer wants to be aware/ account for frequency of
occurrence.

> > Also, I think the stats per thermal zone is also useful, sometimes
> > more than per cooling device, as I have been using in
> > the past, but that is just a comment, not really to block your patch.
> 
> Sure, that can be added in a separate patch. What kind of stats are you
> expecting there ?

Same set you added for cooling devices should also be reflected on
thermal zones, but instead of cooling state, you want to do the account
on trips, at least for the context of this patch set.

> 
> > > diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c
> > > index 8cdf75adcce1..eb03d7e099bb 100644
> > > --- a/drivers/thermal/thermal_helpers.c
> > > +++ b/drivers/thermal/thermal_helpers.c
> > > @@ -187,7 +187,10 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)
> > >  		if (instance->target > target)
> > >  			target = instance->target;
> > >  	}
> > > -	cdev->ops->set_cur_state(cdev, target);
> > > +
> > > +	if (!cdev->ops->set_cur_state(cdev, target))
> > > +		thermal_cooling_device_stats_update(cdev, target);
> > > +
> > 
> > I might be wrong but, this will maybe double account for cases the same
> > cooling state is selected.
> 
> No because I am exiting early for same sates in that routine.

Did I miss that hunk?

> 
> > >  void thermal_cooling_device_setup_sysfs(struct thermal_cooling_device *cdev)
> > >  {
> > > +	struct cooling_dev_stats *stats;
> > > +	unsigned long states;
> > > +	int ret, size;
> > > +
> > > +	ret = cdev->ops->get_max_state(cdev, &states);
> > > +	if (ret)
> > > +		return;
> > > +
> > > +	states++; /* Total number of states is highest state + 1 */
> > > +	size = sizeof(*stats);
> > > +	size += sizeof(*stats->time_in_state) * states;
> > > +
> > > +	stats = kzalloc(size, GFP_KERNEL);
> > > +	if (!stats)
> > > +		return;
> > > +
> > > +	stats->time_in_state = (ktime_t *)(stats + 1);
> > > +	cdev->stats = stats;
> > > +	stats->last_time = ktime_get();
> > > +	stats->max_states = states;
> > > +	cdev->stats = stats;
> > > +
> > > +	spin_lock_init(&stats->lock);
> > 
> > I would say, the cooling device stat initialization deserves its own
> > initialization function, don't you think?
> 
> Hmm, I am not sure if we need it right away. This function is only for cooling
> device's sysfs setup and initializing the "stats" structure kind of falls in the
> setup category. Of course if we want this function to handle sysfs setup for
> thermal zones as well, then yes we better split it up.
> 
> The other thing was with thermal_cooling_device_remove_sysfs() as that would
> also need to call a separate routine to do the cleanup and that would be the
> only thing it will end up doing. So it would more be like a dummy caller.
> 
> > Also, I see nothing about sysfs on the lines added to
> > thermal_cooling_device_setup_sysfs().
> 
> Well, it is allocating structure to keep the values showed while reading sysfs
> files, so it is kind of sysfs related to me :)

Ideally these stats should be behind a config entry, which can be used
also to remove the code out of the kernel that does not want it in.
So, yes, I still think they deserve their own setup/destroy pair, and
a config entry to put the code behind it.

> 
> -- 
> viresh

  reply	other threads:[~2018-01-15 16:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11  9:36 [PATCH V3] thermal: Add cooling device's statistics in sysfs Viresh Kumar
2018-01-12 11:09 ` Aishwarya Pant
2018-01-12 17:25   ` Eduardo Valentin
2018-01-12 17:46 ` Eduardo Valentin
2018-01-15  4:46   ` Viresh Kumar
2018-01-15 16:32     ` Eduardo Valentin [this message]
2018-01-16  8:44       ` Viresh Kumar
2018-01-16 10:00       ` Viresh Kumar

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=20180115163221.GA3756@localhost.localdomain \
    --to=edubezval@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.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 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).