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: <aKhutc0IVWun83qF@x1>
Date: Fri, 22 Aug 2025 09:20:53 -0400
From: Brian Masney <bmasney@...hat.com>
To: Chen-Yu Tsai <wenst@...omium.org>
Cc: Stephen Boyd <sboyd@...nel.org>, linux-clk@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/2] clk: Use hashtable for global clk lookups

On Thu, Aug 14, 2025 at 11:53:16AM +0800, Chen-Yu Tsai wrote:
> A clk lookup using clk_core_lookup() is currently somewhat expensive
> since it has to walk the whole clk tree to find a match. This is
> extremely bad in the clk_core_init() function where it is used to look
> for clk name conflicts, which is always the worst case of walking the
> whole tree. Moreover, the number of clks checked increases as more
> clks are registered, causing each subsequent clk registration becoming
> slower.
> 
> Add a hashtable for doing clk lookups to replace the tree walk method.
> On arm64 this increases kernel memory usage by 4 KB for the hashtable,
> and 16 bytes (2 pointers) for |struct hlist_node| in each clk. On a
> platform with around 800 clks, this reduces the time spent in
> clk_core_lookup() significantly:
> 
>           |      PID 0      |     kworker     |
>           | before |  after | before |  after |
>     -------------------------------------------
>     avg   | 203 us | 2.7 us | 123 us | 1.5 us |
>     -------------------------------------------
>     min   | 4.7 us | 2.3 us | 102 us | 0.9 us |
>     -------------------------------------------
>     max   | 867 us | 4.8 us | 237 us | 3.5 us |
>     -------------------------------------------
>     culm  | 109 ms | 1.5 ms |  21 ms | 0.3 ms |
> 
> This in turn reduces the time spent in clk_hw_register(), and
> ultimately, boot time. On a different system with close to 700 clks,
> This reduces boot time by around 110 ms. While this doesn't seem like
> a lot, this helps in cases where minimizing boot time is important.
> 
> Signed-off-by: Chen-Yu Tsai <wenst@...omium.org>

Reviewed-by: Brian Masney <bmasney@...hat.com>
Tested-by: Brian Masney <bmasney@...hat.com>

I tested this on my Thinkpad x13s laptop, and clk_core_lookup() is
called 684 times on normal boot up of my system. Only 4 of those are
duplicate lookups.

Brian


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ