Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4641485rwl; Mon, 3 Apr 2023 07:45:18 -0700 (PDT) X-Google-Smtp-Source: AKy350aUr8K9PmTxlkBmNBy93xMPk3y94CHtM5ALpjGqaOPTh/gmdah+I4YLvZyATtid7CY7hgsk X-Received: by 2002:a17:902:f68e:b0:1a2:8940:6da4 with SMTP id l14-20020a170902f68e00b001a289406da4mr19880507plg.29.1680533118373; Mon, 03 Apr 2023 07:45:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680533118; cv=none; d=google.com; s=arc-20160816; b=b6zifXWF7WAnX0MUvT3fuVjPlgn626NvP72hVSv34VjhESQdvDHbAUZA9WeYlsjnK7 2bjVNhNJz6dv9Adf2CSS3R+r7OhCYNCbQwWcSgV09NxqjLTKHGYs1jk5EnrquvUlAFII GZq2apkoHNjuT3sywJQXImn+zM/cOckEvoZISavSdh2VZVQpk3XGSyUtcx3XorEirYIk peya4wp+6uIXUwSVVvOmg0mT5DEBfioQWctYhnCU/RaQMusHaBidSdlFmoR+AE28BaC0 7yQArRGFm+PtqwODQG3fTzHnBiQzgZnkW1SJyghbRpLhWf+O3evg9RMCVklvf59vHJg/ owUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=/eYb2XMUpR9VXDleQG1dvUeP259a87ERPUWeMJE/H5g=; b=Va/1sDfl2/dSpeCOHL8gCinvbQrIKX6qv2H2bk4CRIWsWNOkWXlDQNO1M27LJvVSNR s8EuJteL7JmmSyhDl24adVMcaqBwsdhpN4hnEW3C6j3b1BQi0eOo4UfDXO/eToo811jI 6m5j5D6taTFNerS3JwBem0dvc+c1RbRauRDOguVWHzpSleiWRGJg/DRKj7z+FtWYXGv2 hpH9E4QAwJLbuATu/ftAgm0ydmPT2qBwstniVFtz696RFRz+NKdpyMe5rAvwho7BJgJq YWZijFSaTO4oVLrJ3D35QPK1yNtnA1emiUU4qHDK+Wh5Q8i10+DpNW9/JF9LmL5Q/Bcj FCYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Elevh4Zd; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i18-20020a170902e49200b001a1c7fe5bccsi7786563ple.248.2023.04.03.07.45.06; Mon, 03 Apr 2023 07:45:18 -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=@redhat.com header.s=mimecast20190719 header.b=Elevh4Zd; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233971AbjDCOo5 (ORCPT + 99 others); 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-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 X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 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