From patchwork Thu Nov 2 18:27:13 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: 13444118 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 93645C4167D for ; Thu, 2 Nov 2023 18:28:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DF6B8D00A4; Thu, 2 Nov 2023 14:28:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68E908D000F; Thu, 2 Nov 2023 14:28:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50D828D00A5; Thu, 2 Nov 2023 14:28:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 329CE8D000F for ; Thu, 2 Nov 2023 14:28:07 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 11A111A0007 for ; Thu, 2 Nov 2023 18:28:07 +0000 (UTC) X-FDA: 81413848614.18.48699DE Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by imf19.hostedemail.com (Postfix) with ESMTP id DED381A0011 for ; Thu, 2 Nov 2023 18:28:03 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=MMIYOm8V; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf19.hostedemail.com: domain of vishal.l.verma@intel.com designates 198.175.65.9 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=1698949684; 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=giF+Y68SjRCGves2YtIlJWVxMG9wjtiQrDvxA3pIbAQUCnMLVXR/dH/9Imo9Enlr/q9ktV 34YEdjLLL/VibZ5UXtbpx2JbnMb6sKABEsCLFCoRFnBlwMnUgmAQ0J4fI6Km3nydnh/uO+ SXvtXHdIasEyauE4RX9VheJkzpUmAz4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=MMIYOm8V; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf19.hostedemail.com: domain of vishal.l.verma@intel.com designates 198.175.65.9 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698949684; a=rsa-sha256; cv=none; b=yd6iRfFRFzlisDPrsgryd4fG5RpRNklYn0raLUBl+DhP2BV6PbA0MRaHolYxxgXkcCMWEr 4aSxc6dqg2Dib/sMoyxYSPbRrxUcrlZMJj/4oyYm4AO9L5gWA/r/PaqM17PboTjkRIV3X3 eBIy1rDMmYe0JRDkixJ/U+nD69Jh+z4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698949684; x=1730485684; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=hEIpF+H2iWRMoZGPvwzbL8B1g/l212Q9ts7SomwLAKg=; b=MMIYOm8VbWKrRSuIUJjAHE++gQbcQ6y7KChD5giSQsAbGU9wLJua4D1u D9E+F9IYNNHaLtxzhTbSO5XUTvZBHrpBMNi/PVmtrgBg0m+qoC7nGqt+X yokwY7NKviAS8+j1W/SL80DFkbEUqTfNLw2LHUXoBECo/8mPx+X5ymw6y L+vs51wbpufEiMeiBD8aF4uzTw5A3OmY3KQh/aqRkawlo3YusXpmu758B 0K5fBEkz0DHH5VbbQDFrrloasynDQ8S95P1qBTRtLDTdgc6Srto1IA1HI KhoojCFxEvWP0qtCfBcrNm9ULNCeuZyuAXixQiiUx1r0SatLDj/4nBWwh w==; X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="7421168" X-IronPort-AV: E=Sophos;i="6.03,272,1694761200"; d="scan'208";a="7421168" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2023 11:28:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="761359766" X-IronPort-AV: E=Sophos;i="6.03,272,1694761200"; d="scan'208";a="761359766" Received: from fmahinh-mobl.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.91.244]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2023 11:27:59 -0700 From: Vishal Verma Date: Thu, 02 Nov 2023 12:27:13 -0600 Subject: [PATCH v9 1/3] mm/memory_hotplug: replace an open-coded kmemdup() in add_memory_resource() MIME-Version: 1.0 Message-Id: <20231102-vv-kmem_memmap-v9-1-973d6b3a8f1a@intel.com> References: <20231102-vv-kmem_memmap-v9-0-973d6b3a8f1a@intel.com> In-Reply-To: <20231102-vv-kmem_memmap-v9-0-973d6b3a8f1a@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.13-dev-26615 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=owGbwMvMwCXGf25diOft7jLG02pJDKnOr/SE+M5/Pnlbz3jL1YSMg7Nu7bl+5ORtPldBhUmGz ROWXhW53FHKwiDGxSArpsjyd89HxmNy2/N5AhMcYeawMoEMYeDiFICJXLrIyPCL1zjxRFvOwtmm jQ3Wxd8WuLmzzEqWf/DYJ1tS/camoDRGhmlrip4sCDs402uF3nl5XoumU5fU++aHhK2znla0dZK 0KhMA X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: DED381A0011 X-Stat-Signature: jiy5ewsuqbt57cbd5n7rs8rjszrxmzhc X-Rspam-User: X-HE-Tag: 1698949683-926190 X-HE-Meta: U2FsdGVkX1/deX/wyCm8dRQcjRbKZMvfNzEkI9O98oZRSmpRcYhcE6+1Fs3wb1vCIVRQJ7mnF2NktNEG8N+u/Jq+WVGLMRE88qeIgcCKvOZusk8qW5xBK5Kp9Uxe9YX1hfrVowrOBElbnG8sa3xgQRw3hfvo/zm8ktCz5ur6ZBynyGfgxeiaCCaFhCl/oiIDAmKYiQHglAD8e2aw1/Iz/YxoFJNAdQA2QcjhByXGd2Ov14DTKJ9U8mFezBKRSFz3I2AI7ONP/WPF0W0zSQgmUYyUA/4BM01ElYQSmu+16IQQtpoHJ4S4E6xjH8/pDdgnF22vJ69mly0C5EwUZYaGKCIQYEPd0VcWYWTwqtI7nAcQI7D1aHDLnyRwMpJznXOYQ5f/o3aBsrp8qzcDYkeRFwquBf87XJcxdmcSjN0EdLny++ZAj4mxIaIR33RQXy7Em4qs7tmutxRy+ebKy5yLNxnicBHWSNF3drlMlDAli/fqzeij/7tQKhvnU5Ya2XSTBk9OgFQn9qdA7SzcIxeTkAzTznQI7oBTm/J478FPcQ3N6dbeLTqe7GsRAsU7FKB37/AcHQAcAXbt1RAsOz19cZRLdQeIgLXT/46OAn8zhOLVGB/GKGk0W8rtd2GBg+ALgYDWctByn3Bpgp9enmC3/QYQp9ukoZQkeBUBTZlvl59nb57lZ0OEHVxV+C2YWRcmqmqUTIxuKprivJzvgrpVWpUEDm35GeFHBk0nfBNdZ1EBKMCreazmY1RwhZe2+ZxSqmNHE2Hq/Y1d8cscxoCJcaMw/HH6Q3FEq6GIKO1hwC4HGwmYxSfSSQcwz2JmwVS6kTsoIjFiDLW8TnM/N+rJRUJrdpR66hatBziIRUqzqc/UajRb2gbaaXf8bvJQOEOk25nicuTQrlUY4DDqs56tk4zpSKm+O+Kap7mTACnax7IsdYo1IuSjv2Mo5SKviWdHcJiRBghcafdLtz/L8QD jkU5K2mk m+F6qTbT9BVHokJueRJMHOv0auMS10QJK/mMXhRv4sD2mzUKLBuL5zXsryiBEC0r/7TwjciVtV0e954qJanWPWbqXDjkMOvFdBgPzIGfMhQsFcNQ51xsL9LHDpqfOKq3uPEvibRxbD+2RNX96MdOFhDkxx8qF7ofs97EEh2UfmawP7xl8Rqj5nxGIQjxEy3RDPILXkNS65SJTr7JlZt5AOUziXMInUC3mnJ9zWCvWHT6MoIMlz3/2qsU3npQe3iZUjt0Y7fm7oHfVlQwWY1fm16TOISpcuh8O21eFCTVOIEPY3lG5saUlkyv3o/icR3MSl/rlKPrxOew0G9hjhzsFjlINTVJgv7YKjUFU 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 */ }