From: Andrew Morton <akpm@linux-foundation.org>
To: Josh Law <objecting@objecting.org>
Cc: linux-kernel@vger.kernel.org, hlcj1234567@gmail.com
Subject: Re: [PATCH] lib/assoc_array: fix stale nr_leaves_on_tree after gc
Date: Wed, 18 Mar 2026 11:36:52 -0700 [thread overview]
Message-ID: <20260318113652.b9647a9000aaa42a014ace5d@linux-foundation.org> (raw)
In-Reply-To: <540EA561-7291-4AAF-8FAD-857793B811D9@objecting.org>
On Wed, 18 Mar 2026 17:29:10 +0000 Josh Law <objecting@objecting.org> wrote:
> >
> >But assoc_array_apply_edit() alters array->nr_leaves_on_tree and now we
> >immediately overwrite that alteration?
>
>
> Hi Andrew,
>
> It probably doesn't overwrite it in this specific case.
>
>
> In assoc_array_gc(), the edit script is zero-initialized, meaning edit->adjust_count_on is NULL. Because of this (and since array->root isn't NULL), assoc_array_apply_edit() safely skips the block that modifies nr_leaves_on_tree.
wordwrapping, please.
> Since apply_edit() doesn't touch the count here, the explicit assignment right after is necessary to record the newly calculated post-GC count.
How about asking the author of this code?
next prev parent reply other threads:[~2026-03-18 18:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 16:49 Josh Law
2026-03-18 17:23 ` Andrew Morton
2026-03-18 17:29 ` Josh Law
2026-03-18 18:36 ` Andrew Morton [this message]
2026-03-18 18:42 ` Josh Law
2026-03-18 17:43 ` Josh Law
-- strict thread matches above, loose matches on Subject: below --
2026-03-18 16:48 Josh Law
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=20260318113652.b9647a9000aaa42a014ace5d@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=hlcj1234567@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=objecting@objecting.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
all inboxes | Powered by JetHome®