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: <3bd97781fbd2e82a6c14a2e22aff2d4304c3206e.camel@intel.com>
Date: Tue, 20 Aug 2024 07:05:00 +0000
From: "Zhang, Rui" <rui.zhang@...el.com>
To: "linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>, "rjw@...ysocki.net"
	<rjw@...ysocki.net>
CC: "lukasz.luba@....com" <lukasz.luba@....com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"daniel.lezcano@...aro.org" <daniel.lezcano@...aro.org>
Subject: Re: [PATCH v3 02/14] thermal: core: Rearrange checks in
 thermal_bind_cdev_to_trip()

On Mon, 2024-08-19 at 17:51 +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
> 
> It is not necessary to look up the thermal zone and the cooling
> device
> in the respective global lists to check whether or not they are
> registered.  It is sufficient to check whether or not their
> respective
> list nodes are empty for this purpose.
> 
> Use the above observation to simplify thermal_bind_cdev_to_trip(). 
> In
> addition, eliminate an unnecessary ternary operator from it.
> 
> Moreover, add lockdep_assert_held() for thermal_list_lock to it
> because
> that lock must be held by its callers when it is running.
> 
> No intentional functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>

Reviewed-by: Zhang Rui <rui.zhang@...el.com>

thanks,
rui

> ---
> 
> v1 -> v3: No changes
> 
> ---
>  drivers/thermal/thermal_core.c |   16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
> 
> Index: linux-pm/drivers/thermal/thermal_core.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/thermal_core.c
> +++ linux-pm/drivers/thermal/thermal_core.c
> @@ -781,25 +781,17 @@ int thermal_bind_cdev_to_trip(struct the
>  {
>         struct thermal_instance *dev;
>         struct thermal_instance *pos;
> -       struct thermal_zone_device *pos1;
> -       struct thermal_cooling_device *pos2;
>         bool upper_no_limit;
>         int result;
>  
> -       list_for_each_entry(pos1, &thermal_tz_list, node) {
> -               if (pos1 == tz)
> -                       break;
> -       }
> -       list_for_each_entry(pos2, &thermal_cdev_list, node) {
> -               if (pos2 == cdev)
> -                       break;
> -       }
> +       lockdep_assert_held(&thermal_list_lock);
>  
> -       if (tz != pos1 || cdev != pos2)
> +       if (list_empty(&tz->node) || list_empty(&cdev->node))
>                 return -EINVAL;
>  
>         /* lower default 0, upper default max_state */
> -       lower = lower == THERMAL_NO_LIMIT ? 0 : lower;
> +       if (lower == THERMAL_NO_LIMIT)
> +               lower = 0;
>  
>         if (upper == THERMAL_NO_LIMIT) {
>                 upper = cdev->max_state;
> 
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ