Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp315644rwb; Thu, 1 Dec 2022 02:33:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf5HjeepN/FaeMRcYGiM7NmC/wNuLkGUNpt1NMOQ4BsAkk1/6JoehfOaCSTUSTjPrI008kPo X-Received: by 2002:a17:906:43d0:b0:78d:a01b:b474 with SMTP id j16-20020a17090643d000b0078da01bb474mr42582591ejn.8.1669890782360; Thu, 01 Dec 2022 02:33:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669890782; cv=none; d=google.com; s=arc-20160816; b=ka5heyOPaOPxlvuUhqWrxfRDmQ938XprbAB1W0JssVGFVQugpwX1pUA5ENrMFzZAO7 9BbZOLtYHBsD17/19ml5CIbYgGU1BogAkcI9fW5Q5serlPJRMK7QoA52d3EYzQGIpm2W Q4Xiw8VwppnDW82wn5XvXLv49QGtiAP3DU2eI6hZTZMjNESIcsubf20uwtfydj1YPR5s KVDi2gjP2ZRO3BeAu5ea3Ho1CgH5DfbfDiO1aczeqzY9ewQ37qaFG/8bq2LMokK0CIoh NHCYLWeHeCMKUfFIR0Z5u4MryGY8UtN3926uS2je7mZWVE3JuQmCb2OzcGqrU5xr+QGO 5W+A== 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=TsJhdxGFdBmZdr4Zzpno6DDl+0kGNBYt/DoLNx/2LK0=; b=VpIcakZnoI3fhH8nCNcCffiJdmaWuzRkS1wA7FPDXKswCRgZYwbaZL9VpxyMYSTC/G Q4A5OZJlTFEN9KNEBJovoc2g/g4bIrsGvZKYOkOimRravUHe67wn12YdgmdUjPG2kJUI LnuhHTB/RmKhVjhh6OMuDJVnhmxYlRrnRAA3Y+3fwpTlJT+q8X/yDThQuJp1tyZOdw6c xiT6453njxqv0xLOPNJ8aMsrcOFxHyY0hR2iLKphFBKTPcj5MmyzX/eHy2hBW4aSBm3n WrQmK+6il3R8xvLHta8XohYNlsVcNZ78chwwGbZ4mWxY47A1g5C2p861crawAcP9Tkrl Dtug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="m/T9mQyW"; 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 r18-20020a05640251d200b0046b10fbb1fasi3899837edd.222.2022.12.01.02.32.42; Thu, 01 Dec 2022 02:33:02 -0800 (PST) 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="m/T9mQyW"; 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 S230156AbiLAJhn (ORCPT + 82 others); Thu, 1 Dec 2022 04:37:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbiLAJhl (ORCPT ); Thu, 1 Dec 2022 04:37:41 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE260E7B; Thu, 1 Dec 2022 01:37:35 -0800 (PST) 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 sin.source.kernel.org (Postfix) with ESMTPS id A77CFCE1BB6; Thu, 1 Dec 2022 09:37:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75389C43470; Thu, 1 Dec 2022 09:37:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669887451; bh=BfOt5syWCVHNIGlCb5w84CIS4Di9VpSeQ2OX3cIcr0g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=m/T9mQyWRqPURKZX3ywro3KQASCx/8OPjCwEnX3ONXn1gZnBx+Sf4nS2Tr/dDZE2x JyUxtPoL1HCM9kIie8EN+AD1YLaixfOtfzCR1TDv2XoJlmHA1wAEvGMZhzo+0m8Jmb /Z2h7e2XFK1uzrzHO/WpDhAwHo/7pP05AeWgSl29p7Q2yjqRtzC8fb3wzrI6OJ1HkZ KB8ipJ01wFYCSsMZ0DfDAgXLPcPBCSfVY1M5fIW1FlzEpAGu+s5g2QcDyh2qR9Mg8x RYP0Su61tWvN/xP44ZIh2d1yEm7nm1xsw/TWgw2675xlSDvo4WotLTgBYleKetNWad mf5S8Ws3o/j6w== Date: Thu, 1 Dec 2022 11:37:10 +0200 From: Mike Rapoport To: "Kirill A. Shutemov" Cc: Borislav Petkov , "Kirill A. Shutemov" , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Varad Gautam , Dario Faggioli , Dave Hansen , David Hildenbrand , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport Subject: Re: [PATCHv7 08/14] x86/mm: Reserve unaccepted memory bitmap Message-ID: References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <20220614120231.48165-9-kirill.shutemov@linux.intel.com> <20221130012840.sf4rvddzc4ev7bj5@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221130012840.sf4rvddzc4ev7bj5@box.shutemov.name> X-Spam-Status: No, score=-7.1 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 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 Wed, Nov 30, 2022 at 04:28:40AM +0300, Kirill A. Shutemov wrote: > On Tue, Jul 26, 2022 at 11:07:14AM +0200, Borislav Petkov wrote: > > On Tue, Jun 14, 2022 at 03:02:25PM +0300, Kirill A. Shutemov wrote: > > > diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c > > > index f267205f2d5a..22d1fe48dcba 100644 > > > --- a/arch/x86/kernel/e820.c > > > +++ b/arch/x86/kernel/e820.c > > > @@ -1316,6 +1316,16 @@ void __init e820__memblock_setup(void) > > > int i; > > > u64 end; > > > > > > + /* Mark unaccepted memory bitmap reserved */ > > > + if (boot_params.unaccepted_memory) { > > > + unsigned long size; > > > + > > > + /* One bit per 2MB */ > > > + size = DIV_ROUND_UP(e820__end_of_ram_pfn() * PAGE_SIZE, > > > + PMD_SIZE * BITS_PER_BYTE); > > > + memblock_reserve(boot_params.unaccepted_memory, size); > > > + } > > > + > > > > Hmm, I don't like how this is dropped right in the middle of a unrelated > > function. > > > > You're adding arch/x86/mm/unaccepted_memory.c later. Why don't you put > > that chunk in a function there which is called by early_reserve_memory() > > which does exactly what you want - reserve memory early, before memblock > > allocations? > > early_reserve_memory() specifically called before e820__memory_setup() > (see comment in setup_arch()), so we don't have e820_table finalized and > we need it to get correct RAM size from e820__end_of_ram_pfn(). > > I guess we can hide the chunk in a function in unaccepted_memory.c and > call it from here, but it would require #ifdeffery in a header file as the > .c is only compiled for CONFIG_UNACCEPTED_MEMORY=y. > > Looks like an overkill to me, no? Agree. Can we just extend the comment to explain why we reserve the bitmap at e820__memblock_setup() rather than in early_reserve_memory(), pretty much with the explanation above? > -- > Kiryl Shutsemau / Kirill A. Shutemov -- Sincerely yours, Mike.