Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1253378iog; Tue, 14 Jun 2022 02:22:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uAcgVc3NEI9/S0fYWtlvj+/7OM+Owlvhe72V97sJbNqL+oRqTWs5Dki7EA8xoY+2d6QzWA X-Received: by 2002:a17:902:7783:b0:167:8245:ea04 with SMTP id o3-20020a170902778300b001678245ea04mr3341541pll.95.1655198553902; Tue, 14 Jun 2022 02:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655198553; cv=none; d=google.com; s=arc-20160816; b=e6bF4AHhdHKIs3wA7ceD5OZImWn81rJFTIi4XwsLT/Xl7Fr8wLJlBHzLeniW2gXiOX PIhaWIAUFDu0T3JRz8LLYbM/qXYfUOlom74xO+aPtfIiaIb21FY9poLEbBcrE5fGI1E4 Dlr23UkOPLqsf7Jz5ajovfWndKx3/u0Z1qyMxw5zbFelnQ57x8p1U30NHUA9RPoV+rJD om3CHbT9KFGpYuEV/5XzmtlgwqSxs/f4/d3LzS54aMJPnF8j6Ohj2AnDp3Jpz4aHvyFZ 529LsVTeJrN451/qRAKamOgkxlVD1mbl2SoUZ6rgiQHGW9J7rM8b8Jf3/+nCWRxjt2i5 7vfA== 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=0gh3Tvf/IDDyH1J2LdcxLpl/1vtCrWmXoR61g1HEvp0=; b=Hr9uSLg0ZdwuTMOMRbeWX/8dMitLOBhGrqtsavaJ0mnQ14mrHILm9B7d1BPXgCydNK 2VBosABS+wXeGXnKwU3foTgDuzpvVFEpSq0TzstQnpQvnUyhaXSJcRzg7VGK5Ui08uDB G9M5owb1HSRh/9NUc8eIv4IPS734jfgBPbsxgx8oN1yx5Q5GX6bsxmEj8Jc6EHmZYbh6 ZiUtMLpP69QPThpaYDcT+3TuGVxmMqqvmaPzdovA2itnbiyg7kmPfu0aWmq6aYkWsbTn RODK4mejOWR9qwVM6jAIs0v7FcZr9GIA8zh3zh+AEZdhtFwq+1sd9pHyCJIzDPC4cjeD d0ww== 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 j11-20020a63230b000000b004019a45b5easi12751556pgj.747.2022.06.14.02.22.22; Tue, 14 Jun 2022 02:22:33 -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 S230312AbiFNJBx (ORCPT + 99 others); Tue, 14 Jun 2022 05:01:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239852AbiFNJBs (ORCPT ); Tue, 14 Jun 2022 05:01:48 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FAD32F00B; Tue, 14 Jun 2022 02:01:47 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LMj783mwBzgZDS; Tue, 14 Jun 2022 16:59:48 +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, 14 Jun 2022 17:00:43 +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, 14 Jun 2022 17:00:41 +0800 From: Wupeng Ma To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 5/5] memblock: Disable mirror feature if kernelcore is not specified Date: Tue, 14 Jun 2022 17:21:56 +0800 Message-ID: <20220614092156.1972846-6-mawupeng1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220614092156.1972846-1-mawupeng1@huawei.com> References: <20220614092156.1972846-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: dggems701-chm.china.huawei.com (10.3.19.178) 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 in memblock_mark_mirror(). Mark mirrored memory with flag MEMBLOCK_MIRROR iff kernelcore=mirror is added in the kernel parameters. Signed-off-by: Ma Wupeng Acked-by: Ard Biesheuvel --- mm/internal.h | 2 ++ mm/memblock.c | 3 +++ mm/page_alloc.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/internal.h b/mm/internal.h index c0f8fbe0445b..ddd2d6a46f1b 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -861,4 +861,6 @@ struct folio *try_grab_folio(struct page *page, int refs, unsigned int flags); DECLARE_PER_CPU(struct per_cpu_nodestat, boot_nodestats); +extern bool mirrored_kernelcore; + #endif /* __MM_INTERNAL_H */ diff --git a/mm/memblock.c b/mm/memblock.c index b1d2a0009733..a9f18b988b7f 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -924,6 +924,9 @@ int __init_memblock memblock_clear_hotplug(phys_addr_t base, phys_addr_t size) */ int __init_memblock memblock_mark_mirror(phys_addr_t base, phys_addr_t size) { + if (!mirrored_kernelcore) + return 0; + system_has_some_mirror = true; return memblock_setclr_flag(base, size, 1, MEMBLOCK_MIRROR); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e008a3df0485..10dc35ec7479 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 __initdata_memblock; /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from */ int movable_zone; -- 2.25.1