From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] drivers/perf: arm-pmu: fix RCU usage on resume from idle states
Date: Wed, 20 Apr 2016 17:52:05 +0100 [thread overview]
Message-ID: <20160420165205.GA17840@red-moon> (raw)
In-Reply-To: <20160420162354.GB3539@linux.vnet.ibm.com>
On Wed, Apr 20, 2016 at 09:23:54AM -0700, Paul E. McKenney wrote:
[...]
> > > Maybe RCU_NONIDLE() will help here?
> >
> > Thanks for chiming in.
> >
> > CPU_PM notifiers are called from process context (which is not necessarily
> > the idle thread) with IRQs disabled from:
> >
> > - CPUidle drivers state enter calls
> > - syscore callbacks (ie suspend2RAM - suspend thread)
> > - bL switcher
> > - MCPM loopback
> >
> > The questions I have are:
> >
> > - Is it safe to wrap a call (in this case armpmu_start()) with RCU_NONIDLE
> > if the core is not actually executing the idle thread ? The function
> > requiring rcu locks/dereferences is perf_event_update_userpage().
>
> Yes it is.
>
> > - What are RCU_NONIDLE side-effects (ie what can be actually called from
> > within an RCU_NONIDLE wrapper ?)
>
> There are a few restrictions:
>
> 1. Code within RCU_NONIDLE() cannot block. Then again, neither
> can the idle task. ;-)
>
> 2. RCU_NONIDLE() can be nested, but not indefinitely. Then again,
> given that the limit even on a 32-bit system is something like
> a million, I bet you hit compiler or stack-size limits long
> before you overflow RCU_NONIDLE()'s counter.
>
> 3. You can neither branch into the middle of RCU_NONIDLE()'s code
> nor branch out from the middle of RCU_NONIDLE()'s code.
> Calling functions is just fine, but things like this are not:
>
> RCU_NONIDLE({
> do_something();
> goto bad_idea; /* BUG!!! */
> do_something_else();});
> do_yet_a_third_thing();
> bad_idea:
>
> Branching -within- the RCU_NONIDLE() code is just fine.
>
> Yes, and I am adding this information to RCU_NONIDLE()'s header
> comment, apologies for its not being there to begin with!
> (See below for patches.)
Thank you for the explanation, that's now clear. For my own understanding:
RCU_NONIDLE() is a way to inform the RCU subsystem that the CPU in question
should be temporarily *watched* (ie it is not idle from an RCU standpoint),
correct ?
> > It would be nice if we can use it instead of merging this patch, I need
> > more insights into RCU_NONIDLE usage though before proceeding.
>
> Please let me know if any of the above restrictions cause you a problem.
I can't think of any, perf_event_update_userpage(), that I will call
indirectly through:
RCU_NONIDLE(armpmu_start());
is not allowed to block anyway, so I think we have a much better
solution than this one, new patch coming, Catalin please drop this one.
Thank you all !
Lorenzo
next prev parent reply other threads:[~2016-04-20 16:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-19 17:08 [PATCH] drivers/perf: arm-pmu: fix RCU usage on resume from idle states Lorenzo Pieralisi
2016-04-19 17:23 ` Will Deacon
2016-04-19 21:48 ` Kevin Hilman
2016-04-20 13:41 ` Lorenzo Pieralisi
2016-04-20 15:45 ` Catalin Marinas
2016-04-20 16:23 ` Paul E. McKenney
2016-04-20 16:52 ` Lorenzo Pieralisi [this message]
2016-04-20 17:19 ` Paul E. McKenney
2016-04-20 10:48 ` Catalin Marinas
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=20160420165205.GA17840@red-moon \
--to=lorenzo.pieralisi@arm.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).