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 X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04AF5C4338F for ; Tue, 10 Aug 2021 07:48:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 84F7660F38 for ; Tue, 10 Aug 2021 07:48:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 84F7660F38 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9CF496B0071; Tue, 10 Aug 2021 03:48:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 980748D0001; Tue, 10 Aug 2021 03:48:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 847946B0073; Tue, 10 Aug 2021 03:48:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0034.hostedemail.com [216.40.44.34]) by kanga.kvack.org (Postfix) with ESMTP id 63C996B0071 for ; Tue, 10 Aug 2021 03:48:10 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E94EF180361AB for ; Tue, 10 Aug 2021 07:48:09 +0000 (UTC) X-FDA: 78458392698.21.2BB63D6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 6FA3190025A9 for ; Tue, 10 Aug 2021 07:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628581688; 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=qyiZQfgk3j2MX/M11JnnsZSFCKezwOSWW55OSmu9ncY=; b=WZf8WkUuIjZIkJrVlXCuL7mkeR/J3GwD+1LVyeZMU6qogn1BB5J6XAv0ktL+IrI0aZwda8 h1/KfGnO6nLKCs7EyRR2uUsZFiC1FICxwlqnSJ8VTZcycmTZCYBDSX60mAnizXrjLboIHw a+0KbZ8YxToz02tH/D36ydoR1GSKiiA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-183-5GCyuSKtPYOW1iAG19A3qw-1; Tue, 10 Aug 2021 03:48:07 -0400 X-MC-Unique: 5GCyuSKtPYOW1iAG19A3qw-1 Received: by mail-wm1-f71.google.com with SMTP id e21-20020a05600c4b95b029025b007a168dso727235wmp.4 for ; Tue, 10 Aug 2021 00:48:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=qyiZQfgk3j2MX/M11JnnsZSFCKezwOSWW55OSmu9ncY=; b=YDISvijZGNlcpVjN3Y8P8dvVEIXvLxLYgU3xQ3nPSHkk3CMMO2ZHbfPdmj3mraGJPV EPlBaXjzVUtnMErnHyFXP1WR97rJ2tdzLvo8duAH49jKVwTNXz35r7ZbCUtymiHr7wDE 3KzUK7Zw5mxNzfJ6m9x7tXMcikhSzKLJYvIZKHwEDbXeSMCsFWf7BQJZj2WgvDciEY4g 197wICQNWS4DDJgDKUDuX/YIKsWxaqoaQq55lYYU6Oi4LQ7ETC1IOuJLGCrrJ4sNvQQa mD0dhe3vmU073bnBaATEJuyQmJaL5D5JrKjMMN2+jYWEv2XDIzfy6IajsDZRXNNZjnxh FiGg== X-Gm-Message-State: AOAM530+hRddllcK7g3gsJJqwuL2bWtke/r8+rY+5USlGgwAEKYfBxbn RXEffD5h4BqZofu+bVTybV5XWj/IGiwDQMsLOLzfdU9Lo3dDm+8+KiuYC2zoi2NRlrnRE78yfJQ po+Z85AovCWY= X-Received: by 2002:a1c:3847:: with SMTP id f68mr118829wma.27.1628581686198; Tue, 10 Aug 2021 00:48:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3nGwLd7fpNoXzdy/z33L+jLJPlF/DBsrza1eqzfBVIcellVymHPn+c/mpsbj+CQSbYYkvpg== X-Received: by 2002:a1c:3847:: with SMTP id f68mr118784wma.27.1628581685855; Tue, 10 Aug 2021 00:48:05 -0700 (PDT) Received: from ?IPv6:2003:d8:2f0a:7f00:fad7:3bc9:69d:31f? (p200300d82f0a7f00fad73bc9069d031f.dip0.t-ipconnect.de. [2003:d8:2f0a:7f00:fad7:3bc9:69d:31f]) by smtp.gmail.com with ESMTPSA id e11sm2137939wrm.80.2021.08.10.00.48.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Aug 2021 00:48:05 -0700 (PDT) To: "Kirill A. Shutemov" , Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel Cc: Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Varad Gautam , Dario Faggioli , x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" References: <20210810062626.1012-1-kirill.shutemov@linux.intel.com> <20210810062626.1012-2-kirill.shutemov@linux.intel.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH 1/5] mm: Add support for unaccepted memory Message-ID: Date: Tue, 10 Aug 2021 09:48:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210810062626.1012-2-kirill.shutemov@linux.intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6FA3190025A9 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WZf8WkUu; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf29.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com X-Stat-Signature: gdgc5c9zpcysjbp539tge8fdasz59iec X-HE-Tag: 1628581689-167180 Content-Transfer-Encoding: quoted-printable 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 10.08.21 08:26, Kirill A. Shutemov wrote: > UEFI Specification version 2.9 introduces 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 Virtrual Machine > platform. >=20 > Accepting memory is costly and it makes VMM allocate memory for the > accepted guest physical address range. It's better to postpone memory > acceptation until memory is needed. It lowers boot time and reduces > memory overhead. >=20 > Support of such memory requires few changes in core-mm code: >=20 > - memblock has to accept memory on allocation; >=20 > - page allocator has to accept memory on the first allocation of the > page; >=20 > Memblock change is trivial. >=20 > Page allocator is modified to accept pages on the first allocation. > PageOffline() is used to indicate that the page requires acceptance. > The flag currently used by hotplug and balloon. Such pages are not > available to page allocator. >=20 > An architecture has to provide three helpers if it wants to support > unaccepted memory: >=20 > - accept_memory() makes a range of physical addresses accepted. >=20 > - maybe_set_page_offline() marks a page PageOffline() if it requires > acceptance. Used during boot to put pages on free lists. >=20 > - clear_page_offline() clears makes a page accepted and clears > PageOffline(). >=20 > Signed-off-by: Kirill A. Shutemov > --- > mm/internal.h | 14 ++++++++++++++ > mm/memblock.c | 1 + > mm/page_alloc.c | 13 ++++++++++++- > 3 files changed, 27 insertions(+), 1 deletion(-) >=20 > diff --git a/mm/internal.h b/mm/internal.h > index 31ff935b2547..d2fc8a17fbe0 100644 > --- a/mm/internal.h > +++ b/mm/internal.h > @@ -662,4 +662,18 @@ void vunmap_range_noflush(unsigned long start, uns= igned long end); > int numa_migrate_prep(struct page *page, struct vm_area_struct *vma, > unsigned long addr, int page_nid, int *flags); > =20 > +#ifndef CONFIG_UNACCEPTED_MEMORY > +static inline void maybe_set_page_offline(struct page *page, unsigned = int order) > +{ > +} > + > +static inline void clear_page_offline(struct page *page, unsigned int = order) > +{ > +} > + > +static inline void accept_memory(phys_addr_t start, phys_addr_t end) > +{ > +} Can we find better fitting names for the first two? The function names=20 are way too generic. For example: accept_or_set_page_offline() accept_and_clear_page_offline() I thought for a second if PAGE_TYPE_OPS(Unaccepted, offline) makes sense as well, not sure. Also, please update the description of PageOffline in page-flags.h to=20 include the additional usage with PageBuddy set at the same time. I assume you don't have to worry about page_offline_freeze/thaw ... as=20 we only set PageOffline initially, but not later at runtime when other=20 subsystems (/proc/kcore) might stumble over it. --=20 Thanks, David / dhildenb