From patchwork Tue Oct 17 05:44:55 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: 153917 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3917612vqb; Mon, 16 Oct 2023 22:46:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvDXex2ZP2mOx8YY3O+nzNSv8dHPki0cmZ9c4mvfxLeQlIFlfs3lJSBG/cDYG9wPA8wx/y X-Received: by 2002:a17:90b:4c11:b0:27d:193f:2130 with SMTP id na17-20020a17090b4c1100b0027d193f2130mr1349315pjb.3.1697521586438; Mon, 16 Oct 2023 22:46:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697521586; cv=none; d=google.com; s=arc-20160816; b=jHBTPQRnyfPKBEAjZAt5wRYvgmbzeyLCUCf0CCHpuTorPydp1WpQKlP0w4ff5Ydh1m ZuLqUvurJYUNKmIgoaiv58z9Ns+8szTDI8Jb7M4w5VhdbJM0vct/NUphKT1YE+MwTKMM bjA/qLmihP+qO9Wc+0Be0+b5G9QIBZ5UU5jql8d7Y/MVwUEsuhSLsPv88A89TOovYjoN ke0Q8kMihiF+PLYTjhieWgL1ZPIFhpDnSB0AEQYFcKa0NlrIllbJkM2ymbhdCVRwyYtO jcy9JTQA5DOCS/q22ysd1+1F8+7Xq+P6BVUmGvGW7EghQcqbPadLwBdVhK9dQiafCbd0 ijGg== 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=buHYE9iI5wmsfHflMRRj91GyBS9pR6io2qcsf3d9XS4=; fh=ZJyl7lGIgKsdPRNZ+hASCGqYu4kS00HsOWlg75WSZ6w=; b=MGRlyCEKgWqn7HmBVqPTkAVmkbKBAysXdFx606nhysE16Oueyoy0uEua3gNQajB0wU tfzWUxkPeeAy/IyST1bOBGXf2hHS4D3Ckw1EEfFgc8xjwVUl5+UNG82o/G2P8HxnlUWL tPyKzUTiBvmKIa56nv+FPaHifr3tnu5MV8ZB4OQ5IgpImHhsJoQVMxf4l1qVm6fU4QlC wDiUgw5dL1FB+i7kxgz3oPsKUVk1I2ndvIVZ5+vYJtCI5f8xjejHVG3Fe6SgwokhBNeK i3MwRT5lnpysKvFzAayvRkP8SvM1YqiRXBIVX5/KZpmYUM/uAZT54mFkPT/LTaELk1FE eDMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Pqek7vR5; 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 er23-20020a17090af6d700b00268178130a2si926321pjb.60.2023.10.16.22.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 22:46:26 -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=Pqek7vR5; 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 D61D0807479F; Mon, 16 Oct 2023 22:45:23 -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 S230343AbjJQFpO (ORCPT + 19 others); Tue, 17 Oct 2023 01:45:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234451AbjJQFpJ (ORCPT ); Tue, 17 Oct 2023 01:45:09 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC643EA; Mon, 16 Oct 2023 22:45:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697521507; x=1729057507; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=jE1m85E7fxIhhpuuUBH8EL0PB4Icod+o0o4Ao4dEZ0w=; b=Pqek7vR5tmoaaLHRZmec/CVgU/g6HX/alx5ZNRDihOsG35aD+vC+e2fA t0x8IzMpuI6vvAq6IIF6Vn8PMfE4dO1+YL1wONYFO7dqf8FWgWYgCt0GB o5DYd2WUj+rgtrGyx6yiNz+8BqWPtF9+lDUSGZjEqDKFrD9S2q1c7FlwM R0z0VbyooV+LwTf4Z+wYj+DvpKsjYG3T3q9BnKXI1ZAnC/3AaorZ9e5sF gnAPm7Vm5KVwp5NPJPKsxQGN9fSerA6X2ihWLmj7YOOyGoIl9267xGA2/ 7KEwX0QmQaeuSsJTyamtQX5Qm15rkn817zBgJ8eEGbqcda0AkeZPIuf4R Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="384580751" X-IronPort-AV: E=Sophos;i="6.03,231,1694761200"; d="scan'208";a="384580751" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 22:45:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="879694022" X-IronPort-AV: E=Sophos;i="6.03,231,1694761200"; d="scan'208";a="879694022" Received: from mjwirth-mobl.amr.corp.intel.com (HELO [192.168.1.200]) ([10.209.151.162]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 22:45:02 -0700 From: Vishal Verma Date: Mon, 16 Oct 2023 23:44:55 -0600 Subject: [PATCH v6 1/3] mm/memory_hotplug: replace an open-coded kmemdup() in add_memory_resource() MIME-Version: 1.0 Message-Id: <20231016-vv-kmem_memmap-v6-1-078f0d3c0371@intel.com> References: <20231016-vv-kmem_memmap-v6-0-078f0d3c0371@intel.com> In-Reply-To: <20231016-vv-kmem_memmap-v6-0-078f0d3c0371@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.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1311; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=jE1m85E7fxIhhpuuUBH8EL0PB4Icod+o0o4Ao4dEZ0w=; b=owGbwMvMwCXGf25diOft7jLG02pJDKl68jGKGn4bTxx1ebOqYNu6jh2vbXTSVs2Z/qryjOmFo KyTKpUmHaUsDGJcDLJiiix/93xkPCa3PZ8nMMERZg4rE8gQBi5OAZiIjgvDP8vfOR817jvMuqcp dK6592xXD8/HW2dSDdl9X3+bPs/AsZjhv5d+mfdFW7u/SxvW+W/I0nmkLHRYricuNbr191vtRba cTAA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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]); Mon, 16 Oct 2023 22:45:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779980394834185066 X-GMAIL-MSGID: 1779980394834185066 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 Signed-off-by: Vishal Verma Reviewed-by: David Hildenbrand --- 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 */ }