Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp376769pxb; Tue, 12 Apr 2022 04:07:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHrT0FeRcgFHfouhXCxcDf9rKk1VM/iwsptLOp131Fmwy+jXW20dHK2+2o2DphrS1wSnw6 X-Received: by 2002:a17:906:7f02:b0:6cf:86d8:c31c with SMTP id d2-20020a1709067f0200b006cf86d8c31cmr35362942ejr.518.1649761655641; Tue, 12 Apr 2022 04:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649761655; cv=none; d=google.com; s=arc-20160816; b=Qv8xmGARXLcq+UMJ4yESSMxHOAVUjmEFOdi978UD+5nhv0N+iccc8dC2n8ahYyAbaW ng8x90//H3uj8/CC+w6lqY1S82TOyjqbZBKHKyJQZdvYqoGmYjDCysYUq5Zb2oJuwAhj piOh9DUZ4tz1IgnOPkfCyzakxPtqXSfLI+LPLhPfmcknd0Zc//fnnxSF0zqWUlzQjXSQ YGajnTIrzb/EotbAaF/N+yMRT95vwK+YuH8WQxs5walp2zw1OPg7+xEWXlXWlFWNpNiu mwG1okEKXPYGpilzIStEsidX164J48sRcXYX+5KCaO/7LqI6bS4exia8/wBZRb59yL7C XcYg== 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=sI+CKaqjeLSRPAY+LGQfv54eFjnOUGa/yEw/6x76vKY=; b=C/OPlxI5hDK1y2ELdiQpR9thxxhy/9nNPRZZ25Qj0DV9Fu05HV3EftF4lafkmFQ13j HvaKbHPd/se9LXr11VbF6AML1qqVRplmcyYEaH5rKdi7bdhVXZoYIp+3Sxem1a6BVol1 BqO5LSj9NQNdgx1B/X5Tjf0cwfsaSWgtQBXwBE5IVeBUHlz7i8bhcWmejrv2JY93ozTm wQXUlMLke/c9uga98bLruRhRS0r9XGgbfNRXPpY464Zfm3oS0PNIebP0zQYOD3d3vYi6 uRFRm1DghCA6H45qca/ELvPkh8nqibMqHq2h5nHB0cNH/75mQTMhhNZ3JturBhV6WkQi 1Q8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b0U6WOeo; 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 dc24-20020a170906c7d800b006e88ceb9a3csi4685124ejb.274.2022.04.12.04.07.04; Tue, 12 Apr 2022 04:07:35 -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=b0U6WOeo; 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 S239116AbiDHTG2 (ORCPT + 99 others); Fri, 8 Apr 2022 15:06:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239108AbiDHTG0 (ORCPT ); Fri, 8 Apr 2022 15:06:26 -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 ESMTP id 7544FF8EC7 for ; Fri, 8 Apr 2022 12:04:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649444661; 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=sI+CKaqjeLSRPAY+LGQfv54eFjnOUGa/yEw/6x76vKY=; b=b0U6WOeo0aU0PDAPIuGmyGLW7kFX6CvC4Rc5Bgv+0xBs9UFa9z/G3if/0FNGTOV/JzR53K Ngo1oDpwOuQLrMp4np+bJu28LkNtKSrltYDCRE9LG7wQjp+8FEEYHjU+SQarn9Vq0c9kk5 IeDascBapYORfN3SwIRx56PFy4owsT4= 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-576-hO6NJAVCNauBALBdnmK_uQ-1; Fri, 08 Apr 2022 15:04:20 -0400 X-MC-Unique: hO6NJAVCNauBALBdnmK_uQ-1 Received: by mail-wm1-f71.google.com with SMTP id h18-20020a05600c351200b0038e82e6321bso2594991wmq.5 for ; Fri, 08 Apr 2022 12:04:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=sI+CKaqjeLSRPAY+LGQfv54eFjnOUGa/yEw/6x76vKY=; b=iODYTu0Lo+EsAWs2x3DMpmX5Ct6nBBA+2l24xNoPTjOsnH3EfGzDJ40bveeEuFRyXf d4vXcVz4YbgCOsnDTsSoIcaUIVfoSL6JT5eqDdZCZzX8NJlAjpaNPMmSLB4oiZaTXa7L wGJZCwcGIAM7XDzQnQa1esKhtC2FunE1dUA8tsAVUHNqxHKc8bf3bh+W6a9dSEo6O08v 7eNYlbGtBkwtClde8bZMd41FO6jMCIkT+JPLcK0l4Ys0V8vN8okfy+P7t9D+QvWdpXEo lSM14d4k9dCJO+OHWTxNNqLWTou2UfQj08Z3QqjTaHvHdEH8S1m5qP93OlaxtYH6OlCO 9Cpw== X-Gm-Message-State: AOAM532vDoxEj1H+zk6hEQtt6O3zoBfwjv8p1IJdhffBC3dDjNrY/K9h CeVLr/Kyx5aY+pHV6lPgKrqSzAQJqWniZOAuaQwc+ilQB6QDwynktYiL1YuJKXgSwZrxwB9EEdb C/I5OV/+F5kHoz/5NdXvP6tag X-Received: by 2002:adf:9f03:0:b0:207:9071:1766 with SMTP id l3-20020adf9f03000000b0020790711766mr4743653wrf.331.1649444659313; Fri, 08 Apr 2022 12:04:19 -0700 (PDT) X-Received: by 2002:adf:9f03:0:b0:207:9071:1766 with SMTP id l3-20020adf9f03000000b0020790711766mr4743612wrf.331.1649444658934; Fri, 08 Apr 2022 12:04:18 -0700 (PDT) Received: from ?IPV6:2003:cb:c704:fd00:612:f12b:a4a2:26b0? (p200300cbc704fd000612f12ba4a226b0.dip0.t-ipconnect.de. [2003:cb:c704:fd00:612:f12b:a4a2:26b0]) by smtp.gmail.com with ESMTPSA id u23-20020a7bcb17000000b0037bdfa1665asm14481015wmj.18.2022.04.08.12.04.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Apr 2022 12:04:18 -0700 (PDT) Message-ID: <0cbee9cc-f89a-81f2-f24a-784b0fd33bab@redhat.com> Date: Fri, 8 Apr 2022 21:04:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCHv4 1/8] mm: Add support for 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 , Varad Gautam , Dario Faggioli , Dave Hansen , Brijesh Singh , Mike Rapoport , x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport References: <20220405234343.74045-1-kirill.shutemov@linux.intel.com> <20220405234343.74045-2-kirill.shutemov@linux.intel.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220405234343.74045-2-kirill.shutemov@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 06.04.22 01:43, Kirill A. Shutemov wrote: > UEFI Specification version 2.9 introduces the concept of memory > acceptance. Some Virtual Machine platforms, such as Intel TDX or AMD > SEV-SNP, requiring memory to be accepted before it can be used by the > guest. Accepting happens via a protocol specific for the Virtual Machine > platform. > > Accepting memory is costly and it makes VMM allocate memory for the > accepted guest physical address range. It's better to postpone memory > acceptance until memory is needed. It lowers boot time and reduces > memory overhead. > > Support of such memory requires a few changes in core-mm code: > > - memblock has to accept memory on allocation; > > - page allocator has to accept memory on the first allocation of the > page; > > Memblock change is trivial. > > The page allocator is modified to accept pages on the first allocation. > PageUnaccepted() is used to indicate that the page requires acceptance. > > Kernel only needs to accept memory once after boot, so during the boot > and warm up phase there will be a lot of memory acceptance. After things > are settled down the only price of the feature if couple of checks for > PageUnaccepted() in allocate and free paths. The check refers a hot > variable (that also encodes PageBuddy()), so it is cheap and not visible > on profiles. > > Architecture has to provide two helpers if it wants to support > unaccepted memory: > > - accept_memory() makes a range of physical addresses accepted. > > - memory_is_unaccepted() checks anything within the range of physical > addresses requires acceptance. > > Signed-off-by: Kirill A. Shutemov > Acked-by: Mike Rapoport # memblock Thanks, I skimmed over most parts and nothing obvious jumped at me. Dave has some good suggestions; I'll try giving it a thorough in the near future. -- Thanks, David / dhildenb