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: <6a57bf9a-c4f4-2350-8bd2-01717d966611@linaro.org>
Date:   Fri, 18 Dec 2020 10:05:44 -0500
From:   Thara Gopinath <thara.gopinath@...aro.org>
To:     Daniel Lezcano <daniel.lezcano@...aro.org>, rui.zhang@...el.com
Cc:     amitk@...nel.org, linux-kernel@...r.kernel.org,
        linux-pm@...r.kernel.org, Lukasz Luba <lukasz.luba@....com>
Subject: Re: [PATCH v2 1/3] thermal/core: Precompute the delays from msecs to
 jiffies



On 12/16/20 5:03 PM, Daniel Lezcano wrote:
> The delays are stored in ms units and when the polling function is
> called this delay is converted into jiffies at each call.
> 
> Instead of doing the conversion again and again, compute the jiffies
> at init time and use the value directly when setting the polling.
> 
> Cc: Thara Gopinath <thara.gopinath@...aro.org>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@...aro.org>
> Reviewed-by: Lukasz Luba <lukasz.luba@....com>
> ---
>   drivers/thermal/thermal_core.c    | 3 +++
>   drivers/thermal/thermal_core.h    | 1 +
>   drivers/thermal/thermal_helpers.c | 7 +++++++
>   include/linux/thermal.h           | 7 +++++++
>   4 files changed, 18 insertions(+)

Reviewed-by: Thara Gopinath <thara.gopinath@...aro.org>

> 
> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
> index bcc2ea4f5482..2c41d4a0923f 100644
> --- a/drivers/thermal/thermal_core.c
> +++ b/drivers/thermal/thermal_core.c
> @@ -1315,6 +1315,9 @@ thermal_zone_device_register(const char *type, int trips, int mask,
>   	tz->passive_delay = passive_delay;
>   	tz->polling_delay = polling_delay;
>   
> +	thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay);
> +	thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay);
> +
>   	/* sys I/F */
>   	/* Add nodes that are always present via .groups */
>   	result = thermal_zone_create_device_groups(tz, mask);
> diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h
> index e50c6b2909fe..90f9a80c8b23 100644
> --- a/drivers/thermal/thermal_core.h
> +++ b/drivers/thermal/thermal_core.h
> @@ -123,6 +123,7 @@ int thermal_build_list_of_policies(char *buf);
>   
>   /* Helpers */
>   void thermal_zone_set_trips(struct thermal_zone_device *tz);
> +void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms);
>   
>   /* sysfs I/F */
>   int thermal_zone_create_device_groups(struct thermal_zone_device *, int);
> diff --git a/drivers/thermal/thermal_helpers.c b/drivers/thermal/thermal_helpers.c
> index c94bc824e5d3..7f50f412e02a 100644
> --- a/drivers/thermal/thermal_helpers.c
> +++ b/drivers/thermal/thermal_helpers.c
> @@ -175,6 +175,13 @@ void thermal_zone_set_trips(struct thermal_zone_device *tz)
>   	mutex_unlock(&tz->lock);
>   }
>   
> +void thermal_set_delay_jiffies(unsigned long *delay_jiffies, int delay_ms)
> +{
> +	*delay_jiffies = msecs_to_jiffies(delay_ms);
> +	if (delay_ms > 1000)
> +		*delay_jiffies = round_jiffies(*delay_jiffies);
> +}
> +
>   static void thermal_cdev_set_cur_state(struct thermal_cooling_device *cdev,
>   				       int target)
>   {
> diff --git a/include/linux/thermal.h b/include/linux/thermal.h
> index 060a2160add4..d1b82c70de69 100644
> --- a/include/linux/thermal.h
> +++ b/include/linux/thermal.h
> @@ -117,9 +117,14 @@ struct thermal_cooling_device {
>    * @trips_disabled;	bitmap for disabled trips
>    * @passive_delay:	number of milliseconds to wait between polls when
>    *			performing passive cooling.
> + * @passive_delay_jiffies: number of jiffies to wait between polls when
> + *			performing passive cooling.
>    * @polling_delay:	number of milliseconds to wait between polls when
>    *			checking whether trip points have been crossed (0 for
>    *			interrupt driven systems)
> + * @polling_delay_jiffies: number of jiffies to wait between polls when
> + *			checking whether trip points have been crossed (0 for
> + *			interrupt driven systems)
>    * @temperature:	current temperature.  This is only for core code,
>    *			drivers should use thermal_zone_get_temp() to get the
>    *			current temperature
> @@ -155,6 +160,8 @@ struct thermal_zone_device {
>   	void *devdata;
>   	int trips;
>   	unsigned long trips_disabled;	/* bitmap for disabled trips */
> +	unsigned long passive_delay_jiffies;
> +	unsigned long polling_delay_jiffies;
>   	int passive_delay;
>   	int polling_delay;
>   	int temperature;
> 

-- 
Warm Regards
Thara

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ