Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4693893rwl; Mon, 3 Apr 2023 08:22:53 -0700 (PDT) X-Google-Smtp-Source: AKy350ZtqfMBOsBod+tmex/IIaOVZ5hMGTgIoRA5bYBPnkjf3HNtr2xbHc3d+n2ADFjkny0sBmlz X-Received: by 2002:a62:4e8f:0:b0:625:cf6d:b260 with SMTP id c137-20020a624e8f000000b00625cf6db260mr35553114pfb.6.1680535373004; Mon, 03 Apr 2023 08:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680535372; cv=none; d=google.com; s=arc-20160816; b=eQN+033/+zpYAnOktYvK7HS/YlPSrAyBkASUT5XQ0YCL0CBAESYHEtzbB5t2QkAAug lwGj85+gG++a0XExQBIL26aPuqNlvOLhHRdP7NmrQ+c9XsGIdyDtC1JAybYh3w0D4AvZ NPeildZbN/b7WRQ87FHfra9vl2aEXMdgzBLuJmsaPkBSRQCQ8/GXCbKDjqoSeur+sRdM Of6ngE8Jfd4hP7hexa/3QDpbVBS6NiH9P4r9hVnwxvF1HdQVqawwyNBtCdJtTbfLvSNw Zda9kCPL2lyB3LKEZgy1OnaUqkIoEAcdPKQfhxhQyQnDqgEQ36tug28+9PFJ39ealtXJ LjSg== 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=oqA0VHWBGbzdDXhXtmsL6Q39VlRQlEDa8qmRtydlcIU=; b=CBntXHXg/jTGRAv9AtEBMuyqGFh3cQMCk7o+FYLYINY1TVw+J7O1sjE0X2FQPY8Mzk KYmQNGpF4YTBBa6R8H8xOnB0oc1m8djZckRkDJMl1nnVFdtXTX0L1HXTCUIPL8jDl8BU IuuztuaFCg6SqRkt7ZX9hfEoj6PGlrr+WVkTec95kuz/JTuOlq5+sXWV6LqaMQdsCQCj ZbGFuOhoBPYoridqq8VEqLAo2+hE7XwDbuy5da9rZKTTFnIQFv6fc1EP83jpOvrz/2BC jvHHThzCJiaQOx/t0W82eCBtsOTKtB3ocsKbKoIyHa9PrMTGIKNmov0fcgMoE+J7WOc6 uf1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm1 header.b=CJfPIRcT; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=NdC2tkDI; 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 u69-20020a627948000000b0062ae6345c64si8555183pfc.383.2023.04.03.08.22.34; Mon, 03 Apr 2023 08:22:52 -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=CJfPIRcT; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=NdC2tkDI; 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 S232895AbjDCO4X (ORCPT + 99 others); Mon, 3 Apr 2023 10:56:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232011AbjDCO4W (ORCPT ); Mon, 3 Apr 2023 10:56:22 -0400 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B253928EBE; Mon, 3 Apr 2023 07:55:57 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 433DE320098C; Mon, 3 Apr 2023 10:47:06 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 03 Apr 2023 10:47:08 -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=1680533225; x= 1680619625; bh=oqA0VHWBGbzdDXhXtmsL6Q39VlRQlEDa8qmRtydlcIU=; b=C JfPIRcTDs1kJ7uvJSt2/SC/gZ0s850Etkzy+yVS2pfYpPQSe4KLXh+cJ84UD79uM aidEngC7vydhEz1Hr2f1ZscjLnk+/Hh+N7LfBjfBV6oEenxEWi+xxLTWvyi/nx6o KZOaM/T9wBaMXjDZ3fkuSURI3kFbbBLWl9Hvy1a9HCXfKsbFifcZVNpOixtCzsRn ROxo2xpwYSgqVKOPVJnJRmKTJG+is3IdH4YDb7IvUD7EwIbsoCDnUHGu9sdqMCs3 m4aDvaENE/KrceJdicbM90VxOhBz7H1xkYv3p1qd7eOsFtLSChCaQ856gRVV+vrl Ou+/Gpqjm3bSf4YwITdXA== 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=1680533225; x=1680619625; bh=oqA0VHWBGbzdD XhXtmsL6Q39VlRQlEDa8qmRtydlcIU=; b=NdC2tkDIF2Qhtp04LAGWOXraeGqkd 982Y+yLEmxsFtcAqCDimsb+ePj1+DytzJB2hnGUZrzVkc/g8Z8Fi1GCrHGLgfWI4 QBsaLkkQRZudXq6LE6F9lnIVTkGiPE4A/nb8ig8q8QeDrqrebU6oBbERzt5e8ITl 0vB2kvE3DpiaNiUCdd66271rOTkHfuHO9OTbF0V6IftqC7XoOK+JbDbpE90mL/PS WwQxWJyvvENm21f2G+Yr/Juv5rsXj3DcBayYqFwbmVVzYcQiEOeX7DpXAA9wrFr4 cUvdHcQfYUNo6WjW17vojot3bC/Ii5NqALXIlFvZm+sgqiLDCWOYKMUOw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdeijedgkedtucetufdoteggodetrfdotf 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:47:04 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id C6B9410D7B3; Mon, 3 Apr 2023 17:47:02 +0300 (+03) Date: Mon, 3 Apr 2023 17:47:02 +0300 From: "Kirill A. Shutemov" To: David Hildenbrand Cc: "Kirill A. Shutemov" , Borislav Petkov , 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 , Dario Faggioli , Dave Hansen , Mike Rapoport , 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: <20230403144702.uf7fhfrffypkmqy5@box.shutemov.name> References: <20230330114956.20342-1-kirill.shutemov@linux.intel.com> <20230330114956.20342-4-kirill.shutemov@linux.intel.com> <053a9ccd-4205-7a76-70c3-c256bd995a1f@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <053a9ccd-4205-7a76-70c3-c256bd995a1f@redhat.com> 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 04:43:08PM +0200, David Hildenbrand wrote: > On 30.03.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. > > > > 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. > > > > 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); > > } > > The "unpleasant" thing about this is, that page_contains_unaccepted() could > not be used for sanity checks because the result is static. > > For example, something like > > if (page_contains_unaccepted(page, 0)) > accept_memory(page, 0); > BUG_ON(!page_contains_unaccepted(page, 0)); > > Would work on real hardware, however, not for the fake variant. Need for raw_page_contains_unaccepted()? :P -- Kiryl Shutsemau / Kirill A. Shutemov