public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: Chen-Yu Tsai <wenst@chromium.org>
Cc: Chen-Yu Tsai <wenst@chromium.org>,
	linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] clk: Use hashtable for global clk lookups
Date: Sun, 21 Sep 2025 10:20:04 -0700	[thread overview]
Message-ID: <175847520494.4354.5422042536281886650@lazor> (raw)
In-Reply-To: <20250814035317.4112336-2-wenst@chromium.org>

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.


  parent reply	other threads:[~2025-09-21 17:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14  3:53 [PATCH v2 1/2] clk: Sort include statements Chen-Yu Tsai
2025-08-14  3:53 ` [PATCH v2 2/2] clk: Use hashtable for global clk lookups Chen-Yu Tsai
2025-08-22 13:20   ` Brian Masney
2025-09-21 17:20   ` Stephen Boyd [this message]
2025-08-22 13:26 ` [PATCH v2 1/2] clk: Sort include statements Brian Masney
2025-09-21 17:16 ` Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=175847520494.4354.5422042536281886650@lazor \
    --to=sboyd@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wenst@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox