Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1627379iof; Tue, 7 Jun 2022 08:53:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9UNvm1Wo+Xuep6cgGsnby6Ou7NXkcKuDrdNWAUGz51ybtRC4Bkwq79rUrCc7o6CF1APcH X-Received: by 2002:a17:90a:5782:b0:1e8:7bd6:c7fd with SMTP id g2-20020a17090a578200b001e87bd6c7fdmr13155845pji.165.1654617228380; Tue, 07 Jun 2022 08:53:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654617228; cv=none; d=google.com; s=arc-20160816; b=GSUGAcTn0S3g4YpwZpaRUCTrZg9mWk72uwyJDJfMZl6tHCX2Lon8uSYXY2xWIVFVAd YoIuiSt/AwIscF605NO79vIWec9lprQYnRjQ9e64NFLFmL+SgqfHH1TrffT5VY70S60F XBcy1gkKvGAOOPNj7H+mY8tX0fNlUlVcmqFWQLLALpw6OIfRhhX/f+SisYTaOlp886Sj 1M1eYspS5QsNbRTST0RPmfwHLAIHvmSkY4d0z43PmR7+IzpRZkQN4Kr8YDWX7vfwCBC3 XIdtXIjn/Pobj9kZHvtxHQQgYI2YfwggfnPtVdGTscjZBBQAuVK6YmQbEs9T5ynCqbk3 zmgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/g+TAC9AohIKbBhCH909PGl0acKhOq6taPJcYK6MzTs=; b=0e3oNhC2ftIB7m0HNlDu8FX2LxlHfnsg+dU7pgTrWKz+lrlV7/O2LtCpshymBCutuz OgDkwiLQW39bRq3JS7jFVEA74AefV/YNps+Mg2KAPEHJv3OkhFCWoNzoostdWH057gA8 xmeDkVrEait1qAYYvtf6+5gnMpoT55Ngpxa8OLeFKhTEPXTC8WwdBnLm/vXHCCZMC4kY zsnjoQd7FhgJ5mcjvKwlcQYpzCg7zB0pTzce6+g+umoi6BmHHef2Qdwghw7IbJeG0oz7 bXlUzjGMkZCmePJCYScvTRyB9ckjd/TvR/RuxeCSaUzUWZzMsCOWDXcMhs741QAySLla q54w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n1-20020a17090a9f0100b001e0cf692b8dsi29280593pjp.80.2022.06.07.08.53.36; Tue, 07 Jun 2022 08:53:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239252AbiFGJRN (ORCPT + 99 others); Tue, 7 Jun 2022 05:17:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239187AbiFGJQ4 (ORCPT ); Tue, 7 Jun 2022 05:16:56 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83B91B82C7; Tue, 7 Jun 2022 02:16:54 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LHPpY6XYQzjdM9; Tue, 7 Jun 2022 17:15:33 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 7 Jun 2022 17:16:52 +0800 Received: from localhost.localdomain (10.175.112.125) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 7 Jun 2022 17:16:51 +0800 From: Wupeng Ma To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 6/6] efi: Disable mirror feature if kernelcore is not specified Date: Tue, 7 Jun 2022 17:38:05 +0800 Message-ID: <20220607093805.1354256-7-mawupeng1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220607093805.1354256-1-mawupeng1@huawei.com> References: <20220607093805.1354256-1-mawupeng1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Ma Wupeng If system have some mirrored memory and mirrored feature is not specified in boot parameter, the basic mirrored feature will be enabled and this will lead to the following situations: - memblock memory allocation prefers mirrored region. This may have some unexpected influence on numa affinity. - contiguous memory will be split into several parts if parts of them is mirrored memory via memblock_mark_mirror(). To fix this, variable mirrored_kernelcore will be checked before calling efi_find_mirror() which will enable basic mirrored feature and this variable is true if kernelcore=mirror is added in the kernel parameters. Signed-off-by: Ma Wupeng --- drivers/firmware/efi/efi.c | 3 +++ include/linux/mm.h | 2 ++ mm/page_alloc.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 79c232e07de7..8a5edcb0dd82 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -454,6 +454,9 @@ void __init efi_find_mirror(void) if (!efi_enabled(EFI_MEMMAP)) return; + if (!mirrored_kernelcore) + return; + for_each_efi_memory_desc(md) { unsigned long long start = md->phys_addr; unsigned long long size = md->num_pages << EFI_PAGE_SHIFT; diff --git a/include/linux/mm.h b/include/linux/mm.h index bc8f326be0ce..741ac7d022c3 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2540,6 +2540,8 @@ extern void get_pfn_range_for_nid(unsigned int nid, unsigned long *start_pfn, unsigned long *end_pfn); extern unsigned long find_min_pfn_with_active_regions(void); +extern bool mirrored_kernelcore; + #ifndef CONFIG_NUMA static inline int early_pfn_to_nid(unsigned long pfn) { diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e008a3df0485..cf6f70aba787 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -356,7 +356,7 @@ static unsigned long required_kernelcore_percent __initdata; static unsigned long required_movablecore __initdata; static unsigned long required_movablecore_percent __initdata; static unsigned long zone_movable_pfn[MAX_NUMNODES] __initdata; -static bool mirrored_kernelcore __meminitdata; +bool mirrored_kernelcore __meminitdata; /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from */ int movable_zone; -- 2.25.1