Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1308765iog; Tue, 14 Jun 2022 03:36:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx44nvqneyee10XxyTNM7p2cNBV9Q3mMKE/Ypw4hUAH3SW9daIDStQ31sp4fCP+LT8sizqi X-Received: by 2002:a17:906:c7c1:b0:711:d2e9:99d0 with SMTP id dc1-20020a170906c7c100b00711d2e999d0mr3630131ejb.639.1655202983565; Tue, 14 Jun 2022 03:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655202983; cv=none; d=google.com; s=arc-20160816; b=h9D9DZHsWp91DoYcGCpLcKyqmWeXIBc9JZtR00XsxEYv7kQW+k7qbgliFj/xUc44SE s95Rqkdt3sy9/c1s7VOWecqgfAsSl1hoxqIVKhUaYBm5jc4y4JCAFye+in6uL0/KBr96 LyggLAxGUfL0B+dB8JS5zjZmGixq/NRzYUdWSIfMywFutJ3h+a1lEN5UceLNfd6qoGEn eaMc5KOMigUXwawBmo+UNd/hn5XiSM50ITdADqxx9+OLDvMWGXiUO/c6gyuR76F35Qr7 MKI3gu6+rqLyRUMrPVwewgKlVcV5gOfFFFCZa1TGQFGU2jA4+zO3FMsr3bmEjUu66hHQ CLEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=jVBeuH01W9o7PqKJox6c22CbAK3uO60chbVuDOP6zyc=; b=Zik/KY9h4Hh7VhfSTvcpwevvp2yhFEpJiP1biBPXvkZWuqmV73BqKMkLL0oKNCiuXV xkGyQUcGXM94Oa8DuI97xXCchMmtwSIyAXfxtNajlRmyA7bkqpsQu1BrMzbx966ZeVts VWor7VKqTw7GzqZn2aS9PCF7XrK11rMEBjaF36or5JOCPqHfwWFtdSj1UFU/miLqIQ48 ytaiiOcFr/i/GwFc7x18KeZSntyEgzfV4Rqp/Lxzs3zB1G6IB8ikz2kHvnNqeWn6arsn uC9YIzko9cNuxswXINiUBBR3HztPVDqrDDiFyO/Quv5NZr1A28J4IsXyfC8ahHplNRZ3 igow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=azg81Ege; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a056402524d00b0042dd10d4e9dsi13729924edd.508.2022.06.14.03.35.58; Tue, 14 Jun 2022 03:36:23 -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=@kernel.org header.s=k20201202 header.b=azg81Ege; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355463AbiFNK1p (ORCPT + 99 others); Tue, 14 Jun 2022 06:27:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbiFNK1l (ORCPT ); Tue, 14 Jun 2022 06:27:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E25DA2C657; Tue, 14 Jun 2022 03:27:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7DB8F60DF3; Tue, 14 Jun 2022 10:27:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD7C2C3411B; Tue, 14 Jun 2022 10:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655202458; bh=pLY/c1iB3KXXw2JkAgjQjqCgz0rlmIBHN5Fh/dw9rf0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=azg81Ege00O8E7x7v7HQ9vUx4hboeEJbaHMhUrs8SErWepT7gFN6ogKeEtTJU3Az9 UHGseD8HacKj7iGzHlCjJZK7V8KZJ2iDSHVKrm0ousyhFHQxvYsnVonc1kqxFqNiCW v5YlOdTT5m7xwGLfBGUVQ2MaNqnHbt1KXXDopo6tdEJZt1uMmrJqxy36OlhBrz+Dx/ WouzetWQ9PPjJ3ICesIELajnDuWTrG/kPhfz/e8qMkrN4IIPARPjJF9e/bOSjnFBqR o9vFN5QyLUCl1psgzV+xxgVxbYvlO1c36pdF7UEveyDN8Jl8uT8itXQopI7806SJXy oGgdcxxgZ3F5A== Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-fe539f9afbso11903702fac.5; Tue, 14 Jun 2022 03:27:38 -0700 (PDT) X-Gm-Message-State: AJIora8J7Zq1vOPvKOp71sWP1XQKuZg5VghY6TyO8wld6C8uDNl8Lqca cXeFEioOdRj2PqPRE0HMG6vKMg8d5pi1PWstXcA= X-Received: by 2002:aca:aad5:0:b0:32f:3b9b:e0f with SMTP id t204-20020acaaad5000000b0032f3b9b0e0fmr1738156oie.228.1655202447146; Tue, 14 Jun 2022 03:27:27 -0700 (PDT) MIME-Version: 1.0 References: <20220614092156.1972846-1-mawupeng1@huawei.com> <20220614092156.1972846-6-mawupeng1@huawei.com> In-Reply-To: From: Ard Biesheuvel Date: Tue, 14 Jun 2022 12:27:15 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 5/5] memblock: Disable mirror feature if kernelcore is not specified To: Baoquan He 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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.