public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Lists linaro-kernel <linaro-kernel@lists.linaro.org>
Subject: Re: [Query]: tick-sched: can idle_active be false in tick_nohz_idle_exit()?
Date: Thu, 10 Apr 2014 16:56:23 +0200	[thread overview]
Message-ID: <20140410145621.GC27654@localhost.localdomain> (raw)
In-Reply-To: <CAKohpon3vJzL51V9aOBcXKJC4nr3K-0q77HsxFi+=ACUqNqhcA@mail.gmail.com>

On Wed, Apr 09, 2014 at 05:28:57PM +0530, Viresh Kumar wrote:
> Hi Guys,
> 
> File: kernel/time/tick-sched.c
> function: tick_nohz_idle_exit()
> 
> We are checking here if idle_active is true or not and then
> do some stuff. But is it possible that idle_active be false
> here?
> 
> The sequence as far as I understood is:
> idle-loop:
> 
> tick_nohz_idle_enter(), i.e. idle_active = true;
> local_irq_disable()
> 
> IDLE
> .
> .
> 
> wake up due to IPI ??
> 
> local_irq_enable()
>     tick_nohz_irq_enter(), i.e. idle_active = false;
>     tick_nohz_irq_exit(), i.e. idle_active = true;
> 
> tick_nohz_idle_exit()
> 
> How can idle_active be false here?

When a dynticks idle CPU is woken up (typically with an IPI), tick_nohz_stop_idle()
is called on interrupt entry but, because this is a waking up IPI, tick_nohz_start_idle()
won't be called. The reason is that need_resched() prevents tick_nohz_irq_exit() to be
called in irq_exit().

After all if we know that the CPU is going to exit the idle task, we don't need to account
any more idle time. We also don't need to retry to enter in dynticks idle mode since we
are going to restart the tick with tick_nohz_idle_exit().

So in case of wake up IPIs, we may end up with !ts->idle_active in tick_nohz_idle_exit() :)

I must confess this is not obvious. It confused me as well when I met that part. A small
comment in tick_nohz_idle_exit() would be welcome ;)

Thanks.

> 
> --
> viresh

  reply	other threads:[~2014-04-10 14:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-09 11:58 [Query]: tick-sched: can idle_active be false in tick_nohz_idle_exit()? Viresh Kumar
2014-04-10 14:56 ` Frederic Weisbecker [this message]
2014-04-11  9:54   ` Viresh Kumar
2014-04-11 14:35     ` 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=20140410145621.GC27654@localhost.localdomain \
    --to=fweisbec@gmail.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --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