LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH 1/2] drivers: cpuidle: remove stale irq disabling call in cpuidle_enter_freeze()
Date: Thu, 26 Feb 2015 09:48:16 +0000 [thread overview]
Message-ID: <20150226094816.GA25057@red-moon> (raw)
In-Reply-To: <1789709.hzh3CkisvM@vostro.rjw.lan>
On Wed, Feb 25, 2015 at 11:36:10PM +0000, Rafael J. Wysocki wrote:
> On Wednesday, February 25, 2015 02:39:17 PM Lorenzo Pieralisi wrote:
> > On Wed, Feb 25, 2015 at 02:13:23PM +0000, Daniel Lezcano wrote:
> > > On 02/24/2015 06:58 PM, Lorenzo Pieralisi wrote:
> > > > On return from cpuidle_enter_freeze() irqs are re-enabled by the function
> > > > caller (ie cpuidle_idle_call) in the idle loop. This patch removes a stale
> > > > local_irq_disable() call and its stale comment in cpuidle_enter_freeze(),
> > > > since they disagree and do not serve a useful purpose.
> > > >
> > > > Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
> > > > Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> > > > Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> > > > ---
> > > > drivers/cpuidle/cpuidle.c | 3 ---
> > > > 1 file changed, 3 deletions(-)
> > > >
> > > > diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> > > > index 4d53458..f47edc6c 100644
> > > > --- a/drivers/cpuidle/cpuidle.c
> > > > +++ b/drivers/cpuidle/cpuidle.c
> > > > @@ -144,9 +144,6 @@ void cpuidle_enter_freeze(void)
> > > > cpuidle_enter(drv, dev, index);
> > > > else
> > > > arch_cpu_idle();
> > > > -
> > > > - /* Interrupts are enabled again here. */
> > > > - local_irq_disable();
> > > > }
> > >
> > > Hmm, I think Rafael added this prevent lockdep to raise a warning.
> >
> > Ok, so the comment is there to say "at this point of execution IRQs
> > are enabled", it does not refer to local_irq_disable() call effects,
> > that's misleading and not necessarily nice, at least it should
> > be explained.
> >
> > > Otherwise, cpuidle_enter or arch_cpu_idle enables the irq again and then
> > > when exiting the cpu_idle_call, we enable them again, so leading to a
> > > lockdep WARN in trace_hardirqs_on_caller.
> >
> > Would not it be better to enable irqs in cpuidle_enter_freeze() on
> > returning from enter_freeze_proper() and remove the local_irq_enable()
> > call in the cpuidle_idle_call() before jumping to exit_idle ?
> >
> > > That said, if we have to do this, it may reveal something is wrong in
> > > the code.
> >
> > I just spotted code through inspection, I have to say at the moment it
> > is not very clear what it is meant to achieve, so I put together this
> > patch.
>
> So there are two code paths in cpuidle_idle_call(), the enter_freeze_proper()
> one which does *not* re-enable interrupts and the one you modified which does
> that. The local_irq_disable() is to keep things consistent.
>
> I'm not entirely against of re-arranging things here, but a patch like the
> (untested) one below might be more appropriate.
>
> Rafael (who would appreciate it if people asked questions instead of sending
> patches on a hunch).
I understand that, I wanted to just send [patch 2], this patch was more
a way to get a clarification than anything else, asking would have been more
appropriate, sorry.
Anyway, I did not like disabling IRQs to just re-enable them on function
return, in particular the comment below seemed to apply to the following
line, which is a bit misleading.
/* Interrupts are enabled again here. */
local_irq_disable();
>
>
> ---
> drivers/cpuidle/cpuidle.c | 2 +-
> kernel/sched/idle.c | 1 -
> 2 files changed, 1 insertion(+), 2 deletions(-)
>
> Index: linux-pm/drivers/cpuidle/cpuidle.c
> ===================================================================
> --- linux-pm.orig/drivers/cpuidle/cpuidle.c
> +++ linux-pm/drivers/cpuidle/cpuidle.c
> @@ -132,6 +132,7 @@ void cpuidle_enter_freeze(void)
> index = cpuidle_find_deepest_state(drv, dev, true);
> if (index >= 0) {
> enter_freeze_proper(drv, dev, index);
> + local_irq_enable();
> return;
> }
>
> @@ -146,7 +147,6 @@ void cpuidle_enter_freeze(void)
> arch_cpu_idle();
>
> /* Interrupts are enabled again here. */
> - local_irq_disable();
> }
>
> /**
> Index: linux-pm/kernel/sched/idle.c
> ===================================================================
> --- linux-pm.orig/kernel/sched/idle.c
> +++ linux-pm/kernel/sched/idle.c
> @@ -116,7 +116,6 @@ static void cpuidle_idle_call(void)
> */
> if (idle_should_freeze()) {
> cpuidle_enter_freeze();
> - local_irq_enable();
> goto exit_idle;
> }
>
It looks fine, I will test it. I would add a comment to
cpuidle_enter_freeze() to document it must return with IRQs
enabled.
Thanks,
Lorenzo
next prev parent reply other threads:[~2015-02-26 9:47 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-24 17:58 [PATCH 0/2] drivers: cpuidle: minor suspend-to-idle fixes Lorenzo Pieralisi
2015-02-24 17:58 ` [PATCH 1/2] drivers: cpuidle: remove stale irq disabling call in cpuidle_enter_freeze() Lorenzo Pieralisi
2015-02-25 14:13 ` Daniel Lezcano
2015-02-25 14:39 ` Lorenzo Pieralisi
2015-02-25 23:36 ` Rafael J. Wysocki
2015-02-26 9:48 ` Lorenzo Pieralisi [this message]
2015-02-26 16:39 ` Rafael J. Wysocki
2015-02-24 17:58 ` [PATCH 2/2] drivers: cpuidle: add driver/device checks " Lorenzo Pieralisi
2015-02-25 14:30 ` Daniel Lezcano
2015-02-25 14:47 ` Lorenzo Pieralisi
2015-02-25 23:50 ` Rafael J. Wysocki
2015-02-26 0:35 ` Rafael J. Wysocki
2015-02-25 14:56 ` Lorenzo Pieralisi
2015-02-26 23:37 ` [PATCH 0/2] drivers: cpuidle: minor suspend-to-idle fixes Rafael J. Wysocki
2015-02-26 23:39 ` [PATCH 1/2] idle / sleep: Avoid excessive interrupts disabling and enabling Rafael J. Wysocki
2015-02-26 23:39 ` [PATCH 2/2] cpuidle / sleep: Do sanity checks in cpuidle_enter_freeze() too Rafael J. Wysocki
2015-02-27 8:41 ` [PATCH 0/2] drivers: cpuidle: minor suspend-to-idle fixes Peter Zijlstra
2015-02-27 10:00 ` Lorenzo Pieralisi
2015-02-27 22:11 ` Rafael J. Wysocki
2015-02-28 11:54 ` Lorenzo Pieralisi
2015-02-28 23:58 ` Rafael J. Wysocki
2015-03-02 10:08 ` Lorenzo Pieralisi
2015-03-02 13:13 ` Rafael J. Wysocki
2015-03-02 14:50 ` [PATCH 0/2] cpuidle / sleep: fix timer stopping regression (was: drivers: cpuidle: minor suspend-to-idle fixes) Rafael J. Wysocki
2015-03-02 14:51 ` [PATCH 1/2] cpuidle: Clean up fallback handling in cpuidle_idle_call() Rafael J. Wysocki
2015-03-02 16:05 ` Lorenzo Pieralisi
2015-03-02 22:30 ` Rafael J. Wysocki
2015-03-02 14:53 ` [PATCH 2/2] cpuidle / sleep: Use broadcast timer for states that stop local timer Rafael J. Wysocki
2015-03-02 16:27 ` Lorenzo Pieralisi
2015-03-02 22:28 ` Rafael J. Wysocki
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=20150226094816.GA25057@red-moon \
--to=lorenzo.pieralisi@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rjw@rjwysocki.net \
--subject='Re: [PATCH 1/2] drivers: cpuidle: remove stale irq disabling call in cpuidle_enter_freeze()' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).