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]
Message-ID: <CAJZ5v0h_qFs6D6pMfZT-NxgyDOOYYUzN=Ketw69C4BqsAG8_JQ@mail.gmail.com>
Date: Fri, 19 Sep 2025 19:04:09 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Takashi Iwai <tiwai@...e.de>
Cc: "Rafael J . Wysocki" <rafael@...nel.org>, linux-pm@...r.kernel.org, 
	Bjorn Helgaas <bhelgaas@...gle.com>, linux-pci@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] PM: runtime: Define class helpers for automatic PM
 runtime cleanup

On Fri, Sep 19, 2025 at 6:32 PM Takashi Iwai <tiwai@...e.de> wrote:
>
> From: "Rafael J. Wysocki" <rafael@...nel.org>
>
> This patch adds two CLASS macros for the easier use of the
> auto-cleanup feature to manage the runtime PM get/put pairs.
> With the CLASS macro, pm_runtime_put() (or *_autosuspend) is called
> automatically at its scope exit, so you can remove the explicit
> pm_runtime_put() call.

The part of the changelog below is actually really nice.

> Simply put, a code like below
>
>         ret = pm_runtime_resume_and_get(dev);
>         if (ret < 0)
>                 return ret;
>         .....
>         pm_runtime_put(dev);
>         return 0;
>
> can be simplified with CLASS() like:
>
>         CLASS(pm_runtime_resume_and_get, pm)(dev);
>         if (IS_ERR(pm))
>                 return PTR_ERR(pm);
>         .....
>         return 0;
>
> (see pm_runtime_put() call is gone).
>
> When the original code calls pm_runtime_put_autosuspend(), use
> CLASS(pm_runtime_resume_and_get_auto) variant, instead.
> e.g. a code like:
>
>         ret = pm_runtime_resume_and_get(dev);
>         if (ret < 0)
>                 return ret;
>         .....
>         pm_runtime_put_autosuspend(dev);
>         return 0;
>
> will be like:
>
>         CLASS(pm_runtime_resume_and_get_auto, pm)(dev);
>         if (IS_ERR(pm))
>                 return PTR_ERR(pm);
>         .....
>         return 0;
>
> Note that there is no CLASS macro defined for pm_runtime_get_sync().
> With the auto-cleanup, we can unify both usages.
> You can use CLASS(pm_runtime_resume_and_get) but simply skip the error
> check; so a code like below:
>
>         pm_runtime_get_sync(dev);
>         .....
>         pm_runtime_put(dev);
>         return 0;
>
> will become like:
>
>         CLASS(pm_runtime_resume_and_get, pm)(dev);
>         .....
>         return 0;
>
> Link: https://lore.kernel.org/878qimv24u.wl-tiwai@suse.de
> Signed-off-by: Takashi Iwai <tiwai@...e.de>

So I'm going to include it into the first patch and add a
Co-developed-by: tag for you to it.

I'll send a v2, but I'll wait some time in case someone else has any
comments.  Probably tomorrow.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ