All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mason <slash.tmp@free.fr>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	cpufreq <cpufreq@vger.kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
Subject: Re: schedule_timeout sleeps too long after dividing CPU frequency
Date: Tue, 12 May 2015 18:03:40 +0200	[thread overview]
Message-ID: <5552245C.2080701@free.fr> (raw)
In-Reply-To: <20150512152332.GO2067@n2100.arm.linux.org.uk>

On 12/05/2015 17:23, Russell King - ARM Linux wrote:

> On Tue, May 12, 2015 at 04:32:47PM +0200, Mason wrote:
> 
>> I'm working on a Cortex A9 based platform.
>>
>> I have a basic clock tree, and a very basic cpufreq driver using
>> mostly generic driver glue:
>>
>> static struct cpufreq_driver tangox_cpufreq_driver = {
>> 	.name		= "tangox-cpufreq",
>> 	.init		= tangox_cpu_init,
>> 	.verify		= cpufreq_generic_frequency_table_verify,
>> 	.target_index	= tangox_target,
>> 	.get		= cpufreq_generic_get,
>> 	.exit		= cpufreq_generic_exit,
>> 	.attr		= cpufreq_generic_attr,
>> };
>>
>> My target_index function is trivial:
>>
>> static int tangox_target(struct cpufreq_policy *policy, unsigned int idx)
>> {
>> 	return clk_set_rate(policy->clk, freq_table[idx].frequency * 1000);
>> }
>>
>> I was testing an unrelated driver at low frequencies, with the nominal
>> frequency (999 MHz) divided by 54 (i.e. freq = 18.5 MHz) and I noticed
>> that when the driver calls
>>
>>     schedule_timeout(HZ);
>>
>> the thread sleeps 54 seconds instead of 1.
> 
> I'm guessing that this will be because your local timer changes frequency
> with the CPU, which means that the clockevent which was set for one second
> ends up timing out after 54 seconds.

That's the first thing I suspected, but smp_twd.c registers a clk_notifier
to be notified of CPU frequency changes:

static struct notifier_block twd_clk_nb = {
	.notifier_call = twd_rate_change,
};

static int twd_clk_init(void)
{
	if (twd_evt && __this_cpu_ptr(twd_evt) && !IS_ERR(twd_clk))
		return clk_notifier_register(twd_clk, &twd_clk_nb);

	return 0;
}

And I instrumented twd_update_frequency() to check it was being called.

Regards.


WARNING: multiple messages have this Message-ID (diff)
From: slash.tmp@free.fr (Mason)
To: linux-arm-kernel@lists.infradead.org
Subject: schedule_timeout sleeps too long after dividing CPU frequency
Date: Tue, 12 May 2015 18:03:40 +0200	[thread overview]
Message-ID: <5552245C.2080701@free.fr> (raw)
In-Reply-To: <20150512152332.GO2067@n2100.arm.linux.org.uk>

On 12/05/2015 17:23, Russell King - ARM Linux wrote:

> On Tue, May 12, 2015 at 04:32:47PM +0200, Mason wrote:
> 
>> I'm working on a Cortex A9 based platform.
>>
>> I have a basic clock tree, and a very basic cpufreq driver using
>> mostly generic driver glue:
>>
>> static struct cpufreq_driver tangox_cpufreq_driver = {
>> 	.name		= "tangox-cpufreq",
>> 	.init		= tangox_cpu_init,
>> 	.verify		= cpufreq_generic_frequency_table_verify,
>> 	.target_index	= tangox_target,
>> 	.get		= cpufreq_generic_get,
>> 	.exit		= cpufreq_generic_exit,
>> 	.attr		= cpufreq_generic_attr,
>> };
>>
>> My target_index function is trivial:
>>
>> static int tangox_target(struct cpufreq_policy *policy, unsigned int idx)
>> {
>> 	return clk_set_rate(policy->clk, freq_table[idx].frequency * 1000);
>> }
>>
>> I was testing an unrelated driver at low frequencies, with the nominal
>> frequency (999 MHz) divided by 54 (i.e. freq = 18.5 MHz) and I noticed
>> that when the driver calls
>>
>>     schedule_timeout(HZ);
>>
>> the thread sleeps 54 seconds instead of 1.
> 
> I'm guessing that this will be because your local timer changes frequency
> with the CPU, which means that the clockevent which was set for one second
> ends up timing out after 54 seconds.

That's the first thing I suspected, but smp_twd.c registers a clk_notifier
to be notified of CPU frequency changes:

static struct notifier_block twd_clk_nb = {
	.notifier_call = twd_rate_change,
};

static int twd_clk_init(void)
{
	if (twd_evt && __this_cpu_ptr(twd_evt) && !IS_ERR(twd_clk))
		return clk_notifier_register(twd_clk, &twd_clk_nb);

	return 0;
}

And I instrumented twd_update_frequency() to check it was being called.

Regards.

  reply	other threads:[~2015-05-12 16:03 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 14:32 schedule_timeout sleeps too long after dividing CPU frequency Mason
2015-05-12 14:32 ` Mason
2015-05-12 14:46 ` Viresh Kumar
2015-05-12 14:46   ` Viresh Kumar
2015-05-12 15:14   ` Mason
2015-05-12 15:14     ` Mason
2015-05-12 15:50     ` Russell King - ARM Linux
2015-05-12 15:50       ` Russell King - ARM Linux
2015-05-12 16:14       ` Mason
2015-05-12 16:14         ` Mason
2015-05-13 16:51       ` Mason
2015-05-13 16:51         ` Mason
2015-05-14  2:13         ` Viresh Kumar
2015-05-14  2:13           ` Viresh Kumar
2015-05-14 11:22           ` Mason
2015-05-14 11:22             ` Mason
2015-05-14 11:54             ` Viresh Kumar
2015-05-14 11:54               ` Viresh Kumar
2015-05-14 13:06               ` Mason
2015-05-14 13:06                 ` Mason
2015-05-14 13:53                 ` Russell King - ARM Linux
2015-05-14 13:53                   ` Russell King - ARM Linux
2015-05-14 14:51                   ` Mason
2015-05-14 14:51                     ` Mason
2015-05-14 13:59                 ` Viresh Kumar
2015-05-14 13:59                   ` Viresh Kumar
2015-05-14 13:59                   ` Viresh Kumar
2015-05-14 14:38                   ` Viresh Kumar
2015-05-14 14:38                     ` Viresh Kumar
2015-05-14 14:42                   ` Russell King - ARM Linux
2015-05-14 14:42                     ` Russell King - ARM Linux
2015-05-15  9:29                     ` Mason
2015-05-15  9:29                       ` Mason
2015-05-15  9:51                       ` Russell King - ARM Linux
2015-05-15  9:51                         ` Russell King - ARM Linux
2015-05-15 10:01                         ` Viresh Kumar
2015-05-15 10:01                           ` Viresh Kumar
2015-05-15 10:36                         ` Mason
2015-05-15 10:36                           ` Mason
2015-05-15 11:58                           ` Russell King - ARM Linux
2015-05-15 11:58                             ` Russell King - ARM Linux
2015-05-15 12:45                             ` Mason
2015-05-15 12:45                               ` Mason
2015-05-15 13:15                               ` Russell King - ARM Linux
2015-05-15 13:15                                 ` Russell King - ARM Linux
2015-05-15 13:58                                 ` Mason
2015-05-15 18:35                                   ` Mason
2015-05-18 11:24                                     ` Mason
2015-05-18 11:54                                       ` Russell King - ARM Linux
2015-05-20 16:21                                         ` Mason
2015-05-20 18:50                                           ` Arnd Bergmann
2015-05-20 19:34                                             ` Mason
2015-05-20 20:14                                               ` Russell King - ARM Linux
2015-05-20 20:41                                                 ` Mason
2015-05-20 20:52                                                   ` Arnd Bergmann
2015-05-20 21:56                                                     ` Mason
2015-05-20 22:18                                                       ` Arnd Bergmann
2015-05-21 12:35                                                         ` Mason
2015-05-20 23:14                                                       ` Russell King - ARM Linux
2015-05-21  9:56                                                         ` Mason
2015-05-21 10:20                                                           ` Russell King - ARM Linux
2015-05-14 14:48                   ` Mason
2015-05-14 14:48                     ` Mason
2015-05-15  4:16                     ` Viresh Kumar
2015-05-15  4:16                       ` Viresh Kumar
2015-05-15  5:07                       ` Viresh Kumar
2015-05-15  5:07                         ` Viresh Kumar
2015-05-15  9:00                       ` Russell King - ARM Linux
2015-05-15  9:00                         ` Russell King - ARM Linux
2015-05-15  9:21                       ` Mason
2015-05-15  9:21                         ` Mason
2015-05-15 10:11                       ` Mason
2015-05-15 10:11                         ` Mason
2015-05-12 15:23 ` Russell King - ARM Linux
2015-05-12 15:23   ` Russell King - ARM Linux
2015-05-12 16:03   ` Mason [this message]
2015-05-12 16:03     ` Mason

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=5552245C.2080701@free.fr \
    --to=slash.tmp@free.fr \
    --cc=cpufreq@vger.kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=rjw@rjwysocki.net \
    --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 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.