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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 21 Aug 2023 12:22:50 +0530
From:   Viresh Kumar <viresh.kumar@...aro.org>
To:     Liao Chang <liaochang1@...wei.com>
Cc:     rafael@...nel.org, linux-pm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] cpufreq: stats: Improve the performance of
 cpufreq_stats_create_table()

On 18-08-23, 09:50, Liao Chang wrote:
> In the worst case, the freq_table of policy data is not sorted and
> contains duplicate frequencies, this means that it needs to iterate
> through the entire freq_table of policy to ensure each frequency is
> unique in the freq_table of stats data, this has a time complexity of
> O(N^2), where N is the number of frequencies in the freq_table of
> policy.
> 
> However, if the policy.freq_table is already sorted and contains no
> duplicate frequencices, it can reduce the time complexity of creating
> stats.freq_table to O(N), the 'freq_table_sorted' field of policy data
> can be used to indicate whether the policy.freq_table is sorted.
> 
> Signed-off-by: Liao Chang <liaochang1@...wei.com>
> ---
>  drivers/cpufreq/cpufreq_stats.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
> index 55c7ffd37d1c..fcb74050711a 100644
> --- a/drivers/cpufreq/cpufreq_stats.c
> +++ b/drivers/cpufreq/cpufreq_stats.c
> @@ -243,7 +243,8 @@ void cpufreq_stats_create_table(struct cpufreq_policy *policy)
>  
>  	/* Find valid-unique entries */
>  	cpufreq_for_each_valid_entry(pos, policy->freq_table)
> -		if (freq_table_get_index(stats, pos->frequency) == -1)
> +		if ((policy->freq_table_sorted != CPUFREQ_TABLE_UNSORTED) ||
> +		    (freq_table_get_index(stats, pos->frequency) == -1))
>  			stats->freq_table[i++] = pos->frequency;
>  
>  	stats->state_num = i;

Acked-by: Viresh Kumar <viresh.kumar@...aro.org>

-- 
viresh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ