Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1356486iog; Tue, 14 Jun 2022 04:39:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpN2llpuHTB8wWwSTcwBsFsnPYZpM5gRlPefvJLWCVm5WNqF+lu88/+yzhCPUBWNpvQGWD X-Received: by 2002:a05:6402:400b:b0:42d:c902:6c75 with SMTP id d11-20020a056402400b00b0042dc9026c75mr5659852eda.32.1655206744628; Tue, 14 Jun 2022 04:39:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655206744; cv=none; d=google.com; s=arc-20160816; b=yynC7qwnsX/GGmXPuKFXeOKJq/W7MCnOptnU8P3I1MKyZXg+hYTgdimlA/zwqc9+ZR oSpgRdhAQ5znclMtWWNShGNgO1PkQ7CPm42M0Te22VEj/wolsERWbANnqY4iJDfPzm8l MDXbmAeGLlFi5Oq5FQz7f4v9ncM7WJmgxh/Q0ZRt2WKSh3ZAITHABXl8aYCL3fjhCfVs DD1WPZsmcU8GGvEEONjygMUzkvCIc6ZaKvE1uGg1pC5JEXZ6Ao7PDD8v8G90anfUKFmY KSIep2VJQ7RBRIaoC3MHn30Wx4mQsZS/X/jam/KzSgi/EtpYkr2pHG0L/QlWxaX4kKaZ O0Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IiQIaQMhxL76RBZHsmcLreZUSDHLka20T5mMLLN/xgk=; b=UCw0v9p6Gq+0VyI3J1ggjXFdfvdl9T9Tz4VIy213sxNbzu1EsZ0muibUHHsYjoc1s7 ji+9Zvq7xhAXHQk/IzypVyFEjz1+OcQUpuQEVOBdaTdjKO5zQrw/jbrIL7OlPDRXE4z1 Ed9TQCUPEGch7qBc602IPNBlo/5XPcBQgwBNJTXzWQbudgulKjkNj53MaB73rA/rGZcW YY57hm4fIUxoduNN6OvUbAod+TAv9OrGi64vsC1bBlRDf5TR3rNOLAjtFe6SBXiebBSV F3BbxU2betDn/G4l8m2z1RNX9Ft1O9V09l0EtZjZPn7JmeVd1AgF4xcRUGxxeLGPeGQH 4paQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="NPjGZ/rY"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq2-20020a1709073f0200b00718d033df13si4546043ejc.678.2022.06.14.04.38.39; Tue, 14 Jun 2022 04:39:04 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="NPjGZ/rY"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355700AbiFNKuZ (ORCPT + 99 others); Tue, 14 Jun 2022 06:50:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355571AbiFNKuW (ORCPT ); Tue, 14 Jun 2022 06:50:22 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CFCBA48E6C for ; Tue, 14 Jun 2022 03:50:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655203821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IiQIaQMhxL76RBZHsmcLreZUSDHLka20T5mMLLN/xgk=; b=NPjGZ/rYFVRofTShHHLAscsjL2Vsp1A1NKAsGgsgdPUCbzzcNopBwan7psR3ITsABlg4vo Gal6fo4tOp4/n7tMbH/hbTrxJ1s1T3zXrAPoXuHEaxvlU/TwuLxtN95V1wrDJbbhOVor2t hnSpQOFdOIS9d4JPHu+p6jGcW8BPYU8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-352-DhirNWZtMFiMrb8YeOnp2g-1; Tue, 14 Jun 2022 06:50:15 -0400 X-MC-Unique: DhirNWZtMFiMrb8YeOnp2g-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 78950299E755; Tue, 14 Jun 2022 10:50:14 +0000 (UTC) Received: from localhost (ovpn-12-211.pek2.redhat.com [10.72.12.211]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE2A5416164; Tue, 14 Jun 2022 10:50:12 +0000 (UTC) Date: Tue, 14 Jun 2022 18:50:09 +0800 From: Baoquan He To: Ard Biesheuvel Cc: Wupeng Ma , Jonathan Corbet , Will Deacon , Catalin Marinas , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , X86 ML , "H. Peter Anvin" , Darren Hart , Andy Shevchenko , Mike Rapoport , Andrew Morton , Paul Walmsley , Palmer Dabbelt , Albert Ou , "Paul E. McKenney" , Kees Cook , songmuchun@bytedance.com, Randy Dunlap , damien.lemoal@opensource.wdc.com, Stephen Boyd , Wei Liu , Robin Murphy , David Hildenbrand , Anshuman Khandual , Zhen Lei , Kefeng Wang , gpiccoli@igalia.com, Huacai Chen , Geert Uytterhoeven , vijayb@linux.microsoft.com, Linux Doc Mailing List , Linux Kernel Mailing List , Linux ARM , linux-efi , platform-driver-x86@vger.kernel.org, Linux Memory Management List , linux-riscv Subject: Re: [PATCH v5 5/5] memblock: Disable mirror feature if kernelcore is not specified Message-ID: References: <20220614092156.1972846-1-mawupeng1@huawei.com> <20220614092156.1972846-6-mawupeng1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 06/14/22 at 12:27pm, Ard Biesheuvel wrote: > On Tue, 14 Jun 2022 at 12:20, Baoquan He wrote: > > > > On 06/14/22 at 05:21pm, Wupeng Ma wrote: > > > 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; > > > > memblock_mark_mirror() is just a wrapper, maybe we should check this in > > efi_find_mirror(). Otherwise, how do we explain the message printed out > > at below in boot log if we don't mark mirror memory at all? > > > > void __init efi_find_mirror(void) > > { > > ...... > > if (mirror_size) > > pr_info("Memory: %lldM/%lldM mirrored memory\n", > > mirror_size>>20, total_size>>20); > > } > > > > EFI does not care about *how* mirrored memory is being used or not, it > just reports what the firmware provided. So EFI is not the appropriate > level to take kernelcore=mirror into account. > > I already mentioned that memblock_mark_mirror() is also the wrong > place IMO, but Kefeng explained that doing it elsewhere is > problematic. OK, seems we have no better choice other than these two. >