lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 5 Oct 2021 18:38:27 +0200
From:   "Rafael J. Wysocki" <rafael@...nel.org>
To:     John Keeping <john@...anate.com>
Cc:     linux-rt-users@...r.kernel.org,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Pavel Machek <pavel@....cz>, Len Brown <len.brown@...el.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Linux PM <linux-pm@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH RT] PM: runtime: avoid retry loops on RT

On Tue, Oct 5, 2021 at 6:14 PM John Keeping <john@...anate.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@...anate.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?

> ---
>  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
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ