Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1317512iog; Tue, 14 Jun 2022 03:49:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uyMZ2NZ6BBCvgW3fmjn6V2ba9S/9AkctctxMPqzRMSy+IcPgxmmczJe4Qj+8zzP2/Voe5A X-Received: by 2002:a17:90b:224a:b0:1e6:7780:6c8c with SMTP id hk10-20020a17090b224a00b001e677806c8cmr3926298pjb.119.1655203741368; Tue, 14 Jun 2022 03:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655203741; cv=none; d=google.com; s=arc-20160816; b=zV7ZQN4l025MS6TbTOsAgTHySyyMDA+JZ5zfeual0WA9twOYVm8+XXxsB5P5GC16Ua 71h5ld5LlSeeyaF/0BVujKGxcYR4qNQNJyAxSBiegl+2fKg/kKrxvf7JM5/Y6b6qjeUC hF5KezwV8EHGOPw5yAnaWHLQkSm8tJnSo9bC//UcX0AgmAIvoEc/zNj/S9orNo02vNr/ WX54vde690ulBCwkNsfFqEFCIH1mhZLODXqkJjMH9QzW++ax6Z3buPagCBCFEWTLLCfy 7kjxJfWCo9WSfMAS+HlieyVaUrqG+uKJ+p6lg/7wDgE8pCoypn5SnhGeqokmlTM7VfFN q7rA== 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=94Tijhs2krNsUh5sgMXTyng6F8TEy2CILJiweYDy2xE=; b=PodLfQa8GSxTHv7zHi3orggBjGpDgfZ7vxRMWBhT2S36E09grzaYr79qBwkYMNwE3P 5kEkPA4iJkFSGQJEa7sVkxeSIOP4uyVRr9awMYNrIrM2NS/cY7cOVMgypcwNT2wMR9Tf 22Jl90cd6jZ5A6aDxkOqs2Y5Rdmh828ykoQyZKI7BfqpvNhkjikMHcYIvmfTgQeDlqXw C6tpqjzgbNwM/jc7wyuhL0TuSwTk17UuDO+MNb7AcOUaq+DLimuer6F7LjPmthujfYGb mvcKDDOAg6kmnBfA0o7DJY/UI29w3OE7hPLVHHm2LOVGz0usOR2RBEAhHpK2NbnQEBYP gH3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DaM0mpWS; 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 i10-20020a654d0a000000b003fe192996b0si14374801pgt.707.2022.06.14.03.48.49; Tue, 14 Jun 2022 03:49:01 -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=DaM0mpWS; 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 S1354155AbiFNKUo (ORCPT + 99 others); Tue, 14 Jun 2022 06:20:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353743AbiFNKUl (ORCPT ); Tue, 14 Jun 2022 06:20:41 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C7D7947549 for ; Tue, 14 Jun 2022 03:20:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655202036; 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=94Tijhs2krNsUh5sgMXTyng6F8TEy2CILJiweYDy2xE=; b=DaM0mpWSW8cFVRTPcYZPMX2mt1JVh8rpYB5pZo4/GBxAZUJheRqGmXiltQ5WF8k8X1L33B 2dcSDX4M2W1ubKxEKFYsoO/oza1mvsY6g9unCTS9tZBE6hg95AdUZRFSrK8UjQ2Q+bXHDY iATVjlpPvcp1sKWsr+WB+kK1K4/kFAE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-575-oZmcGoKQNE-UgM_JJWpd_A-1; Tue, 14 Jun 2022 06:20:33 -0400 X-MC-Unique: oZmcGoKQNE-UgM_JJWpd_A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 50276811E76; Tue, 14 Jun 2022 10:20:31 +0000 (UTC) Received: from localhost (ovpn-12-211.pek2.redhat.com [10.72.12.211]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A42CC52D63; Tue, 14 Jun 2022 10:20:29 +0000 (UTC) Date: Tue, 14 Jun 2022 18:20:25 +0800 From: Baoquan He To: Wupeng Ma Cc: corbet@lwn.net, will@kernel.org, ardb@kernel.org, catalin.marinas@arm.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, dvhart@infradead.org, andy@infradead.org, rppt@kernel.org, akpm@linux-foundation.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, paulmck@kernel.org, keescook@chromium.org, songmuchun@bytedance.com, rdunlap@infradead.org, damien.lemoal@opensource.wdc.com, swboyd@chromium.org, wei.liu@kernel.org, robin.murphy@arm.com, david@redhat.com, anshuman.khandual@arm.com, thunder.leizhen@huawei.com, wangkefeng.wang@huawei.com, gpiccoli@igalia.com, chenhuacai@kernel.org, geert@linux-m68k.org, vijayb@linux.microsoft.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org 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: <20220614092156.1972846-6-mawupeng1@huawei.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 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); } > + > 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 > >