From patchwork Wed Nov 1 22:51:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 13443104 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B9FD101EF for ; Wed, 1 Nov 2023 22:52:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="k96IOm0g" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698879146; x=1730415146; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=hEIpF+H2iWRMoZGPvwzbL8B1g/l212Q9ts7SomwLAKg=; b=k96IOm0gxpCRgPkpCUU2oQ01qPYQfjw6vAyAs34+kii6Oh2kPqRJJ5/C l6QaDCIJOQdO7Rhysd6h7V0mB+OW5WsmkjVeXDUkEGKH2sOF0RjS1wkPA cbVhqn4zambabNqzpptB4JeA4Q3jpRReBKSIhlYMGhBL6g8sYfX3rbj4D 9q2hN22CP75uM/IgSmXY6wvKeJcddjLJNpxAJUCacvvDt9SX1zZdZlmyy bVF9TRIDho5fkHSoJw6PLNzjy5tJm2v1Zs5TOv45vDGnljA3TX57COcOQ AmQdg7ERUkyvwkumTlOY5/pmeAuB2QBx9OTUz3xioiaDRwXMUp9pHQ6CJ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="10133610" X-IronPort-AV: E=Sophos;i="6.03,269,1694761200"; d="scan'208";a="10133610" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 15:52:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="796033557" X-IronPort-AV: E=Sophos;i="6.03,269,1694761200"; d="scan'208";a="796033557" Received: from dgopalan-mobl.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.98.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 15:52:22 -0700 From: Vishal Verma Date: Wed, 01 Nov 2023 16:51:51 -0600 Subject: [PATCH v8 1/3] mm/memory_hotplug: replace an open-coded kmemdup() in add_memory_resource() Precedence: bulk X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231101-vv-kmem_memmap-v8-1-5e4a83331388@intel.com> References: <20231101-vv-kmem_memmap-v8-0-5e4a83331388@intel.com> In-Reply-To: <20231101-vv-kmem_memmap-v8-0-5e4a83331388@intel.com> To: Andrew Morton , David Hildenbrand , Oscar Salvador , Dan Williams , Dave Jiang Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, Huang Ying , Dave Hansen , "Aneesh Kumar K.V" , Michal Hocko , Jonathan Cameron , Jeff Moyer , Vishal Verma X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1362; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=hEIpF+H2iWRMoZGPvwzbL8B1g/l212Q9ts7SomwLAKg=; b=owGbwMvMwCXGf25diOft7jLG02pJDKlO15aG/1KINNWN2ie9r25S157UB9UxN8TOaWyxuKfd8 6hBxsyuo5SFQYyLQVZMkeXvno+Mx+S25/MEJjjCzGFlAhnCwMUpABNhecXwV47p9dUwJv3W+3aV IXtYrjVW8cQ+C77ucvhiidbLafbvFjEyPJQoOd3km/jN6fxxuX8PJ6VO8QkrNSvJWn/FSjhXzS6 dBQA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF 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 Cc: David Hildenbrand Cc: Michal Hocko Cc: Oscar Salvador Cc: Dan Williams Reported-by: Dan Williams Reviewed-by: David Hildenbrand Signed-off-by: Vishal Verma Reviewed-by: Fan Ni --- 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 */ }