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: 161061 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp554293vqu; Thu, 2 Nov 2023 11:28:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEC/XFie7eAkGWBixrPaCob5x4rqiUy2U+/EIaW0uJ9ArbEKj9CHE+Q9UVMWuhar/UsEJYB X-Received: by 2002:a05:6a20:3d0e:b0:125:517c:4f18 with SMTP id y14-20020a056a203d0e00b00125517c4f18mr20705472pzi.8.1698949696820; Thu, 02 Nov 2023 11:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698949696; cv=none; d=google.com; s=arc-20160816; b=OMRgybPjnqwypbqbxwnf8G82vLH9T6KUhySBhqXnAh9JKQ+9mR+Vxvf7/xIEgQmNvh jeFdU3SGYo1GrjPKwHh2glOo3I/P4ucNgO6AJrwG1SL8UM/m5djqYVm/pLi/hG4cV6Uv 6jFX3KmXnco0MgJZpppoGfvxTsbTTmXDDhafSdUHrfpTDKMQqr1a1m48loZcSo+6Xx1D uQhY/UTp8+4U/64mvgR7ExI84ike4ppg2C0sU1eyH9haDZC+1OPlgF+tlYMbi8Pv9ygm JO7GM9DO6EydWDMoRIkAcyl9sZY5rOQh8ncoSbvymwvk8qNZXcHDb9X+0wWJ8xTf2V69 wI2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=zzMhYvJnkemfZMH9qCM5Cd7iPomAieby6YrwPqfCLLk=; fh=ZJyl7lGIgKsdPRNZ+hASCGqYu4kS00HsOWlg75WSZ6w=; b=RIp/BWTKU6A3QCCqJ5ThYTIiCiHxS27gtMG3q9lHM6wPLDGCkMzrKlm/yYbCgbxYAI vztDBc7BXZdLACyYpR+RoJsSVrK4/FDvAfOL32BbeeRz7YwbwHjDbOjjC97Pnnd22Rp6 bEz8xKRzxnX5kPziTFkpvTajvBlkzMCSHSJhQI8XZulTFTtTG+1o6R9w6gDnsDgCsPGN exvYd51J3xb0EiGAk/DdlHdKIbeAbSR50N1ykUtjDjBAbp6IWv9wFHHUMU8CdP8OvA4v wVtKZSAPbQkDVcxF2FrdPBH96EWA5VXBG+PE0hFglsY+IoetmIRUHXTCjeqpabxRsQgY mbZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Umo70Xex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ck16-20020a056a02091000b005b7c45b1f95si92633pgb.555.2023.11.02.11.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 11:28:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Umo70Xex; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9337F82C92FE; Thu, 2 Nov 2023 11:28:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377199AbjKBS2O (ORCPT + 35 others); Thu, 2 Nov 2023 14:28:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbjKBS2J (ORCPT ); Thu, 2 Nov 2023 14:28:09 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75F01134; Thu, 2 Nov 2023 11:28:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698949682; x=1730485682; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=hEIpF+H2iWRMoZGPvwzbL8B1g/l212Q9ts7SomwLAKg=; b=Umo70XexyrMZ3c36W6zxadSEbzdxHaBJWBRaQyzMY5LpArx3brJhI4Vz 89ulkM2NI7T13qs6wTTaZR5PkIW2Plew/e3iTv4lqrSxKWnEUOBouDMGQ KUHzothzzHMkjrA33K0LSudcjjPFlSWBGbvtbTLB8aqyrvxbXNpc7Qt7l 4Buwvh2/+OgrWfRIoIulHsl1CdAtQY60uC8SXC7EKduJ/+Fyr4uXFdLCH pmNbE8cJA9zV51TdNeiFDoTIIuSEVtBYnuFpBGGyhi8NrbHZxFz9ghUSC /TerfiLBw2SYcrVydayOcrNY7lnzyAXgS5551yNTy7CBjDiGmcUjJo7+R g==; X-IronPort-AV: E=McAfee;i="6600,9927,10882"; a="7421163" X-IronPort-AV: E=Sophos;i="6.03,272,1694761200"; d="scan'208";a="7421163" 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-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 02 Nov 2023 11:28:15 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781477877459837891 X-GMAIL-MSGID: 1781477877459837891 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 */ }