From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74AE5CCA47B for ; Tue, 14 Jun 2022 10:50:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E88FF6B01B1; Tue, 14 Jun 2022 06:50:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E39808D0002; Tue, 14 Jun 2022 06:50:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D00966B01F1; Tue, 14 Jun 2022 06:50:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C04046B01B1 for ; Tue, 14 Jun 2022 06:50:22 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 934542188E for ; Tue, 14 Jun 2022 10:50:22 +0000 (UTC) X-FDA: 79576522284.27.7A241DE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id C9EDB20099 for ; Tue, 14 Jun 2022 10:50:21 +0000 (UTC) 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655203821; a=rsa-sha256; cv=none; b=PUhB/J7nAyETGp/1jbmCWANVv7O/wuXeLk9pMAW3Xmhu/sodzfbin4g5TnnCFB8unDiFoH k01j9+mum8y/AUj3ra0VbmVxIY/cX2Vm22YGeqdn4qyqsXbsJMSilv4PULyyNmehuVaXnB vcv1TzixIbhqU2gRGKieBwE+ODR6eCw= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="NPjGZ/rY"; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf13.hostedemail.com: domain of bhe@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655203821; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IiQIaQMhxL76RBZHsmcLreZUSDHLka20T5mMLLN/xgk=; b=pIBE1wp3YuHbwpcNrexjuvKbIffrtm0kQC4N/h9Fvc9HyBSURjK/Oby3kC8ePiGmrAmL+c 1WSYPPTfUAD7PCnGmldNxqLpDJRdtemc5c0AuuCnvzYlKJ6Z8ivnkIUlEkaFymc7PPZGD+ 0eALXsp6khu+XVGm0cV5EBE2TDiI0cs= X-Rspamd-Queue-Id: C9EDB20099 X-Rspam-User: Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="NPjGZ/rY"; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf13.hostedemail.com: domain of bhe@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=bhe@redhat.com X-Rspamd-Server: rspam06 X-Stat-Signature: nqcs3ha4am9yrnwd71yxc8hhkqtemd5s X-HE-Tag: 1655203821-196497 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. >