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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A351DC433F5 for ; Fri, 8 Apr 2022 19:04:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0441B6B0072; Fri, 8 Apr 2022 15:04:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F341F6B0073; Fri, 8 Apr 2022 15:04:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD4FA6B0074; Fri, 8 Apr 2022 15:04:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id D05596B0072 for ; Fri, 8 Apr 2022 15:04:22 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9A5F522322 for ; Fri, 8 Apr 2022 19:04:22 +0000 (UTC) X-FDA: 79334637564.09.62379DD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 1ABEEC0008 for ; Fri, 8 Apr 2022 19:04:21 +0000 (UTC) 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-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-576-xrGKYGSmNryBes6yoGXJqw-1; Fri, 08 Apr 2022 15:04:20 -0400 X-MC-Unique: xrGKYGSmNryBes6yoGXJqw-1 Received: by mail-wm1-f69.google.com with SMTP id n21-20020a05600c4f9500b0038e3b0aa367so4395126wmq.1 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=NOaaBeHni68Ck9GzEvVH+Q6dAS46lhLoj1N5ahrcp6X7IKR6W+2DH8Z9/ixhqfMd5E LZuzqjCr1tqR1FEY/sEDE7gNJ+9+JkwGpVtl5T4O7yNmY5q4xF1eOSmW7iNEwbFR0Laf Q4+TPuoCXnR6F87OdzA4dGXygRGLYIuovfkKakit4FbqtpAd+xB2ah/eY8eKsAmXBXBz 2MoAbfqS8vUTDXCwHQwpnLmLmYFP/JShd9r0gPcjxN358wNBtAFJq8gxjqyvp8p6yGuE piTY+jfnXwEwE3VvImhURz8CAETvNeOjTsO5KcGTUVtwzGZYXo4qKP2t8I8vKjyIonFi GPxw== X-Gm-Message-State: AOAM531wvNZm1k3WajRQIH9K3iLjNPsFBj83sOHREERogUkfW0t4Rfj4 7UFY8WhGOTsxloWdc4xhn6QAdKRJbx5KFIycnF26eV1e41h5+4mfpzVgJZEbVEPn/tBK0Ir8dBf 5LNOR4Tacx5Q= X-Received: by 2002:adf:9f03:0:b0:207:9071:1766 with SMTP id l3-20020adf9f03000000b0020790711766mr4743632wrf.331.1649444659289; Fri, 08 Apr 2022 12:04:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwyaFoxo2wRi67tJhuDxDonRbQNSmnOVJ6SXAc1V3MXq6++aK0JF36Ux0bYx5kIK0LPTcQEw== 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 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> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=b0U6WOeo; spf=none (imf28.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1ABEEC0008 X-Stat-Signature: 6ak1xo4k1b13xjxj4xktgyoiueb7fx3b X-HE-Tag: 1649444661-4968 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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