From patchwork Tue Oct 17 05:44:55 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: 13424457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9364ACDB483 for ; Tue, 17 Oct 2023 05:45:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29DF38E0012; Tue, 17 Oct 2023 01:45:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 24DF68D00DE; Tue, 17 Oct 2023 01:45:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 052178E0012; Tue, 17 Oct 2023 01:45:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E30178D00DE for ; Tue, 17 Oct 2023 01:45:11 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B113B140ABA for ; Tue, 17 Oct 2023 05:45:11 +0000 (UTC) X-FDA: 81353865222.01.DA5F76D Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by imf14.hostedemail.com (Postfix) with ESMTP id 90123100008 for ; Tue, 17 Oct 2023 05:45:09 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SxR4OdxI; spf=pass (imf14.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697521509; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=buHYE9iI5wmsfHflMRRj91GyBS9pR6io2qcsf3d9XS4=; b=xLXFwaY2n/oadBiPxCfKJgDVcMSfjtkcha5ve2nAwBE3iaklb59GrS7KtdnU9EPb9dVpcm UT7WN0weohgbjcAAZGIKQLxHM4HvjMWP8Gss5cIZuVVibCJpOrkFPt4/yrYiGO7jQS78yp 4dQr417eWrtvBnT5S4NgbkVmW4HniPE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1697521509; a=rsa-sha256; cv=none; b=Hx+/WhZEcqiaQ6auiNhGZZr2vFlxBq8AUsjo2MjkK9DiD1EsMFTLELez58ecanRNNFI8kW JnlhhoMatyxz9gTA8oJ/3gXuH+stpOX95nZxjKbwwYS32sHktxIhdxKb9WOSeqoSqqZa9j 4tnHgqjT2VW35yMMD1dSsTEmiWjtyT0= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SxR4OdxI; spf=pass (imf14.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697521509; x=1729057509; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=jE1m85E7fxIhhpuuUBH8EL0PB4Icod+o0o4Ao4dEZ0w=; b=SxR4OdxIABAluttwyn08YisKCucoyIBopuYnyMS2UGyxsLDUcQwSyghk XJPwqaCkRuBxWYR8zV5iwAzgcchSIPRIuDyn0pvN78Go0qzyZ7Ubn3dBC aPdYIj+qvcUOQywVn/zCCaCIw0f7uSR+eFVaiq/IZE0oaTuqSeFrv00NO Vd+ktevARw9hwLsfxDDPgWSFrN7KnsdgF7DHkk4JT6zDl0E0FwpO+/RFh H91JHAzTJZ76PorEVrEKN77z55WCLtvzQozESXjKEhnqBSHwe/LvED4Fn 2+fJGJkTg1HA0doimKjNtmWYt/0iJWQGXM7K9kf3dBInf/2/W9bPezKY4 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="384580754" X-IronPort-AV: E=Sophos;i="6.03,231,1694761200"; d="scan'208";a="384580754" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 22:45:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="879694022" X-IronPort-AV: E=Sophos;i="6.03,231,1694761200"; d="scan'208";a="879694022" Received: from mjwirth-mobl.amr.corp.intel.com (HELO [192.168.1.200]) ([10.209.151.162]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 22:45:02 -0700 From: Vishal Verma Date: Mon, 16 Oct 2023 23:44:55 -0600 Subject: [PATCH v6 1/3] mm/memory_hotplug: replace an open-coded kmemdup() in add_memory_resource() MIME-Version: 1.0 Message-Id: <20231016-vv-kmem_memmap-v6-1-078f0d3c0371@intel.com> References: <20231016-vv-kmem_memmap-v6-0-078f0d3c0371@intel.com> In-Reply-To: <20231016-vv-kmem_memmap-v6-0-078f0d3c0371@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.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1311; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=jE1m85E7fxIhhpuuUBH8EL0PB4Icod+o0o4Ao4dEZ0w=; b=owGbwMvMwCXGf25diOft7jLG02pJDKl68jGKGn4bTxx1ebOqYNu6jh2vbXTSVs2Z/qryjOmFo KyTKpUmHaUsDGJcDLJiiix/93xkPCa3PZ8nMMERZg4rE8gQBi5OAZiIjgvDP8vfOR817jvMuqcp dK6592xXD8/HW2dSDdl9X3+bPs/AsZjhv5d+mfdFW7u/SxvW+W/I0nmkLHRYricuNbr191vtRba cTAA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspamd-Queue-Id: 90123100008 X-Rspam-User: X-Stat-Signature: 16gsxnxdtbii9xh4r93k7bupwudo5p3e X-Rspamd-Server: rspam03 X-HE-Tag: 1697521509-885177 X-HE-Meta: U2FsdGVkX1+C/T3+hFI1gg3LZjzYQUE6XfbCzUqd01y5hZfZQw+1wZ68/0GdKlnajotkdqT28PVzx1IA8AwFiv9yBp9KF5mjk62T+T4rEQqZJNLrUR/YKafodOsm49pc4d3M3GIsal7d+cwWC5POfb1wiwt79VNPTGnbE+rc07i/ib/SsqxD6Avgb50mK7qfwMWkmL2iMC6q/UBLUsiW36SfR+jjPnVVKiDKNbcgt2VcbIheNOQm+tS7pFhrHEaJlmmQbJ4bEbcMbXHSTDA7xV8GCJ+Q3GfPGpGbq0jv2b2PjQswoRusXx9B2lLBhBbb2qHe++/gYKRhO8F1Hk/JKXI8WpFmG/NEO8iR2cwV4xQtEpAHtwN5mQYfQmSKQanlc3ygJsY/UO+LMWDreL41iVeXaWUY5iVJcV2XkF7uofDqtIPrJi0cRfHpu4ubatehSabZB9H2ZaaHi7G8jTyibINaI9CMRV6Z28Cm4dUJoxXDWu5djjfUhN+totSl9AIVZQxLFM83aa29laDCo3YBFoKN6Uxu7mMaS7eSXlluwrxxdZ4ig+Y9dOQr2gIEjjSw+DoK+TI/acXa7Xp3/ba1dtrz1Iux1ycVuUYLImyqOKfvNiFmnMnNNsdhMuBH8t2AxplsTmb7su7hTVT07w5VQcjS7nFJ8wNjFy1URJk2U0OYv4aFArx/W8FznLkXZQwkmiUwVwb3tIZv9TBwJQvURyxGNTx6V/huj0ypS4spPYu5R9ylqNfhPE6HdR0LyhJwW9ngJX1+umWcXGhmlrJCJR8vj3K8+/atCuS7QAKXLLxMyIj6hap6Cw8qgSfVWIlg2e1w6dzN6RRnIRjYncoGGpdzsEQtg7+EYCgwJplcaoQxWBKHJLmT308vlXTbqFSNaPJv9UESkqylSLmX/PuOBs7jXh50GMj1ILNc6iQLs77EhhfX4LSXQofJzJf9MIXmuu6plq3HTOABx0TepJk T81JIxUL 40ZuZAhqTlOnl+qWq6VoMkjjN/BCijrRHVLY5Weu8fdVIE8lCwMYJBY7Tjxy4FwVJTf3nlxo7+U7wrHAbp3QYQWt5WWFZVXMtBhIL4gZJtloL19W9T2cAQLE4LYQRwNm8nC1ODrWI96XWVr/wk3g2nlwf9ytLOjusCcit10LjkcHPMoMjH1tJUq/K5C4G5EPwbkQ0MQGQu16RgTcbcBKtS/bP0SMFEp3xm9Uhgh6P7bTFy6ytX4sMgjvqLS1LCtyPI/6PpSBRqmV6qkojxQvVgJjJpfmQ4ew8cdiTjQS9kYO2jtPFWR9aZqZt92rF09Xb9Q2G0R6tToRQ99yZhWg7NZ1Qn6mhZ3wQM6Bl X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Signed-off-by: Vishal Verma Reviewed-by: David Hildenbrand --- 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 */ }