From: Joshua Hahn <joshua.hahnjy@gmail.com>
To: David Hildenbrand <david@redhat.com>
Cc: gourry@gourry.net, akpm@linux-foundation.org,
harry.yoo@oracle.com, ying.huang@linux.alibaba.com,
honggyu.kim@sk.com, yunjeong.mun@sk.com,
gregkh@linuxfoundation.org, rakie.kim@sk.com, rafael@kernel.org,
lenb@kernel.org, dan.j.williams@intel.com,
Jonathan.Cameron@huawei.com, dave.jiang@intel.com,
horen.chuang@linux.dev, hannes@cmpxchg.org, osalvador@suse.de,
linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
linux-mm@kvack.org, kernel-team@meta.com
Subject: Re: [PATCH v9] mm/mempolicy: Weighted Interleave Auto-tuning
Date: Wed, 21 May 2025 08:37:29 -0700 [thread overview]
Message-ID: <20250521153730.2196701-1-joshua.hahnjy@gmail.com> (raw)
In-Reply-To: <25283dbd-2867-4034-bb16-951e0fb81843@redhat.com>
On Wed, 21 May 2025 15:04:00 +0200 David Hildenbrand <david@redhat.com> wrote:
> On 20.05.25 16:12, Joshua Hahn wrote:
[...snip...]
> [...]
>
> > -static void iw_table_free(void)
> > +static void wi_state_free(void)
> > {
> > - u8 *old;
> > + struct weighted_interleave_state *old_wi_state;
> >
> > - mutex_lock(&iw_table_lock);
> > - old = rcu_dereference_protected(iw_table,
> > - lockdep_is_held(&iw_table_lock));
> > - rcu_assign_pointer(iw_table, NULL);
> > - mutex_unlock(&iw_table_lock);
> > + mutex_lock(&wi_state_lock);
> > +
> > + old_wi_state = rcu_dereference_protected(wi_state,
> > + lockdep_is_held(&wi_state_lock));
> > + if (!old_wi_state) {
> > + mutex_unlock(&wi_state_lock);
> > + goto out;
> > + }
> >
> > + rcu_assign_pointer(wi_state, NULL);
> > + mutex_unlock(&wi_state_lock);
>
> Just one nit: if written as:
>
> ...
> rcu_assign_pointer(wi_state, NULL);
> mutex_unlock(&wi_state_lock);
>
> old_wi_state = ...
> if (old_wi_state) {
> synchronize_rcu();
> kfree(old_wi_state);
> }
> kfree(&wi_group->wi_kobj);
>
> You can easily avoid the goto.
Ah I see, thank you for the suggestion!
I think we would have to move the "old_wi_state = ..." to be inside
the lock and before the rcu_assign_pointer since wi_state will be
NULL at that point if we do not, but other than that, I think this
is a great optimization over the version I have : -)
I will send in a fix patch for this later as a cleanup patch, if
that sounds good with you!
> > synchronize_rcu();
> > - kfree(old);
> > + kfree(old_wi_state);
> > +out:
> > + kfree(&wi_group->wi_kobj);
> > }
>
> I'll note that this rather unrelated churn (renaming functions +
> variables) is a bit abd for review as it adds noise. Having that as part
> of a cleanup patch might have been better.
I see, thank you for your feedback.
I thought it might be necessary for this series, since I embedded the
iw_table inside the wi_struct, so we can no longer just free the table,
we would have to free the entire wi_state it was embedded in. I apologize if
this was difficult to review -- I agree that this patch was on the longer
side. I will do a better job of isolating parts of the patch in the future.
> Nothing else jumped at me (did not an in-depth review of the logic)
>
> Acked-by: David Hildenbrand <david@redhat.com>
Thank you for your Ack, David! I hope you have a great day!! : -)
Joshua
> --
> Cheers,
>
> David / dhildenb
next prev parent reply other threads:[~2025-05-21 15:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 14:12 Joshua Hahn
2025-05-20 17:53 ` Andrew Morton
2025-05-20 18:11 ` Joshua Hahn
2025-05-20 18:37 ` Andrew Morton
2025-05-20 19:00 ` Joshua Hahn
2025-05-21 13:04 ` David Hildenbrand
2025-05-21 15:37 ` Joshua Hahn [this message]
2025-05-21 15:40 ` David Hildenbrand
2025-05-21 13:38 ` Oscar Salvador
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=20250521153730.2196701-1-joshua.hahnjy@gmail.com \
--to=joshua.hahnjy@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=david@redhat.com \
--cc=gourry@gourry.net \
--cc=gregkh@linuxfoundation.org \
--cc=hannes@cmpxchg.org \
--cc=harry.yoo@oracle.com \
--cc=honggyu.kim@sk.com \
--cc=horen.chuang@linux.dev \
--cc=kernel-team@meta.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=osalvador@suse.de \
--cc=rafael@kernel.org \
--cc=rakie.kim@sk.com \
--cc=ying.huang@linux.alibaba.com \
--cc=yunjeong.mun@sk.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