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 0581CC433EF for ; Tue, 14 Jun 2022 10:27:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F3C58D0229; Tue, 14 Jun 2022 06:27:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A3FE6B00CD; Tue, 14 Jun 2022 06:27:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 46CFF8D0229; Tue, 14 Jun 2022 06:27:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 37E686B00CC for ; Tue, 14 Jun 2022 06:27:40 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 14EE712169D for ; Tue, 14 Jun 2022 10:27:40 +0000 (UTC) X-FDA: 79576465080.12.7A98913 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 7CAF714009A for ; Tue, 14 Jun 2022 10:27:39 +0000 (UTC) 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 B648C60DE0 for ; Tue, 14 Jun 2022 10:27:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8890CC3411F for ; 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-f41.google.com with SMTP id 586e51a60fabf-1013ecaf7e0so6214395fac.13 for ; Tue, 14 Jun 2022 03:27:38 -0700 (PDT) X-Gm-Message-State: AJIora877B9k4L0fHL2DUgwbIaHbLxLJHxOvEeo2IOl+LsKfCx0onihr dxOe29f6zJ4YRbXOqfSSsdzo8cBWUDV9Lp7PDdY= X-Google-Smtp-Source: ABdhPJwqvTBoi/hdOV5yBa6AZkvlop+ZjXzRzSSCX4iDQR2/4mlYcKmmyvZh/nsuqJlyiGM+W/g1OGM3mBXbHXv9T6k= 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" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655202459; a=rsa-sha256; cv=none; b=doa2CVEP02cqVA+HR13ARpnroHeIJrqpPcQ5cHfe6l+YVEateFev14oWRZZ7KFMS4uyN5A EeaEtyBtzJfahed0BRlCI61KSAoEn9xU7CYSgtJZ0FVB8lUlYY1MPkmQlMZ9dQhSMFgyfy 0xrBLqyvXLgfp8y6ELcO1Dtw+JPVOrU= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=azg81Ege; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of ardb@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=ardb@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655202459; 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=jVBeuH01W9o7PqKJox6c22CbAK3uO60chbVuDOP6zyc=; b=jzXgxP0ujkhxZI9IkefLAlkjDGBsDWEYXskraARx8ihqjexmkuoizED1X0dWag4chEZV/o AzMZsFWyOxWVADVsiWfvrBv4nH9948cnzQDYyp36d0hMTeb1BR0kfy6RK3Pbv8jjVw4hvm OJq8BD+Dek5w/m4mFvVeVWmo7NJDIr8= X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 7CAF714009A X-Stat-Signature: q4he3a3gzzgpwokoua8846rkugrq5pk7 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=azg81Ege; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.hostedemail.com: domain of ardb@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=ardb@kernel.org X-Rspam-User: X-HE-Tag: 1655202459-893562 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 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.