From: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
To: Chintan Pandya <cpandya@codeaurora.org>, <robh+dt@kernel.org>,
<frowand.list@gmail.com>, <devicetree@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>
Subject: Re: [PATCH v2] of: use hash based search in of_find_node_by_phandle
Date: Fri, 26 Jan 2018 11:57:02 +0100 [thread overview]
Message-ID: <f08592cf-5e49-e631-c481-e166b741f25e@prevas.dk> (raw)
In-Reply-To: <1516955496-17236-1-git-send-email-cpandya@codeaurora.org>
On 2018-01-26 09:31, Chintan Pandya wrote:
> Implement, device-phandle relation in hash-table so
> that look up can be faster, irrespective of where my
> device is defined in the DT.
>
> There are ~6.7k calls to of_find_node_by_phandle() and
> total improvement observed during boot is 400ms.
I'm probably missing something obvious, but: Aren't phandles in practice
small consecutive integers assigned by dtc? If so, why not just have a
smallish static array mapping the small phandle values directly to
device node, instead of adding a pointer to every struct device_node? Or
one could determine the size of the array dynamically (largest seen
phandle value, capping at something sensible, e.g. 1024).
In either case, one would still need to keep the code doing the
whole-tree traversal for handling large phandle values, but I think the
above should make lookup O(1) in most cases.
Alternatively, one could just count the number of nodes with a phandle,
allocate an array of that many pointers (so the memory use is certainly
no more than if adding a pointer to each device_node), and sort it by
phandle, so one can do lookup using a binary search.
Rasmus
next prev parent reply other threads:[~2018-01-26 10:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-26 8:31 [PATCH v2] of: use hash based search in of_find_node_by_phandle Chintan Pandya
2018-01-26 10:57 ` Rasmus Villemoes [this message]
2018-01-26 15:14 ` Chintan Pandya
2018-01-26 15:34 ` Rob Herring
2018-01-26 21:39 ` Rob Herring
2018-01-29 7:34 ` Chintan Pandya
2018-01-29 15:10 ` Rob Herring
2018-01-29 18:18 ` Chintan Pandya
2018-01-26 23:11 ` kbuild test robot
2018-01-26 23:26 ` kbuild test robot
2018-01-29 23:23 ` Frank Rowand
2018-01-30 8:04 ` Chintan Pandya
2018-01-30 18:59 ` Frank Rowand
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=f08592cf-5e49-e631-c481-e166b741f25e@prevas.dk \
--to=rasmus.villemoes@prevas.dk \
--cc=cpandya@codeaurora.org \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.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