linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Rakie Kim <rakie.kim@sk.com>
To: Gregory Price <gourry@gourry.net>
Cc: Rakie Kim <rakie.kim@sk.com>,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org,
	joshua.hahnjy@gmail.com, dan.j.williams@intel.com,
	ying.huang@linux.alibaba.com, kernel_team@skhynix.com,
	honggyu.kim@sk.com, yunjeong.mun@sk.com,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v2 1/4] mm/mempolicy: Fix memory leaks in mempolicy_sysfs_init()
Date: Mon, 17 Mar 2025 17:24:00 +0900	[thread overview]
Message-ID: <20250317082406.818-1-rakie.kim@sk.com> (raw)
In-Reply-To: <Z9QyR3mHw76u_Sq9@gourry-fedora-PF4VCD3F>

On Fri, 14 Mar 2025 09:42:31 -0400 Gregory Price <gourry@gourry.net> wrote:
> On Fri, Mar 14, 2025 at 10:55:00AM +0000, Jonathan Cameron wrote:
> > > 
> > > 1) allocate node_attrs and mempolicy_kobj up front and keep your
> > >    reordering, this lets us clean up allocations on failure before
> > >    kobject_init is called
> > > 
> > > 2) after this remove all the other code and just let
> > >    mempolicy_kobj_release clean up node_attrs
> > > 
> > > 3) Add a (%d) to the error message to differentiate failures
> > 
> > Given how unlikely (and noisy) a memory allocation failure is,
> > maybe just drop the printing at all in those paths - allowing
> > early returns.
> > 
> > The lifetime rules around node_attrs in here are making readability
> > poor. It is implicitly owned by the mempolicy_kobj, but no direct association.
> > Maybe just encapsulating the kobject in a structure that contains
> > this as a [] array at the end.  Then we end up with single allocation of
> > stuff that is effectively one thing.
> >
> 
> Even better recommendation, lets do as Jonathan suggests. <3
> 
> ~Gregory

Hi Gregory

I will revise the next version based on Jonathan's feedback.
Moreover, I'll separate this patch from the hotplug series and make it an
independent patch.

Rakie


  reply	other threads:[~2025-03-17  8:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-12  7:56 Rakie Kim
2025-03-12  7:56 ` [PATCH v2 2/4] mm/mempolicy: Support memory hotplug in weighted interleave Rakie Kim
2025-03-12 16:03   ` Gregory Price
2025-03-13  6:33     ` Rakie Kim
2025-03-13 16:23       ` Gregory Price
2025-03-13 22:36         ` David Hildenbrand
2025-03-14  6:00           ` Rakie Kim
2025-03-14  9:17             ` David Hildenbrand
2025-03-17  8:23               ` Rakie Kim
2025-03-12  7:56 ` [PATCH v2 3/4] mm/mempolicy: Enable sysfs support for " Rakie Kim
2025-03-12 16:14   ` Gregory Price
2025-03-13  6:34     ` Rakie Kim
2025-03-13 16:40       ` Gregory Price
2025-03-14  6:35         ` Rakie Kim
2025-03-12  7:56 ` [PATCH v2 4/4] mm/mempolicy: Fix duplicate node addition in sysfs for " Rakie Kim
2025-03-12 15:04   ` Joshua Hahn
2025-03-13  6:34     ` Rakie Kim
2025-03-13 16:42   ` Gregory Price
2025-03-14  6:35     ` Rakie Kim
2025-03-12 15:49 ` [PATCH v2 1/4] mm/mempolicy: Fix memory leaks in mempolicy_sysfs_init() Gregory Price
2025-03-13  6:31   ` Rakie Kim
2025-03-13 15:52     ` Gregory Price
2025-03-14  7:44       ` Rakie Kim
2025-03-14 10:55       ` Jonathan Cameron
2025-03-14 13:42         ` Gregory Price
2025-03-17  8:24           ` Rakie Kim [this message]
2025-03-17  8:24         ` Rakie Kim

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=20250317082406.818-1-rakie.kim@sk.com \
    --to=rakie.kim@sk.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.j.williams@intel.com \
    --cc=gourry@gourry.net \
    --cc=honggyu.kim@sk.com \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kernel_team@skhynix.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --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