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: 158320 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp285008vqb; Wed, 25 Oct 2023 15:45:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEDLq4BRZfABu8V4w7BTNjPzTiT8poHBpZPZfH3jtC0cP8T/03qoBrZLUNjkRfb8/I4G3N5 X-Received: by 2002:a81:77d7:0:b0:594:e148:3c42 with SMTP id s206-20020a8177d7000000b00594e1483c42mr16410585ywc.52.1698273956896; Wed, 25 Oct 2023 15:45:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698273956; cv=none; d=google.com; s=arc-20160816; b=TvLPPlsZdWxZSB+B2rwsyRlbdIgIqlbbuXY+nHMyy17fSUCiUxGRKLdbPqSgA61EeI PecywdfBFExRGQbzYlh0U8DqyPGd2ewAdodfFa9VEHgUBFuKEtXUIVY54QH//5P2V90l vLLYRN2Pt9bVyW/fhaNDbO56G7n25uzp+2i+WpAJcDjTW0Jx1utqmPi4HAA7or6Yb3N+ RQ/DWhKbvt2p5dYYJ0CGYCW0ZcasDUH60ykjBYEOXHMfL97cJIuR1r55iWVqptBxyQ2c uGvoFtj6SQQsGf/M9VNh6RY+cREVmiHpJnZi/N6BGbQQ2PGfJAoHkb6B11+Tr7VvjqoU WVyw== 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=DBpgz2+yP9eWXeqj7v03tMI/C2SGqzZGTsWxebnENMw+lQyX4z/YMkwpxtOzfJ7cqY CvmXVSK7spRaMbtQpw7Ms89QYrCKPc2+td3TO+/qPutUpGzQpUR9s7hfabsxxEOgd+BG puTcYHr0CZJJL6lQQgnvzvPN3YuOMjBQKOcPPf++/nI4+uGY3RJ7hegNasxAQ9t97Wve i88IN9D9Xx++ZWxHvnNslmP8ZAhVZnStc4ejliIvFxeEOOOlAoMlErA2B8hQRr4e6+OV dwyp7BSmIv7z0pMhmsU0QW5xwUvU9IECFRd2skOsWOowPbrqXONfZD3LaSA8aSCrZgz2 DspA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SxEtYgMs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id x124-20020a817c82000000b005a4e9a61e1esi12398791ywc.15.2023.10.25.15.45.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 15:45:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SxEtYgMs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id E7066809BE59; Wed, 25 Oct 2023 15:45:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230354AbjJYWpB (ORCPT + 25 others); Wed, 25 Oct 2023 18:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbjJYWo7 (ORCPT ); Wed, 25 Oct 2023 18:44:59 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E3BF115; Wed, 25 Oct 2023 15:44:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698273897; x=1729809897; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=hEIpF+H2iWRMoZGPvwzbL8B1g/l212Q9ts7SomwLAKg=; b=SxEtYgMsD9KTbdF5ikCENwakHS6oyr3QVhxOXjbzzn+Urg9gOBmXZubo cT+kaozpvkUaTghq3aE8iCRLHkoOfN5UJn60R+VoJEDS25WJa5cWwQ9l/ z68Ty3tlmdFfwlqP5lPJiJGDtvKnucOIrjF61eQelu8U84EQouh9qayvX pl6pnTJ96fK+eHY4eLAl1MKQd7l/4NDUT+xmDOftpsq5JrjwQ7RbB0zjv 5Wl3uPe8W8MFwH0XQ4HCTD0sArm+JJq3h0UvucNaEdfkp8iYZApwQcfCV 1GXpqU83fQTjGuqalljk5v9vurkaiXu1CwjMCfkWk3UIUzipg1hzmLHNG A==; X-IronPort-AV: E=McAfee;i="6600,9927,10874"; a="473650442" X-IronPort-AV: E=Sophos;i="6.03,252,1694761200"; d="scan'208";a="473650442" 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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Wed, 25 Oct 2023 15:45:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780769313074612228 X-GMAIL-MSGID: 1780769313074612228 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 */ }