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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D827CC76188 for ; Mon, 3 Apr 2023 14:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233930AbjDCOo5 (ORCPT ); Mon, 3 Apr 2023 10:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233929AbjDCOon (ORCPT ); Mon, 3 Apr 2023 10:44:43 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1786D18272 for ; Mon, 3 Apr 2023 07:43:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680532993; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/eYb2XMUpR9VXDleQG1dvUeP259a87ERPUWeMJE/H5g=; b=Elevh4Zd3aW7+wpa9VK2FHEI4B1i1v4uVsKQt7PwTv6OJy7yI1x2xZNv8AdRoqhH23ZUfF T5cW4lhrpW7cj//V7iNAoLB7qpzuVT8yIbRq72P3OT4yxmMFm9jMGyTbASAzMS2y/OqQKl j6B9l6Il6kwO2aKB41ZI5heMDF+lc+g= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-368-wOF3RwVVOC6KGh-ypqy4UQ-1; Mon, 03 Apr 2023 10:43:12 -0400 X-MC-Unique: wOF3RwVVOC6KGh-ypqy4UQ-1 Received: by mail-wm1-f71.google.com with SMTP id bi27-20020a05600c3d9b00b003ef6ee937b8so11453925wmb.2 for ; Mon, 03 Apr 2023 07:43:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680532991; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/eYb2XMUpR9VXDleQG1dvUeP259a87ERPUWeMJE/H5g=; b=tucKkpitsMldxHHLbg2uVoDDfWYF42xp96QbJPdByAOXCDPTUX6f4/B5lzpyR2/EzU XTKy+KpJyI08XaixvcGUpcV/WaCdgrxoGjqy6VE9cvA6eOJ2PY+DGLCEwC50k/pEyT2E H0MhbdF0+JRj440WJKBz/Kxiaxlzy0sN4XTpsnc6piN5ACQ9+irGryw/0Z2klulUedVy 0QP/SGMgYBRmvxJHnAJ8YpA0Bas96jDAeObazkxNQ94MPayxXTN2wn+Xv35rvRh0xx27 mJlJeGXAFu3HXYzWHLvFtfIYpcSv1WnUab01AwSIQlWv0yOQUO782A8DqFjZUqmyZGKY l2Lg== X-Gm-Message-State: AAQBX9fk7DKGeTFu9TfO4NNCEogk09fGRrh1rxUkQZ3oTuiMS+qwz+Ui xtILqw6Ful+jek2oKVV+tX6+xYQSfBGIBhbuT3U4sHOpWyqcwHNhZf780QBXlN/ep844oxejzo4 sPpE5zQk8WB12Iz/tUXwIbn3v X-Received: by 2002:adf:fb0d:0:b0:2e5:17a4:7d65 with SMTP id c13-20020adffb0d000000b002e517a47d65mr9852997wrr.39.1680532991155; Mon, 03 Apr 2023 07:43:11 -0700 (PDT) X-Google-Smtp-Source: AKy350Y08+lpc/XjAnUg5I1OrKi5tNhWj0ZeUnj6X2UCuKEr2raMcQhFTlwQjTgwu1vHm8iFtim9pA== X-Received: by 2002:adf:fb0d:0:b0:2e5:17a4:7d65 with SMTP id c13-20020adffb0d000000b002e517a47d65mr9852963wrr.39.1680532990772; Mon, 03 Apr 2023 07:43:10 -0700 (PDT) Received: from ?IPV6:2003:cb:c702:5e00:8e78:71f3:6243:77f0? (p200300cbc7025e008e7871f3624377f0.dip0.t-ipconnect.de. [2003:cb:c702:5e00:8e78:71f3:6243:77f0]) by smtp.gmail.com with ESMTPSA id i17-20020a5d5591000000b002eaac3a9beesm169318wrv.8.2023.04.03.07.43.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Apr 2023 07:43:10 -0700 (PDT) Message-ID: <053a9ccd-4205-7a76-70c3-c256bd995a1f@redhat.com> Date: Mon, 3 Apr 2023 16:43:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCHv9 03/14] mm/page_alloc: Fake unaccepted memory Content-Language: en-US To: "Kirill A. Shutemov" , Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel Cc: 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 References: <20230330114956.20342-1-kirill.shutemov@linux.intel.com> <20230330114956.20342-4-kirill.shutemov@linux.intel.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230330114956.20342-4-kirill.shutemov@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- Thanks, David / dhildenb