public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <sboyd@codeaurora.org>,
	LKML <linux-kernel@vger.kernel.org>,
	patches@linaro.org,
	"linaro-kernel@lists.linaro.org" <linaro-kernel@lists.linaro.org>
Subject: Re: [PATCH V2] tick: Make sleep length calculation more accurate
Date: Wed, 02 Oct 2013 18:22:29 +0200	[thread overview]
Message-ID: <524C4845.5060800@linaro.org> (raw)
In-Reply-To: <CAFTL4hw-yawRUO-8ePsonvh1o2P7T5yb+GFPVop5OHzH6HTobw@mail.gmail.com>

On 10/02/2013 05:57 PM, Frederic Weisbecker wrote:
> 2013/10/2 Daniel Lezcano <daniel.lezcano@linaro.org>:
>> The sleep_length is computed in the tick_nohz_stop_sched_tick function but it
>> is used later in the code with in between the local irq enabled.
>>
>> cpu_idle_loop
>>    tick_nohz_idle_enter         [ exits with local irq enabled ]
>>     __tick_nohz_idle_enter
>>       tick_nohz_stop_sched_tick
>>    ...
>>
>>    arch_cpu_idle
>>       menu_select               [ uses here 'sleep_length' ]
>>    ...
>>
>> Between the computation of the sleep length and its usage, some interrupts
>> may occur, making the sleep length shorter than actually it is because of the
>> interrupt processing
>
> So, do you mean that the ts->sleep_length would return a value that is too long
> given that the CPU already spent some time to service the irqs since we computed
> the sleep length in tick_nohz_idle_enter()?
>
> But then tick_nohz_irq_exit() should take care of that as it calls
> again tick_nohz_stop_sched_tick().
> So I'm a bit confused.
>
>> or different if the timer itself expired.
>
> Same here, if the timer expired, it triggers an interrupt which can do
> two things:
>
> 1) reprogram a new timer and this recompute sleep_length
> 2) set_need_resched() and then exit the idle loop, so arch_cpu_idle() won't even
> be called. Or the timer interrupts hlt, but then menu_select() was
> called before.
>
> So I probably missed something here.

No you did not :)

Indeed... At the first glance, this issue sounded so obvious I suspected 
there must be a trick somewhere but I did not think to look at the 
irq_exit, the code is very complex. Thanks for clarifying this.

For my personal information, is there any particular reason to set an 
intermediate 'sleep_length' in tick_nohz_stop_sched_tick instead of 
doing what does this patch ?

Thanks
   -- Daniel

-- 
  <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


  reply	other threads:[~2013-10-02 16:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02 10:26 [PATCH V2] tick: Make sleep length calculation more accurate Daniel Lezcano
2013-10-02 13:28 ` Daniel Lezcano
2013-10-02 15:57 ` Frederic Weisbecker
2013-10-02 16:22   ` Daniel Lezcano [this message]
2013-10-02 16:42     ` Frederic Weisbecker
2013-10-02 18:03       ` Daniel Lezcano
2013-10-05  9:53         ` Frederic Weisbecker

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=524C4845.5060800@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=fweisbec@gmail.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=sboyd@codeaurora.org \
    --cc=tglx@linutronix.de \
    /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