NVDIMM Device and Persistent Memory development
 help / color / mirror / Atom feed
From: Vishal Verma <vishal.l.verma@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	 David Hildenbrand <david@redhat.com>,
	Oscar Salvador <osalvador@suse.de>,
	 Dan Williams <dan.j.williams@intel.com>,
	Dave Jiang <dave.jiang@intel.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	 nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org,
	 Huang Ying <ying.huang@intel.com>,
	 Dave Hansen <dave.hansen@linux.intel.com>,
	 "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	 Michal Hocko <mhocko@suse.com>,
	 Jonathan Cameron <Jonathan.Cameron@Huawei.com>,
	 Jeff Moyer <jmoyer@redhat.com>,
	Vishal Verma <vishal.l.verma@intel.com>
Subject: [PATCH v8 1/3] mm/memory_hotplug: replace an open-coded kmemdup() in add_memory_resource()
Date: Wed, 01 Nov 2023 16:51:51 -0600	[thread overview]
Message-ID: <20231101-vv-kmem_memmap-v8-1-5e4a83331388@intel.com> (raw)
In-Reply-To: <20231101-vv-kmem_memmap-v8-0-5e4a83331388@intel.com>

A review of the memmap_on_memory modifications to add_memory_resource()
revealed an instance of an open-coded kmemdup(). Replace it with
kmemdup().

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Reported-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 mm/memory_hotplug.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index f8d3e7427e32..6be7de9efa55 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1439,11 +1439,11 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
 	if (mhp_flags & MHP_MEMMAP_ON_MEMORY) {
 		if (mhp_supports_memmap_on_memory(size)) {
 			mhp_altmap.free = memory_block_memmap_on_memory_pages();
-			params.altmap = kmalloc(sizeof(struct vmem_altmap), GFP_KERNEL);
+			params.altmap = kmemdup(&mhp_altmap,
+						sizeof(struct vmem_altmap),
+						GFP_KERNEL);
 			if (!params.altmap)
 				goto error;
-
-			memcpy(params.altmap, &mhp_altmap, sizeof(mhp_altmap));
 		}
 		/* fallback to not using altmap  */
 	}

-- 
2.41.0


  reply	other threads:[~2023-11-01 22:52 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 ` Vishal Verma [this message]
2023-11-03 16:26   ` [PATCH v8 1/3] mm/memory_hotplug: replace an open-coded kmemdup() in add_memory_resource() 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
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=20231101-vv-kmem_memmap-v8-1-5e4a83331388@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).