From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "Huang, Ying" <ying.huang@intel.com>
Cc: "david@redhat.com" <david@redhat.com>,
"Jiang, Dave" <dave.jiang@intel.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"osalvador@suse.de" <osalvador@suse.de>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Williams, Dan J" <dan.j.williams@intel.com>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"Jonathan.Cameron@Huawei.com" <Jonathan.Cameron@Huawei.com>,
"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>,
"aneesh.kumar@linux.ibm.com" <aneesh.kumar@linux.ibm.com>,
"Hocko, Michal" <mhocko@suse.com>,
"jmoyer@redhat.com" <jmoyer@redhat.com>,
"linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH v8 2/3] mm/memory_hotplug: split memmap_on_memory requests across memblocks
Date: Thu, 2 Nov 2023 01:27:24 +0000 [thread overview]
Message-ID: <725291282836a82d2ac9c62dd5d5d2eedfd24c0b.camel@intel.com> (raw)
In-Reply-To: <87edh93qfj.fsf@yhuang6-desk2.ccr.corp.intel.com>
On Thu, 2023-11-02 at 09:16 +0800, Huang, Ying wrote:
> Vishal Verma <vishal.l.verma@intel.com> writes:
>
[..]
> > +
> > +static int create_altmaps_and_memory_blocks(int nid, struct memory_group *group,
> > + u64 start, u64 size)
> > +{
> > + unsigned long memblock_size = memory_block_size_bytes();
> > + u64 cur_start;
> > + int ret;
> > +
> > + for (cur_start = start; cur_start < start + size;
> > + cur_start += memblock_size) {
> > + struct mhp_params params = { .pgprot =
> > + pgprot_mhp(PAGE_KERNEL) };
> > + struct vmem_altmap mhp_altmap = {
> > + .base_pfn = PHYS_PFN(cur_start),
> > + .end_pfn = PHYS_PFN(cur_start + memblock_size - 1),
> > + };
> > +
> > + mhp_altmap.free = memory_block_memmap_on_memory_pages();
> > + params.altmap = kmemdup(&mhp_altmap, sizeof(struct vmem_altmap),
> > + GFP_KERNEL);
> > + if (!params.altmap)
> > + return -ENOMEM;
>
> Use "goto out" here too?
Hm, yes I suppose we want to clean up previous iterations of the loop -
I'll make this change.
>
> > +
> > + /* call arch's memory hotadd */
> > + ret = arch_add_memory(nid, cur_start, memblock_size, ¶ms);
> > + if (ret < 0) {
> > + kfree(params.altmap);
> > + goto out;
> > + }
> > +
> > + /* create memory block devices after memory was added */
> > + ret = create_memory_block_devices(cur_start, memblock_size,
> > + params.altmap, group);
> > + if (ret) {
> > + arch_remove_memory(cur_start, memblock_size, NULL);
> > + kfree(params.altmap);
>
> How about move arch_remove_memory() and kree() to error path and use
> different label?
I thought of this, but it got slightly awkward because of the scope of
'params' (declared/allocated within the loop), just kfree'ing in that
scope looked cleaner..
next prev parent reply other threads:[~2023-11-02 1:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-01 22:51 [PATCH v8 0/3] mm: use memmap_on_memory semantics for dax/kmem Vishal Verma
2023-11-01 22:51 ` [PATCH v8 1/3] mm/memory_hotplug: replace an open-coded kmemdup() in add_memory_resource() Vishal Verma
2023-11-03 16:26 ` fan
2023-11-01 22:51 ` [PATCH v8 2/3] mm/memory_hotplug: split memmap_on_memory requests across memblocks Vishal Verma
2023-11-02 1:16 ` Huang, Ying
2023-11-02 1:27 ` Verma, Vishal L [this message]
2023-11-02 8:54 ` David Hildenbrand
2023-11-03 16:43 ` fan
2023-11-03 19:09 ` Verma, Vishal L
2023-11-01 22:51 ` [PATCH v8 3/3] dax/kmem: allow kmem to add memory with memmap_on_memory Vishal Verma
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=725291282836a82d2ac9c62dd5d5d2eedfd24c0b.camel@intel.com \
--to=vishal.l.verma@intel.com \
--cc=Jonathan.Cameron@Huawei.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dave.jiang@intel.com \
--cc=david@redhat.com \
--cc=jmoyer@redhat.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=nvdimm@lists.linux.dev \
--cc=osalvador@suse.de \
--cc=ying.huang@intel.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