Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4635637rwl; Mon, 3 Apr 2023 07:40:40 -0700 (PDT) X-Google-Smtp-Source: AKy350ZgFbwlrlQhwzEmwOWqOMX9q2fHx21cdT7b+UP654SQ2mAHMZy9+QnfYf26W3SaY6i2RIjO X-Received: by 2002:a17:907:6d99:b0:948:c047:477d with SMTP id sb25-20020a1709076d9900b00948c047477dmr2289686ejc.22.1680532839900; Mon, 03 Apr 2023 07:40:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680532839; cv=none; d=google.com; s=arc-20160816; b=XfjKmdwyk5hGJ9M1/0JASxSV+IbG42Tuz08R9kWpwuR/wd+UZYujMFiJOi9+meMCXH FhgOu2Lin2wzkHDyO5xPD7lJD3z8q53I6Knr4yjKD/xSNpbTBsQbOjJa+xUgZJLaBBko X3PCq47O4ql4bOy2TLfgaTS1a3Q9ilwNOYN04aYzJmWSgy93wTlTCXyxfnW6gkpDREHA OzSek5s4ldEbOjqkN54FOcIeXLfCIq0tWajIn2dxyMJtqhMaQKby2pUZeiyeBaqIehsV IDkHsLhMe8PBz21yRZj55M52xwRWeLdInFUKxV8DTj4SKHZuXWF2VdmgpG6rRuICMHzP pMYw== 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:feedback-id :dkim-signature:dkim-signature; bh=K2V3JLsEArJXT5TV6MDPru6C5GMHsExu9jhmhSdk+zM=; b=WNaGR8iAYAsgkyaHvbR2rRi+Lg0KTKxfRFqFgJMsheaMvQc+f7Oo1B/DWj7q/2rqOt KKrOGuc0QqVAniRLAm9tVI8M/EHq/P8jVjgkWkmFnnS/vXKJ4VX0mW8S6eQLsHUtIi8Q Y55jJHq4jjW6eKXoTbCqXojWIK/TOZ6XCa/NF0cytvBXtOMfIGwPqPHQarEQdAq991Gh slXM7uYPUThEuxX9R/Xw9QyGI4xUDZ/Wqgsi1MXdeALUoTRVqlVH/nJ5jmeUXHgvy+bT F6aVAzOg+uPz0ttGMqDm+DLRgAoB6VYcUxnQu3prAov3LjjwmK9XbMYi2NOM7TF1Z1Ij zf+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm1 header.b=Wc5t8NRE; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=e2w447uu; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg19-20020a170906a05300b0093dfd2eab9dsi670902ejb.2.2023.04.03.07.40.00; Mon, 03 Apr 2023 07:40:39 -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=@shutemov.name header.s=fm1 header.b=Wc5t8NRE; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=e2w447uu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233751AbjDCOjY (ORCPT + 99 others); Mon, 3 Apr 2023 10:39:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233728AbjDCOjX (ORCPT ); Mon, 3 Apr 2023 10:39:23 -0400 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC4A91DFB2; Mon, 3 Apr 2023 07:39:22 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 77AF532009FD; Mon, 3 Apr 2023 10:39:19 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 03 Apr 2023 10:39:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1680532759; x= 1680619159; bh=K2V3JLsEArJXT5TV6MDPru6C5GMHsExu9jhmhSdk+zM=; b=W c5t8NREEIWo1fH4RidMcCeW8vslYrlg8yjoP+fgXapMvSaVtq9OTiDKafp41bgJz oYjPqABrCdeeV2/V1q4c0BxUORxGcYBHOCApDb2YeRDYyzJEXAzT9o5m2O+GId2f AOwiKFEAT8Xze9i4dm37E1ox/z8+Fp68QS5/sUUTygsRqVqWlIPcXISiXSsMcDXO Eqh3kwG9iXvTml4l8bznnUS64eqHWJETGhzsHommuBn632Wy3/YYkMcMmyMgPIwF CvAhcGESsu0siFSXsfTIzDBnXYX/G2dwg2jXI3eLoe/7uylTaKBOBs176DS58Zrq a/zQ4xmUoKX1PMSfaXdOg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1680532759; x=1680619159; bh=K2V3JLsEArJXT 5TV6MDPru6C5GMHsExu9jhmhSdk+zM=; b=e2w447uusTtu5q54yfFeOZQdnc9b/ AJb+1KHufDoeqjk9f1kBNfqBzKSaT52+A7uZpWAB1u5QndFu01DUPparmXsPlxGx WF0vAV3fCvY69KlA++dInfzV4t+6p5b2jO6d0lqD4ePrXihfFXFbmUqUpN4g9cKz E/GaxU82i/JtkkPrcUBc5RNWUQ2mXs4d8xk9Uxy037d9gvl6vmdG6zqHhjj0z3TS limNJ6chj7mBRJ9SV29UXHqJtZNsV8Nuhr88F+0HOXbtmOMT5m4KNU6CGBFgzueV hIKekPqMAkqm81p047aklihTLYEghPR28pLxBAE/YcJ2UfttHkwTmop5Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdeijedgjeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdttddttddtvdenucfhrhhomhepfdfmihhr ihhllhcutedrucfuhhhuthgvmhhovhdfuceokhhirhhilhhlsehshhhuthgvmhhovhdrnh grmhgvqeenucggtffrrghtthgvrhhnpefhieeghfdtfeehtdeftdehgfehuddtvdeuheet tddtheejueekjeegueeivdektdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehkihhrihhllhesshhhuhhtvghmohhvrdhnrghmvg X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Apr 2023 10:39:17 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id 7F0EC10D7B3; Mon, 3 Apr 2023 17:39:15 +0300 (+03) Date: Mon, 3 Apr 2023 17:39:15 +0300 From: "Kirill A. Shutemov" To: Vlastimil Babka Cc: "Kirill A. Shutemov" , Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Dario Faggioli , Dave Hansen , Mike Rapoport , David Hildenbrand , Mel Gorman , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, aarcange@redhat.com, peterx@redhat.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv9 03/14] mm/page_alloc: Fake unaccepted memory Message-ID: <20230403143915.uc4tnpgmssvpdqxu@box.shutemov.name> References: <20230330114956.20342-1-kirill.shutemov@linux.intel.com> <20230330114956.20342-4-kirill.shutemov@linux.intel.com> <835dfe65-d9dd-0b16-37d4-920e97f1bca0@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <835dfe65-d9dd-0b16-37d4-920e97f1bca0@suse.cz> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS 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 Mon, Apr 03, 2023 at 03:39:53PM +0200, Vlastimil Babka wrote: > On 3/30/23 13:49, Kirill A. Shutemov wrote: > > For testing purposes, it is useful to fake unaccepted memory in the > > system. It helps to understand unaccepted memory overhead to the page > > allocator. > > Ack on being useful for testing, but the question is if we want to also > merge this patch into mainline as it is? I don't insist on getting it upstream, but it can be handy to debug related bugs in the future. > > The patch allows to treat memory above the specified physical memory > > address as unaccepted. > > > > The change only fakes unaccepted memory for page allocator. Memblock is > > not affected. > > > > It also assumes that arch-provided accept_memory() on already accepted > > memory is a nop. > > I guess to be in mainline it would have to at least gracefully handle the > case of accept_memory actually not being a nop, and running on a system with > actual unaccepted memory (probably by ignoring the parameter in such case). > Then also the parameter would have to be documented. As it is written now, accept_memory() is nop on system with real unaccepted memory if the memory is already accepted. Arch-specific code will check against own records to see if the memory needs accepting. If not, just return. And the option will not interfere with unaccepted memory declared by EFI memmap. It can extend it, but that's it. Looks safe to me. > Speaking of documented parameters, I found at least two that seem a more > generic variant of this (but I didn't look closely if that makes sense): > > efi_fake_mem= nn[KMG]@ss[KMG]:aa[,nn[KMG]@ss[KMG]:aa,..] [EFI; X86] > Add arbitrary attribute to specific memory range by > updating original EFI memory map. > > memmap=%-+ > [KNL,ACPI] Convert memory within the specified region > from to . If "-" is left > > Would any of those be usable for this usecase? Oh. I missed them. Will take a closer look. > > > Signed-off-by: Kirill A. Shutemov > > --- > > mm/page_alloc.c | 21 +++++++++++++++++++++ > > 1 file changed, 21 insertions(+) > > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index d62fcb2f28bd..509a93b7e5af 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -7213,6 +7213,8 @@ static DEFINE_STATIC_KEY_FALSE(zones_with_unaccepted_pages); > > > > static bool lazy_accept = true; > > > > +static unsigned long fake_unaccepted_start = -1UL; > > + > > static int __init accept_memory_parse(char *p) > > { > > if (!strcmp(p, "lazy")) { > > @@ -7227,11 +7229,30 @@ static int __init accept_memory_parse(char *p) > > } > > early_param("accept_memory", accept_memory_parse); > > > > +static int __init fake_unaccepted_start_parse(char *p) > > +{ > > + if (!p) > > + return -EINVAL; > > + > > + fake_unaccepted_start = memparse(p, &p); > > + > > + if (*p != '\0') { > > + fake_unaccepted_start = -1UL; > > + return -EINVAL; > > + } > > + > > + return 0; > > +} > > +early_param("fake_unaccepted_start", fake_unaccepted_start_parse); > > + > > static bool page_contains_unaccepted(struct page *page, unsigned int order) > > { > > phys_addr_t start = page_to_phys(page); > > phys_addr_t end = start + (PAGE_SIZE << order); > > > > + if (start >= fake_unaccepted_start) > > + return true; > > + > > return range_contains_unaccepted_memory(start, end); > > } > > > -- Kiryl Shutsemau / Kirill A. Shutemov