mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linaro-kernel@lists.linaro.org, patches@linaro.org,
	cpufreq@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH Resend 1/4] cpufreq: stats: handle cpufreq_unregister_driver() and suspend/resume properly
Date: Wed, 08 Jan 2014 01:14:11 +0100	[thread overview]
Message-ID: <2641423.LeSa8tdYgZ@vostro.rjw.lan> (raw)
In-Reply-To: <b4c2b7c1f5e480e6ae6fcbc737ae52c1e0a88549.1389058746.git.viresh.kumar@linaro.org>

On Tuesday, January 07, 2014 07:10:10 AM Viresh Kumar wrote:
> There are several problems cpufreq stats in the way it handles
> cpufreq_unregister_driver() and suspend/resume..
> 
> - We must not loose data collected so far when suspend/resume happens and so
>   stats directories must not be removed/allocated during these operations, Which
>   is done currently.
> 
> - cpufreq_stat has registered notifiers with both cpufreq and hotplug. It adds
>   sysfs stats directory with a cpufreq notifier: CPUFREQ_NOTIFY and removes this
>   directory with a notifier from hotplug core.
> 
>   In case cpufreq_unregister_driver() is called (on rmmod cpufreq driver), stats
>   directories per cpu aren't removed as CPUs are still online. The only call
>   cpufreq_stats gets is cpufreq_stats_update_policy_cpu for all CPUs except the
>   last of each policy. And pointer to stat information is stored in the entry
>   for last cpu in per-cpu cpufreq_stats_table. But policy structure would be
>   freed inside cpufreq core and so that will result in memory leak inside
>   cpufreq stats (as we are never freeing memory for stats).
> 
>   Now if we again insert the module cpufreq_register_driver() will be called and
>   we will again allocate stats data and put it on for first cpu of every policy.
>   In case we only have a single cpu per policy we will return with a error from
>   cpufreq_stats_create_table() due to below code:
> 
> 	if (per_cpu(cpufreq_stats_table, cpu))
> 		return -EBUSY;
> 
>   And so probably cpufreq stats directory would show up anymore (as it was added
>   inside last policies->kobj which doesn't exist anymore). I haven't tested it
>   though. Also the values in stats files wouldn't be refreshed as we are using
>   the earlier stats structure.
> 
> - CPUFREQ_NOTIFY is called from cpufreq_set_policy() which is called for
>   scenarios where we don't really want cpufreq_stat_notifier_policy() to get
>   called. For example whenever we are changing anything related to a policy:
>   min/max/current freq, etc.. cpufreq_set_policy() is called and so cpufreq
>   stats is notified. Where we don't do any useful stuff other than simply
>   returning with -EBUSY from cpufreq_stats_create_table(). And so this isn't the
>   right notifier that cpufreq stats..
> 
> Due to all above reasons this patch does following changes:
> - Add new notifiers CPUFREQ_CREATE_POLICY and CPUFREQ_REMOVE_POLICY, which are
>   only called when policy is created/destroyed. They aren't called for
>   suspend/resume paths..
> - Use these notifiers in cpufreq_stat_notifier_policy() to create/destory stats
>   sysfs entries. And so cpufreq_unregister_driver() or suspend/resume shouldn't
>   be a problem for cpufreq_stats.
> - Return early from cpufreq_stat_cpu_callback() for suspend/resume sequence, so
>   that we don't free stats structure.
> 
> Acked-and-tested-by: Nicolas Pitre <nico@linaro.org>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

The entire series applied to bleeding-edge, thanks!

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

      parent reply	other threads:[~2014-01-08  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-07  1:40 Viresh Kumar
2014-01-07  1:40 ` [PATCH Resend 2/4] cpufreq: stats: remove hotplug notifiers Viresh Kumar
2014-01-07  1:40 ` [PATCH Resend 3/4] cpufreq: stats: free table and remove sysfs entry in a single routine Viresh Kumar
2014-01-07  1:40 ` [PATCH Resend 4/4] cpufreq: stats: create sysfs entries when cpufreq_stats is a module Viresh Kumar
2014-01-08  0:14 ` Rafael J. Wysocki [this message]

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=2641423.LeSa8tdYgZ@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=cpufreq@vger.kernel.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=patches@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

all inboxes | Powered by JetHome®