From: Randolph Sapp <rs@ti.com>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>, <rs@ti.com>,
<robertcnelson@gmail.com>, <ayush@beagleboard.org>,
<Erik.Welsh@octavosystems.com>, <anshuld@ti.com>, <bb@ti.com>,
<trini@konsulko.com>, <afd@ti.com>, <ilias.apalodimas@linaro.org>
Cc: <u-boot@lists.denx.de>
Subject: Re: [PATCHv2 4/5] efi_mem_sort: skip unnecessary compare
Date: Mon, 13 Apr 2026 14:23:50 -0500 [thread overview]
Message-ID: <DHS9TKSVNH16.3L5B7F14AYYTI@ti.com> (raw)
In-Reply-To: <59AD8D70-3B2E-4969-8E94-90BC60BEF96A@gmx.de>
On Thu Apr 9, 2026 at 2:47 PM CDT, Heinrich Schuchardt wrote:
> Am 2. April 2026 22:50:37 MESZ schrieb rs@ti.com:
>>From: Randolph Sapp <rs@ti.com>
>>
>>I don't want to think about the possibility of this pointer containing a
>>reference to something from a previous iteration. At best it results in
>>a some arithmetic and a comparison that should usually be unnecessary.
>
> "a some arithmetic" is not understandable. Please, adjust the commit message.
>
>>
>>Signed-off-by: Randolph Sapp <rs@ti.com>
>>---
>> lib/efi_loader/efi_memory.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>>diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
>>index b77c2f980cc..882366a9f8a 100644
>>--- a/lib/efi_loader/efi_memory.c
>>+++ b/lib/efi_loader/efi_memory.c
>>@@ -129,13 +129,13 @@ static uint64_t desc_get_end(struct efi_mem_desc *desc)
>> static void efi_mem_sort(void)
>> {
>> struct efi_mem_list *lmem;
>>- struct efi_mem_list *prevmem = NULL;
>> bool merge_again = true;
>>
>> list_sort(NULL, &efi_mem, efi_mem_cmp);
>>
>> /* Now merge entries that can be merged */
>> while (merge_again) {
>
> The suggested change looks correct. But we could go further:
>
> We could get rid of this outer loop by either eliminating prev instead of cur or by using list_for_each_safe().
>
> Best regards
>
> Heinrich
Very good point. Didn't know about the safe iteration functions but this logic
would benefit greatly from comparing current and next efi_mem_desc and merging
into the next efi_mem_desc instance instead. Less arithmetic, iteration, and
generally less room for error.
Will apply that.
>>+ struct efi_mem_list *prevmem = NULL;
>> merge_again = false;
>> list_for_each_entry(lmem, &efi_mem, link) {
>> struct efi_mem_desc *prev;
next prev parent reply other threads:[~2026-04-13 19:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 20:50 [PATCHv2 0/5] various memory related fixups rs
2026-04-02 20:50 ` [PATCHv2 1/5] lmb: add LMB_FDT for fdt reserved regions rs
2026-04-06 21:37 ` Randolph Sapp
2026-04-09 19:15 ` Heinrich Schuchardt
2026-04-02 20:50 ` [PATCHv2 2/5] efi_dt_fixup: use fdtdec_get_bool rs
2026-04-09 9:44 ` Anshul Dalal
2026-04-09 19:22 ` Heinrich Schuchardt
2026-04-10 5:08 ` Ilias Apalodimas
2026-04-02 20:50 ` [PATCHv2 3/5] efi_selftest_memory: check for duplicates first rs
2026-04-02 20:50 ` [PATCHv2 4/5] efi_mem_sort: skip unnecessary compare rs
2026-04-09 19:47 ` Heinrich Schuchardt
2026-04-13 19:23 ` Randolph Sapp [this message]
2026-04-02 20:50 ` [PATCHv2 5/5] memory: reserve from start_addr_sp to end_addr_sp rs
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=DHS9TKSVNH16.3L5B7F14AYYTI@ti.com \
--to=rs@ti.com \
--cc=Erik.Welsh@octavosystems.com \
--cc=afd@ti.com \
--cc=anshuld@ti.com \
--cc=ayush@beagleboard.org \
--cc=bb@ti.com \
--cc=ilias.apalodimas@linaro.org \
--cc=robertcnelson@gmail.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/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