From: David Gibson <david@gibson.dropbear.id.au>
To: Kelvin Zhang <zhangkelvin@google.com>
Cc: devicetree-compiler@vger.kernel.org, Simon Glass <sjg@chromium.org>
Subject: Re: [PATCH v2] libfdt: Don't search for the terminator in fdt_get_string()
Date: Mon, 2 Nov 2026 17:20:55 +1100 [thread overview]
Message-ID: <augrvGDJghayJVMv@gractus.seuss> (raw)
In-Reply-To: <CAOSmRzixCf479QyhmGuwBBZrRLTYqoaSUw88HKZnkPyEh6=gcw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1323 bytes --]
On Sun, Nov 01, 2026 at 08:50:05PM -0800, Kelvin Zhang wrote:
> Unless FDT_ASSUME_MASK includes ASSUME_VALID_INPUT, fdt_get_string()
> finds the end of the string with memchr(), bounded by the end of the
> string block, which also checks that the string is terminated. A
> string block normally ends with a NUL, and then every string in it is
> terminated. When the caller does not ask for the string's length,
> check that byte instead, so that fdt_string() doesn't scan the string
> at all.
>
> This helps callers that look up many property names. With a 612 KiB
> tree on x86-64, built with gcc -O2 and the default FDT_ASSUME_MASK,
> calling fdt_string() for the name of each of its 17,899 properties
> takes 108 us instead of 160 us, not counting the walk that finds
> them. libufdt, which Android bootloaders use to apply overlays, calls
> fdt_string() at least once for every property it reads: tens of
> thousands of times to apply one overlay to a 445 KiB tree.
>
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> Signed-off-by: Kelvin Zhang <zhangkelvin@google.com>
Merged, thanks.
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2026-11-02 6:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 4:50 [PATCH v2] libfdt: Don't search for the terminator in fdt_get_string() Kelvin Zhang
2026-11-02 6:20 ` David Gibson [this message]
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=augrvGDJghayJVMv@gractus.seuss \
--to=david@gibson.dropbear.id.au \
--cc=devicetree-compiler@vger.kernel.org \
--cc=sjg@chromium.org \
--cc=zhangkelvin@google.com \
/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