From patchwork Wed Oct 25 22:44:33 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: 13436900 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 2CC4BC25B6B for ; Wed, 25 Oct 2023 22:45:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43EF58D001A; Wed, 25 Oct 2023 18:45:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C9308D0001; Wed, 25 Oct 2023 18:45:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21A868D001A; Wed, 25 Oct 2023 18:45:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 108EF8D0001 for ; Wed, 25 Oct 2023 18:45:02 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D3C44C0ADF for ; Wed, 25 Oct 2023 22:45:01 +0000 (UTC) X-FDA: 81385465602.27.4F55285 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by imf08.hostedemail.com (Postfix) with ESMTP id 917FC160002 for ; Wed, 25 Oct 2023 22:44:57 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=DvzSdQsS; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.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=1698273898; 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=a2enqsYJVCWNWE4iRYXEfyr6VVQ1Bpa82iMSkb0e7UnUxjrpjt7aKAw7AAOcM92brg17Dx TlxhW0KPRtilxbFKbr1fr1/WpCBTtH2tXMZ1JmAq1dGWjoW/VSErQQC3Jx87JZUydDe2WU iz4KM3qqGN0qDm8WrafVBL+rNe8J5Ms= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=DvzSdQsS; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.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=1698273898; a=rsa-sha256; cv=none; b=Vzf2s9l7nW0m5+2fkJ+grw0WeKSVjDUQxVsfaD2iC6oHVDmG3N0u/GYolJV0teJIgASEFn +IlpmLALUmn9TB32xQc2tzFLooG2lKHvlY//d973nOhYti6Pk2I9ci6Vs7kckaAU9ZyKY8 MTXU1SrPFiFQAfN8xozw6BYKju1BkFQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698273898; x=1729809898; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=hEIpF+H2iWRMoZGPvwzbL8B1g/l212Q9ts7SomwLAKg=; b=DvzSdQsSkKdbNpsBoIi1ZKuZ995Iov82BJgNBkWgTeM5sFvPyf/NJeE9 MuqQkns76sDndTBN3trvbLOYVMbrMeBFj416m8l5StbdgyL2MKS72nMMv iQ5YE6WEYza0kI+4N9ZS4k8y/+Ej/YCMSwudZ1Zc2dM7tyfPgoqyGFZEw ugfxzxD0+L2S7ErEIvhmrjDQ2TqhpSjC1LU7xtbjpDiOLf2VtzUplN1BI eRhJ9fa+y7u10/zVixq7TNHh2nYeEyvP4OlIcKopSTo2brTRwK2iJIiRz j9J26kFYHpLwXGERDwYUe+oYRuRrsA02xoHEjtRUS5BNOjZRrj1VhvR+w A==; X-IronPort-AV: E=McAfee;i="6600,9927,10874"; a="473650441" X-IronPort-AV: E=Sophos;i="6.03,252,1694761200"; d="scan'208";a="473650441" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 15:44:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10874"; a="708846721" X-IronPort-AV: E=Sophos;i="6.03,252,1694761200"; d="scan'208";a="708846721" Received: from nmckubrx-mobl.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.68.190]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 15:44:50 -0700 From: Vishal Verma Date: Wed, 25 Oct 2023 16:44:33 -0600 Subject: [PATCH v7 1/3] mm/memory_hotplug: replace an open-coded kmemdup() in add_memory_resource() MIME-Version: 1.0 Message-Id: <20231025-vv-kmem_memmap-v7-1-4a76d7652df5@intel.com> References: <20231025-vv-kmem_memmap-v7-0-4a76d7652df5@intel.com> In-Reply-To: <20231025-vv-kmem_memmap-v7-0-4a76d7652df5@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=owGbwMvMwCXGf25diOft7jLG02pJDKmWsxJWmYp2Tak1DxJWVlQW1jWL/jDzy6c113tEP+XOW HL4TWZMRykLgxgXg6yYIsvfPR8Zj8ltz+cJTHCEmcPKBDKEgYtTACZy/Scjwx6zeNcOMf0D/k92 FS0SOXguPq7sz44vulelEq7dPf/3RxIjw4ZdJntVZnX5FnH6XT+YkMdUWZv4zkbC44169ozqlvo cbgA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspamd-Queue-Id: 917FC160002 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: xsppbyicxongap77wb67teowgcwfrixh X-HE-Tag: 1698273897-443902 X-HE-Meta: U2FsdGVkX19WA2Qjwx/xqVT4OJVWpLj1Wi8+kR4+HN2nPKt68zNW8SCJCnJsBj3aXe8Y+6RsT+rngvdrqO7paGDfaVoCeyFOjOIXHZTFEKZV9KU6GtMSVbuHt/+HZ0UYppLDavu44FmKehnI/gB2jRpKHuTNyv+Tg0j5Qgm1np2LztDhtjwRB12B2asS30HaOU/OflEZVY8SYcs3D6lAJCBhg7XlzRIAb9PYf6Gw9hwKJ+vi2aIKl5VymmvVlr4wse2l/Y//WAtxRvdlSkyRamN+R5SLPHrWPWEe+yCBIonr/pBcxq6ot4xG3dekh0UJJVEf80Rc06k1hLOmPsnSi+zC6oicyb01hEmOhjCBqeIlmvMKhTzhL2ssCcCGpMHw4NG4YAL3r+nr10vG/Ea0b3Vmzul5VDOhzNaSjL41ONeGwxoyLfS/efYTu1hsXGz2V3gUwZDdGmZpbLk5WO6uGeaBN6Bn1zr36JJTPYwf1nNqtxF8f4CMsS82qDQPOYEqrNsjhks0ynu7xBE4X2y3Xse+FlytCKfcRPzR0VjYOh6UO6oHDMLQiz47S/VqHOzgkyO7h2JMhFyEBufmoXd/FHJSVTNJSCafaVc2xvNttzVY7NJ38njLNMeSwA+RDUL/5V1SJaRQHMTqaZuSgoO8fiRL848OmspbY9p38xwjiVzymvdF8h/D9Uyay8hR1XVcs40zIf4MJ86px/BaGn0kq6u2EAaqG9CEadqL2Qb5ap04gy4t+ChU5olXcDCtDrLqaU3GMdyxywQzcgQvjtByTsgSiuodgGNfoiIWLA+awAc7bzcfgl6tDzQgo99wsAR8QIsZ/CU/82RcUo10OPL1zXbXVSGq4bI4M+qqlwCP2xYzf1xCYKfMVzuPuvjD54Nk01eBTGakM1pd5ZRMCy2chhsQUlK3U9eSL2AEIj5LOs4xLq/AX/rhn5TcCxItRPMyaYwFogr/Ef/pYVMYgl5 qqSSAeXh g5zhuFkJ0q9SSh6UJB/wlZzAsx2bkjJj8mHYuEQJI+8fqqR9/QCHHONyCR9N1kShC2XzBoeGtm8ioxN4H5VwPmBUJAUYlp0/TEis4WV8IVGLXNBdqqZIPIDOEHy4K18U2NgZxkXllW551/nm6velmSOj+Fng/kp17zOQOqDLdWzCCFbsIkfxIBXwq9iZnF+0WdetNkesdS0c19GVtGXxjspvir6ucB43kyplWXmY3JN21FfgjFZv3f5zb0gNgHkVTviBDOXGqXDlqh+m6T6ddo5wFI1Eg6MsoanrF5UAvQPwDM414ZCRn3caR6RIRo79akn2nNJzr4kMGsqRPEV23tJOLoUVIjKZ4czjZ 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 --- 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 */ }