From: Peter Zijlstra <peterz@infradead.org>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: mingo@kernel.org, tglx@linutronix.de, rjw@rjwysocki.net,
nicolas.pitre@linaro.org, preeti@linux.vnet.ibm.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2 4/5] idle: Move idle conditions in cpuidle_idle main function
Date: Mon, 24 Feb 2014 20:25:01 +0100 [thread overview]
Message-ID: <20140224192501.GO6835@laptop.programming.kicks-ass.net> (raw)
In-Reply-To: <530B97B9.8020502@linaro.org>
On Mon, Feb 24, 2014 at 08:04:25PM +0100, Daniel Lezcano wrote:
> >+ /*
> >+ * Since we fell out of the loop above, we know
> >+ * TIF_NEED_RESCHED must be set, propagate it into
> >+ * PREEMPT_NEED_RESCHED.
> >+ *
> >+ * This is required because for polling idle loops we will
> >+ * not have had an IPI to fold the state for us.
> >+ */
> >+ preempt_set_need_resched();
> > tick_nohz_idle_exit();
> > schedule_preempt_disabled();
>
> So IIUC, the mainloop has two states: one where it is blocked on a HLT/WFI
> instruction (or about to enter/ exit this state) and another one outside of
> this blocking section.
Almost; on x86 we have an monitor/mwait construct that blocks waiting
for a cacheline write. We point it at the thread_info->flags line. So
the TIF_NEED_RESCHED write from the other CPU wakes us up.
So no need to send an IPI after we write that flag.
> When the idle task is blocked on HLT/WFI, it needs the IPI-reschedule in
> order to be woken up and rescheduled. But if it is outside this section, the
> idle task is not waiting for an interrupt and an expensive IPI can be saved
> by just setting the TS_POLLING flag, the scheduler will check this flag and
> won't send the IPI.
>
> But 'set_preempt_need_resched' is called from the IPI handler. So if no IPI
> is sent because the idle task is in polling state, we have to set it
> ourself.
>
> Now, the difference between the old code with 'tif_need_resched()' is
> because we don't need to check it because it is always true.
>
> Am I right ?
Yah, also it closes a very narrow window where TIF_NEED_RESCHED wasn't
set at the end of the while (!need_resched()) but is at the top.
next prev parent reply other threads:[~2014-02-24 19:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-24 13:55 [PATCH V2 1/5] idle/cpuidle: Split cpuidle_idle_call main function into smaller functions Daniel Lezcano
2014-02-24 13:55 ` [PATCH V2 2/5] cpuidle/idle: Move the cpuidle_idle_call function to idle.c Daniel Lezcano
2014-02-24 13:55 ` [PATCH V2 3/5] idle: Reorganize the idle loop Daniel Lezcano
2014-02-24 13:55 ` [PATCH V2 4/5] idle: Move idle conditions in cpuidle_idle main function Daniel Lezcano
2014-02-24 14:59 ` Peter Zijlstra
2014-02-24 15:39 ` Daniel Lezcano
2014-02-24 16:05 ` Peter Zijlstra
2014-02-24 17:03 ` Daniel Lezcano
2014-02-24 17:22 ` Peter Zijlstra
2014-02-24 17:54 ` Nicolas Pitre
2014-02-24 17:58 ` Peter Zijlstra
2014-02-24 19:04 ` Daniel Lezcano
2014-02-24 19:25 ` Peter Zijlstra [this message]
2014-02-27 13:32 ` [tip:sched/core] sched/idle: Remove stale old file tip-bot for Peter Zijlstra
2014-02-24 13:55 ` [PATCH V2 5/5] idle: Add more comments to the code Daniel Lezcano
2014-02-24 15:00 ` [PATCH V2 1/5] idle/cpuidle: Split cpuidle_idle_call main function into smaller functions Peter Zijlstra
2014-02-24 15:12 ` Daniel Lezcano
2014-02-24 15:16 ` Peter Zijlstra
2014-02-25 3:35 ` Preeti U Murthy
2014-02-25 3:47 ` Preeti U Murthy
2014-02-25 6:35 ` Daniel Lezcano
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=20140224192501.GO6835@laptop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=nicolas.pitre@linaro.org \
--cc=preeti@linux.vnet.ibm.com \
--cc=rjw@rjwysocki.net \
--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 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.