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: 13443102 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 81F9EC4167B for ; Wed, 1 Nov 2023 22:52:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14B9D8D006B; Wed, 1 Nov 2023 18:52:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0FBFA8D0050; Wed, 1 Nov 2023 18:52:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE0D58D006B; Wed, 1 Nov 2023 18:52:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id DA9E78D0050 for ; Wed, 1 Nov 2023 18:52:30 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B281A1201C2 for ; Wed, 1 Nov 2023 22:52:30 +0000 (UTC) X-FDA: 81410886060.17.9F35634 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by imf21.hostedemail.com (Postfix) with ESMTP id 82DAD1C0014 for ; Wed, 1 Nov 2023 22:52:27 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=JuOv33mp; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf21.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.198.163.7 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698879147; 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=zzMhYvJnkemfZMH9qCM5Cd7iPomAieby6YrwPqfCLLk=; b=8jWwJWf6hbFmSoTqVxvteoq6TJ9r822ALrrSCRjCV78i5GsZATvpiwVkgx8RzCMJLGwjx0 m9tSrGZTZX9gYsQCTsUUyqyjEn0uOuL/WSngbo26ep/8yTFczfxP458afQVl7JRbFrdWEB 3UpSjWJOojeeKiNf7LRYksRYPMcfx5s= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=JuOv33mp; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf21.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.198.163.7 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698879147; a=rsa-sha256; cv=none; b=XzI24F6MyCcdDhWNOiAPY2GyVAZ3h1FEqUT2DM1mnjhAquNzMmqZXK5TFNlsdPA9Z/ioH+ C+eTQMyHcJ4eIFqIlFbLpld2SosjZdQizdgA6Haw3vxgpBqyX1UdfwWGc6yz5TwssQ4viO 3htzQ/+9zMjQWinasEsYHVpwOct43R4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698879148; x=1730415148; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=hEIpF+H2iWRMoZGPvwzbL8B1g/l212Q9ts7SomwLAKg=; b=JuOv33mp12TMEyn9LZD33kNvRy+jOKwSEQIHJY8it/LwPCqQ01K5efno 5h30Of4hUt9SlykY0s8MWpdsVy/4f1Vi4iIZD4OLJvZ/CjIW/YYQuYPlL Y17C/sbRvxlubQYR5BxZF+PVginMqTxjEnoKNapsQCDZ0PU2gKaVIZUJN CwhrW5JaJlUMugUJOK0cKWMVoRh2Gty0HifycpzbaBb3A8HKfqQ90ewSC 8o6kXiSkTedRW0rxWcpEFs3pcINz3LO0xnq0cnoG6iqhw/zrxWBLrPIf7 rx4mzhuzTWAEIM9+bsRyf2L5MUO9ajAhb+Yi3Dci0aQymlnfzSOd+UX6C Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="10133611" X-IronPort-AV: E=Sophos;i="6.03,269,1694761200"; d="scan'208";a="10133611" 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() 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 X-Rspamd-Queue-Id: 82DAD1C0014 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: gjmxpqhdw3by8jngigw6sx675zs9m6g9 X-HE-Tag: 1698879147-365581 X-HE-Meta: U2FsdGVkX18EC+EKxLRu58ENZLkrUtxZMdGqtHV1tymbQGpXRChke9H8dUpZw0f/OiuxmVmGKDMulKiBVHua7wKkTZI61MgZZt+fhb2ZmmCI0HdOd3te4hxdekq9RWt1rZirby1O1bm/KxF1dcDvCU500xwTE5ervnfykeHUqZhG/ZxCHV9T4VN5j+IjGCNenyGX6lFwGdOC7gy531J1gdJ/CcMfn4zQcKlQanntaU8Vt0RhR6NPdeajPZco+zO78gP010hGH1y/iIlXPQVxc1SgckF2agYW57Tn28JQxhoYno0aPLh4k4EBXi9UnPc9QvnG/FFBL01+edOC9RTSJ0Cv17Pxjm67D2TuZmQv6vKqbzl8Ac1Sep/uHIyrer9ZNo2MuInje/Ju8HUCPKeA4W0WMhrQVG/7H1U4qe/zMX9q2Ap2oMxwVhWcdajG11s0JZNroD8hco67nP8cmiOUfPCwYq5OvoBT/1iO0lcsEQbFu6dMYgRFo0n271EQubSaVViJiBi2K+K1/TVip+vSuAcN5P+T+ZmKcm7tBO1fBe0Zji/Aqw/OTy90ud2gOLaAEisTRQX7bCdcfA0bbxvOhpXbCzhXJHe6xyGjLY8tFBwKj9vE2j4WlAIM6fukwQn0bs1/sTGiLs8nxwobKPj2bhD49AkTPfjNbtJETqKo/ebStzxCpJKNl3uZwudqNiA0urvd15hxjsaWdNG3yjIIQRo6T7BHwNWXpZjMC0poimA0bw0GodFVfOOiRw5PuimRJ/hAy9L2579lxlflB3QYyuHgkmzF/PbIfD5WTT18XW+4O3B6bwi7kCfwT6Nr7dkydkf/85FJm1+03n7yguo7RvTF/Kp2h0lLzjKzrOJhYK1+9JD+9Zs9ajWpj+XFnAsSPeJZ0vQUtZLU4GAJDEzPFxGdR4+Qt1NcHiTrfWuJSQzrzAL4MQ/f2TaESBmzD8cR546nKPLipQJ1ZJ5PBWR 4I05Sjbp Iw2H1W0IrVQjj8nwvUJnCqpA/eTVOaeYJ5hrcJDL1+NjLdgGXpDvGtPHQPQ13pHoG+5aRFb9ySN6p5GNYkY9gT0mIA5uxoq0yjP34cTRs7R9h6EJioeqNoeWXpZvUsFlxuwnmHLQRJI1Bz57rIzYlxe0NL9td9KXGim3SMoCQL3iewnkokLhpnvaAur/nCTsgTqE72Ase8yMb+5AHzpblJyBWrBqNI9VRWCk/PfwJPhDyJmtovMSkDs8pkrwuTYO+5azAVKc4FIQ88SeCZICKuTzskNDVv5PGn5rIxu++KAHHNu5YhEa9ubInSs4m6lyXOJCIPmy0jImpucUc8eSuyz7FZW+c5+5wYtss 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: List-Subscribe: List-Unsubscribe: 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 */ }