[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <175847520494.4354.5422042536281886650@lazor>
Date: Sun, 21 Sep 2025 10:20:04 -0700
From: Stephen Boyd <sboyd@...nel.org>
To: Chen-Yu Tsai <wenst@...omium.org>
Cc: Chen-Yu Tsai <wenst@...omium.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
Quoting Chen-Yu Tsai (2025-08-13 20:53:16)
> 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 |
> -------------------------------------------
Applied to clk-next
Can you send a followup that adds a unit test for clk_core_lookup()? We
don't want __clk_lookup() to continue being used, so maybe we can add a
test only exported function like clk_hw_lookup() that uses
clk_core_lookup() underneath while grabbing the prepare lock. It can
make sure a registered clk_hw is found and a non-registered name isn't
found and assert that the not yet registered name isn't found.
Powered by blists - more mailing lists