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 83869C43334 for ; Mon, 13 Jun 2022 09:44:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F3B48D0175; Mon, 13 Jun 2022 05:44:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A2C48D0171; Mon, 13 Jun 2022 05:44:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06BAA8D0175; Mon, 13 Jun 2022 05:44:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id EBF478D0171 for ; Mon, 13 Jun 2022 05:44:44 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id C153E80C39 for ; Mon, 13 Jun 2022 09:44:44 +0000 (UTC) X-FDA: 79572728088.29.0C45F4D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id 5AC3118007F for ; Mon, 13 Jun 2022 09:44:44 +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 A1F6061387 for ; Mon, 13 Jun 2022 09:44:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11D0BC3411F for ; Mon, 13 Jun 2022 09:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655113483; bh=xt5DGwjhYrIt2t4/I7WxcJsztFBJP3gm0q1s4WQ34ZM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=eDk9eOjpLYpw2KXvxuiY9qXt/i918GnXBO1FT5/9QVM3a5B4O6gXb664rK+2IOGt2 V8gkTE1XBEAJSfd4qpQG4rotWzj8aoQHJTyqVR6DwLIM+D2K5+fO8lMN0XG8VcV89e 57hmNnLPLrDS3GxarMwNsKLnV4x12gOOTn4jchgomkyrgMA7CvZCT4WpqML7g+Dbgn z6NY90awHZtSwqgVzf6QUiBlZ8jEijwq8ZUgH1NCq+za/jU8WptlvXicZdBPUJbNC6 /mqX/v910ZuHlWHwNCpsOkUaLuUM+2DU6X4P4ksrZP8OurlFc/WLyCIPpyR3nSURKK G81kpRRX41Chg== Received: by mail-oi1-f180.google.com with SMTP id k24so7126860oij.2 for ; Mon, 13 Jun 2022 02:44:43 -0700 (PDT) X-Gm-Message-State: AOAM5319+jYBk70KmziIuTzKpA3jGCq8WD6y+oDv1CP/VadFZqUO4sM1 5SXe+IhPVL2cHw33l9WJGv/J1SvjgoVl5R6THHs= X-Google-Smtp-Source: ABdhPJxWL190gaOo8x+poLO9fIQXg4n82FrPAPLPqZ2Srb/3zr8FQ26NmuG4wz3v6gR8a+MZBf5hmYgVu3gibFw/syM= X-Received: by 2002:a05:6870:e98b:b0:fe:219a:2449 with SMTP id r11-20020a056870e98b00b000fe219a2449mr7281685oao.228.1655113471413; Mon, 13 Jun 2022 02:44:31 -0700 (PDT) MIME-Version: 1.0 References: <20220613082147.183145-1-mawupeng1@huawei.com> <20220613082147.183145-7-mawupeng1@huawei.com> <590a1211-d316-d51d-6577-eb9983126dd0@huawei.com> In-Reply-To: <590a1211-d316-d51d-6577-eb9983126dd0@huawei.com> From: Ard Biesheuvel Date: Mon, 13 Jun 2022 11:44:19 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 6/6] memblock: Disable mirror feature if kernelcore is not specified To: mawupeng Cc: 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 , 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 , Zhen Lei , 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 Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655113484; a=rsa-sha256; cv=none; b=N4gQW0aNg53vaxVGPtGQyEiZGdaaCGOybBmNhGwu4TqJjJ/9g/BCAhuw0vLNqb3qlIlwd7 W8l+zGvi3XJJXI3En3W7tg2q7BLLXYWZQUQ+k9RAGnIj6cRxWySuZihzSLX4NQ59ZEIr7A 2BMl1wqxJxuWl2eyEQvCeFJdyWylK9A= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eDk9eOjp; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.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=1655113484; 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=h+vWoTYf8ZT05yfh7A+KWU3sqnc1VuuzVp2mUZlufrI=; b=38VGkA7t6W1Ow4ZmV1hhE9ibyKaRIcdX2ekYZHMHSM5Dixjh2sRr8k4q8MJHG5OQZEI/6A ZlBYH2dJFAICozVytGtnNHNQoAS0tCtHCtiskWNOAzGmGjWy6yXzwO7yQo0VYMq2qsDvn7 UJt/N0w+Rc4TnV3h6GkqEUgU5cD4+s0= X-Stat-Signature: 51oe1ky68e4df8uxwyb9ghk9widr5fkt X-Rspam-User: X-Rspamd-Queue-Id: 5AC3118007F X-Rspamd-Server: rspam07 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=eDk9eOjp; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of ardb@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=ardb@kernel.org X-HE-Tag: 1655113484-574186 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 Mon, 13 Jun 2022 at 11:13, mawupeng wrote: > > > > On 6/13/2022 4:21 PM, 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 > > --- > > 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; > > + > > 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..9b030aeb4983 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; > > __initdata here is not suitable and will lead to compile warnings. > > In my test, __initdata_memblock and ro_after_init are both fine, but I am not > sure which one to choose? Do you have any idea on this? > __initdata_memblock is fine if it works. This looks to me like the right place to implement this policy, so Acked-by: Ard Biesheuvel > > > > /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from */ > > int movable_zone;