From: John Keeping <john@metanate.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: linux-rt-users@vger.kernel.org, Pavel Machek <pavel@ucw.cz>,
Len Brown <len.brown@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Linux PM <linux-pm@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH RT] PM: runtime: avoid retry loops on RT
Date: Tue, 5 Oct 2021 18:17:06 +0100 [thread overview]
Message-ID: <20211005181706.66102578.john@metanate.com> (raw)
In-Reply-To: <CAJZ5v0gPwUQzGBa2VDeC3xAF9zJVm486BC0eue10-urJ8Xz+iw@mail.gmail.com>
On Tue, 5 Oct 2021 18:38:27 +0200
"Rafael J. Wysocki" <rafael@kernel.org> wrote:
> On Tue, Oct 5, 2021 at 6:14 PM John Keeping <john@metanate.com> wrote:
> >
> > With PREEMPT_RT spin_unlock() is identical to spin_unlock_irq() so there
> > is no reason to have a special case using the former. Furthermore,
> > spin_unlock() enables preemption meaning that a task in RESUMING or
> > SUSPENDING state may be preempted by a higher priority task running
> > pm_runtime_get_sync() leading to a livelock.
> >
> > Use the non-irq_safe path for all waiting so that the waiting task will
> > block.
> >
> > Note that this changes only the waiting behaviour of irq_safe, other
> > uses are left unchanged so that the parent device always remains active
> > in the same way as !RT.
> >
> > Signed-off-by: John Keeping <john@metanate.com>
>
> So basically, the idea is that the irq_safe flag should have no effect
> when CONFIG_PREEMPT_RT is set, right?
>
> Wouldn't it be cleaner to make it not present at all in that case?
Yes, just replacing pm_runtime_irq_safe() with an empty function would
also fix it, but I'm not sure if that will have unexpected effects from
the parent device suspending/resuming, especially in terms of latency
for handling interrupts.
> > ---
> > drivers/base/power/runtime.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> > index 96972d5f6ef3..5e0d349fab4e 100644
> > --- a/drivers/base/power/runtime.c
> > +++ b/drivers/base/power/runtime.c
> > @@ -347,8 +347,9 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev)
> > {
> > int retval = 0, idx;
> > bool use_links = dev->power.links_count > 0;
> > + bool irq_safe = dev->power.irq_safe && !IS_ENABLED(CONFIG_PREEMPT_RT);
> >
> > - if (dev->power.irq_safe) {
> > + if (irq_safe) {
> > spin_unlock(&dev->power.lock);
> > } else {
> > spin_unlock_irq(&dev->power.lock);
> > @@ -376,7 +377,7 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev)
> > if (cb)
> > retval = cb(dev);
> >
> > - if (dev->power.irq_safe) {
> > + if (irq_safe) {
> > spin_lock(&dev->power.lock);
> > } else {
> > /*
> > @@ -596,7 +597,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
> > goto out;
> > }
> >
> > - if (dev->power.irq_safe) {
> > + if (dev->power.irq_safe && !IS_ENABLED(CONFIG_PREEMPT_RT)) {
> > spin_unlock(&dev->power.lock);
> >
> > cpu_relax();
> > @@ -777,7 +778,7 @@ static int rpm_resume(struct device *dev, int rpmflags)
> > goto out;
> > }
> >
> > - if (dev->power.irq_safe) {
> > + if (dev->power.irq_safe && !IS_ENABLED(CONFIG_PREEMPT_RT)) {
> > spin_unlock(&dev->power.lock);
> >
> > cpu_relax();
> > --
> > 2.33.0
> >
next prev parent reply other threads:[~2021-10-05 17:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-05 15:54 [RFC PATCH RT] PM: runtime: avoid retry loops on RT John Keeping
2021-10-05 16:38 ` Rafael J. Wysocki
2021-10-05 17:17 ` John Keeping [this message]
2021-10-06 17:05 ` Rafael J. Wysocki
2021-10-06 18:18 ` John Keeping
2021-10-21 10:37 ` Rafael J. Wysocki
2021-10-25 10:30 ` John Keeping
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=20211005181706.66102578.john@metanate.com \
--to=john@metanate.com \
--cc=gregkh@linuxfoundation.org \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=rafael@kernel.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