From patchwork Tue Nov 7 07:22:41 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: 13448005 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 5C7F2C4167B for ; Tue, 7 Nov 2023 07:23:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F09416B025E; Tue, 7 Nov 2023 02:23:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EB9256B025F; Tue, 7 Nov 2023 02:23:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D80EC6B0260; Tue, 7 Nov 2023 02:23:22 -0500 (EST) 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 C909C6B025E for ; Tue, 7 Nov 2023 02:23:22 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 95DF640962 for ; Tue, 7 Nov 2023 07:23:22 +0000 (UTC) X-FDA: 81430317444.26.9364EB1 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by imf04.hostedemail.com (Postfix) with ESMTP id 660EE40009 for ; Tue, 7 Nov 2023 07:23:19 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=f9Uzek3c; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf04.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.55.52.43 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=1699341799; 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=1G6e7866hFT/kF3Bw82Ml+XB+OH9nS4569IdHqqJRiE=; b=DHa5AYn+0RbTNmAlRQroNnxwUaxnfRcyJvgQVMW0TpXgYGVL7jc0KbegjfBllcW9/0SyD4 9f+3qREEdLN15eFB6lmTKLc+jmagx7BY7Yzu0W2F7eNHW4grYaHbS4vDY5p2ZixbvlqWFd a8eCjTsuhUD6/rIRjv/nfgl+Yaey9BY= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=f9Uzek3c; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf04.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699341799; a=rsa-sha256; cv=none; b=DhkQcr7lRLD4GRoUAJvvbM4Kwos9B3fl0OZenPE1q/9q9X9PVPyIFb/MoKmCqYXdX4XvlJ Le2O7SJqfMHCxe16ub58aWC4cgBmErBrruTcdkW/uH13S9mFlzotzbIcEuGW/sjXMPqKt9 oPHfxDoZJfIaQ674sHweVwO4AlKXL3g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699341799; x=1730877799; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=HZM5+hBI5lAioW4CqYpnGoymfhCO2XjBgbEz0jWhomc=; b=f9Uzek3cZB5SUfQ1QXtqAAjWh7aPds4IW9f571evrkt3audQDcnlleq4 t8UdlewZ9BAvbZSKagox6HJw8fp6xBha21IRb38Khoa/b0bgKFQDkEB3U 7grcmGy5uptGtveUzOV/b7AbKbaUIONmTiV6SHl1ni4MlPfQQHSOOHoq3 Myn53cuA1ygVWXSb4Etbz6KqDDoDrM+9KJSmvB8qCcASq6PVHzIi292RM gP20NYL1MnAfeRvR3/DD4GxUMBFmc325LO3ztTFyB5ckys+uGMZKkSn6l yzz5tVGpems8iyY2ISaYJdHffj0PFHKmvqhkwILyAYiHfxsomD9INjtzS g==; X-IronPort-AV: E=McAfee;i="6600,9927,10886"; a="475689639" X-IronPort-AV: E=Sophos;i="6.03,282,1694761200"; d="scan'208";a="475689639" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 23:23:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10886"; a="712477221" X-IronPort-AV: E=Sophos;i="6.03,282,1694761200"; d="scan'208";a="712477221" Received: from pengmich-mobl1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.96.119]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 23:23:15 -0800 From: Vishal Verma Date: Tue, 07 Nov 2023 00:22:41 -0700 Subject: [PATCH v10 1/3] mm/memory_hotplug: replace an open-coded kmemdup() in add_memory_resource() MIME-Version: 1.0 Message-Id: <20231107-vv-kmem_memmap-v10-1-1253ec050ed0@intel.com> References: <20231107-vv-kmem_memmap-v10-0-1253ec050ed0@intel.com> In-Reply-To: <20231107-vv-kmem_memmap-v10-0-1253ec050ed0@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 , Fan Ni X-Mailer: b4 0.13-dev-26615 X-Developer-Signature: v=1; a=openpgp-sha256; l=1434; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=HZM5+hBI5lAioW4CqYpnGoymfhCO2XjBgbEz0jWhomc=; b=owGbwMvMwCXGf25diOft7jLG02pJDKmeTx/u2KMpofzhr339p/4ulhoHJrGPXanCC7+ECHxYL X9h51uhjlIWBjEuBlkxRZa/ez4yHpPbns8TmOAIM4eVCWQIAxenAEzk3ByG/9mrWwovZp29Ejbz qvedaOUILZP3Ti4Hb8oszGwJtNc+ncnwz3Bv9Z3235/C8n54lB/yKZB+U/r7tc0txUARf/dFErv fcwMA X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspamd-Queue-Id: 660EE40009 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 5z615q1t9j68y9nr6ngd4eraegb98ia8 X-HE-Tag: 1699341799-838802 X-HE-Meta: U2FsdGVkX193wdFS4JnmIX1bfqjSShRKqOgR7tsOy2svwJNw65iicuLs2ynEFr9nZKNUODHA0a2VW+83ikQBFhDrmHuVrt+CXK/vk0WenGrxgtfywjYBSvTPxsK5fZFuOOzADl6FIhP/TVKPAGuDMoVjtPnWzWy4Bn87iWMQIuay+8mR6+6D+q81dBIB8PyvToGEJgojmPU8VLmAd3yqSNUTvloReONnHfpRhZUkF2AATIl+DTfydbKnkCBISUY1t1H+oaAbBxuMDHchnnKSNxYhKMnov/fxnpE3DyfY92HVOARYYI4R0Oh7Aa5J6tx2a3YRK/z9TyqStz/L7Ki4bVHrAZoGwJd3goSJBP9egmIjLoGZeQU9YTOHjoOB1I/Yj/FXnMlDOzBIkTBpcB7meKyeGMU/UdHiW9T0vRbYHPI2i2RBPg+pAb33wJ+MSP/Sux23E0PNDZr88dczb7HCJWsETNChM7bDXtiMw2NNl3H+pmleY1SQPihIOvz2s7unF852WVYszB8jx68BVOgZdz0aFPcYL71pIDj3ctNKDGAxU0lOKlNdjShjgNSyaw0GvDQM9df3N4o+tSYvxszFF8+hrM06B55tUlVcmA+TIMhQO3uvKHAPZ1oYPWRMXJJD/FfX3R43x+Nsh+I0uyKmuVn9kd7cQFU3QOiuk0rCcKtj5wpmJ2/J5x/phXVk4InJh+mwrIl46O+1OhrwsMQu7eNNGA/VU7B8L+VxHrjqeh21l5W7L8+JdnFOSwTBnBGzGNkNS3oI4cHT6qLI3lp8sF99fO3EZfzfLu/ZPOEXx+Jm58sPk9vBUQRbACCFqaA+jsBTHZ8M6QXeNuv+8oqLGhF8EOk+IqLotliVef4rA5diJUYSOqOFyuWJVGFSMSKJM9NxgcQPRyk0GLZZAdmVL+GpoLJUsWP/cXCsvlA7+4XSIeKOlLjNw8wcBbq52ZowlNgMn+VEAQkG2mlPLZ5 AsQcqd6c rmroJ0ogYfqF8tr/FgK/xQ+J1Xx1hQbmgUiUnoMkOz6amnv+A7LyVUTiPaMOWeFkQYuQGBZELJpkMriEEMtcErILqwBQr/Jie4Wf/ODdwuaFQaYuEu122r9Cret7MuJuJ7R076EekSiADQsXXwJxWFarFxweKjj1uNgpt5KXk4LpGPuKSzUeQ0cTmD/oqhXH1CnsUduFP+rriodCSYnH8bR39o9Z2bq0kxmq0gDGiSiDDEhY0eUogo4joCD66r2AR232BzsEyHU/HHIEZqa8gW438Yd1LBiQvkQ4/CCPhRrpvOYIfyOXtEMU0FuLuyKn/AZrWggAEzPjIhCV0xa4HXDXH7P5vaxZxIRiPOyL/AxO2sjaEtWuNYusI9Q== 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 Reviewed-by: Fan Ni Signed-off-by: Vishal Verma --- 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 ab41a511e20a..3ed48059a780 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1439,13 +1439,13 @@ 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) { ret = -ENOMEM; goto error; } - - memcpy(params.altmap, &mhp_altmap, sizeof(mhp_altmap)); } /* fallback to not using altmap */ }