All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: "Kirill A. Shutemov" <kirill@shutemov.name>,
	Borislav Petkov <bp@alien8.de>, Andy Lutomirski <luto@kernel.org>,
	Sean Christopherson <seanjc@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Joerg Roedel <jroedel@suse.de>
Cc: Andi Kleen <ak@linux.intel.com>,
	Kuppuswamy Sathyanarayanan
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	David Rientjes <rientjes@google.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	Varad Gautam <varad.gautam@suse.com>,
	Dario Faggioli <dfaggioli@suse.com>,
	x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev,
	linux-kernel@vger.kernel.org,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH 1/5] mm: Add support for unaccepted memory
Date: Tue, 10 Aug 2021 09:48:04 +0200	[thread overview]
Message-ID: <dd4b7aff-ccf3-24f6-3f6e-14c4b6aa8b64@redhat.com> (raw)
In-Reply-To: <20210810062626.1012-2-kirill.shutemov@linux.intel.com>

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.
> 
> 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.
> 
> Support of such memory requires 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.
> 
> 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.
> 
> An architecture has to provide three helpers if it wants to support
> unaccepted memory:
> 
>   - accept_memory() makes a range of physical addresses accepted.
> 
>   - maybe_set_page_offline() marks a page PageOffline() if it requires
>     acceptance. Used during boot to put pages on free lists.
> 
>   - clear_page_offline() clears makes a page accepted and clears
>     PageOffline().
> 
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> ---
>   mm/internal.h   | 14 ++++++++++++++
>   mm/memblock.c   |  1 +
>   mm/page_alloc.c | 13 ++++++++++++-
>   3 files changed, 27 insertions(+), 1 deletion(-)
> 
> 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, unsigned long end);
>   int numa_migrate_prep(struct page *page, struct vm_area_struct *vma,
>   		      unsigned long addr, int page_nid, int *flags);
>   
> +#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 
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 
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 
we only set PageOffline initially, but not later at runtime when other 
subsystems (/proc/kcore) might stumble over it.

-- 
Thanks,

David / dhildenb


  reply	other threads:[~2021-08-10  7:48 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10  6:26 [PATCH 0/5] x86: Impplement support for unaccepted memory Kirill A. Shutemov
2021-08-10  6:26 ` Kirill A. Shutemov
2021-08-10  6:26 ` [PATCH 1/5] mm: Add " Kirill A. Shutemov
2021-08-10  6:26   ` Kirill A. Shutemov
2021-08-10  7:48   ` David Hildenbrand [this message]
2021-08-10  7:48     ` David Hildenbrand
2021-08-10 15:02     ` Kirill A. Shutemov
2021-08-10 15:02       ` Kirill A. Shutemov
2021-08-10 15:21       ` David Hildenbrand
2021-08-10 15:21         ` David Hildenbrand
2021-08-12 20:34         ` Kirill A. Shutemov
2021-08-12 20:34           ` Kirill A. Shutemov
2021-08-10 18:13   ` Dave Hansen
2021-08-10 18:13     ` Dave Hansen
2021-08-10 18:30     ` Andi Kleen
2021-08-10 18:30       ` Andi Kleen
2021-08-10 18:56       ` Dave Hansen
2021-08-10 18:56         ` Dave Hansen
2021-08-10 19:23         ` Andi Kleen
2021-08-10 19:23           ` Andi Kleen
2021-08-10 19:46           ` Dave Hansen
2021-08-10 19:46             ` Dave Hansen
2021-08-10 21:20             ` Andi Kleen
2021-08-10 21:20               ` Andi Kleen
2021-08-12  8:19               ` Joerg Roedel
2021-08-12  8:19                 ` Joerg Roedel
2021-08-12 14:14                 ` Dave Hansen
2021-08-12 14:14                   ` Dave Hansen
2021-08-12 20:49                   ` Kirill A. Shutemov
2021-08-12 20:49                     ` Kirill A. Shutemov
2021-08-12 20:59                     ` Dave Hansen
2021-08-12 20:59                       ` Dave Hansen
2021-08-12 21:23                       ` Kirill A. Shutemov
2021-08-12 21:23                         ` Kirill A. Shutemov
2021-08-13 14:49                   ` Joerg Roedel
2021-08-13 14:49                     ` Joerg Roedel
2021-08-17 15:00                     ` David Hildenbrand
2021-08-17 15:00                       ` David Hildenbrand
2021-08-19  9:55                       ` Joerg Roedel
2021-08-19  9:55                         ` Joerg Roedel
2021-08-19 10:06                         ` David Hildenbrand
2021-08-19 10:06                           ` David Hildenbrand
2021-08-10 20:50     ` Dave Hansen
2021-08-10 20:50       ` Dave Hansen
2021-08-12 21:08       ` Kirill A. Shutemov
2021-08-12 21:08         ` Kirill A. Shutemov
2021-08-10  6:26 ` [PATCH 2/5] efi/x86: Implement " Kirill A. Shutemov
2021-08-10  6:26   ` Kirill A. Shutemov
2021-08-10 17:50   ` Dave Hansen
2021-08-10 17:50     ` Dave Hansen
2021-08-12 21:14     ` Kirill A. Shutemov
2021-08-12 21:14       ` Kirill A. Shutemov
2021-08-12 21:43       ` Dave Hansen
2021-08-12 21:43         ` Dave Hansen
2021-08-10 18:30   ` Dave Hansen
2021-08-10 18:30     ` Dave Hansen
2021-08-10 19:08     ` Kirill A. Shutemov
2021-08-10 19:08       ` Kirill A. Shutemov
2021-08-10 19:19       ` Dave Hansen
2021-08-10 19:19         ` Dave Hansen
2021-08-12 21:17         ` Kirill A. Shutemov
2021-08-12 21:17           ` Kirill A. Shutemov
2021-08-10  6:26 ` [PATCH 3/5] x86/boot/compressed: Handle " Kirill A. Shutemov
2021-08-10  6:26   ` Kirill A. Shutemov
2021-08-10  6:26 ` [PATCH 4/5] x86/mm: Provide helpers for " Kirill A. Shutemov
2021-08-10  6:26   ` Kirill A. Shutemov
2021-08-10 18:16   ` Dave Hansen
2021-08-10 18:16     ` Dave Hansen
2021-08-12 20:31     ` Kirill A. Shutemov
2021-08-12 20:31       ` Kirill A. Shutemov
2021-08-10  6:26 ` [PATCH 5/5] x86/tdx: Unaccepted memory support Kirill A. Shutemov
2021-08-10  6:26   ` Kirill A. Shutemov
2021-08-10 14:08 ` [PATCH 0/5] x86: Impplement support for unaccepted memory Dave Hansen
2021-08-10 14:08   ` Dave Hansen
2021-08-10 15:15   ` Kirill A. Shutemov
2021-08-10 15:15     ` Kirill A. Shutemov
2021-08-10 15:51     ` Dave Hansen
2021-08-10 15:51       ` Dave Hansen
2021-08-10 17:31       ` Kirill A. Shutemov
2021-08-10 17:31         ` Kirill A. Shutemov
2021-08-10 17:36         ` Dave Hansen
2021-08-10 17:36           ` Dave Hansen
2021-08-10 17:51           ` Kirill A. Shutemov
2021-08-10 17:51             ` Kirill A. Shutemov
2021-08-10 18:19             ` Dave Hansen
2021-08-10 18:19               ` Dave Hansen
2021-08-10 18:39               ` Kirill A. Shutemov
2021-08-10 18:39                 ` Kirill A. Shutemov
2021-08-12  8:23 ` Joerg Roedel
2021-08-12  8:23   ` Joerg Roedel
2021-08-12 10:10   ` Kirill A. Shutemov
2021-08-12 10:10     ` Kirill A. Shutemov
2021-08-12 19:33     ` Andi Kleen
2021-08-12 19:33       ` Andi Kleen
2021-08-12 20:22       ` Kirill A. Shutemov
2021-08-12 20:22         ` Kirill A. Shutemov
2021-08-13 14:56         ` Joerg Roedel
2021-08-13 14:56           ` Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dd4b7aff-ccf3-24f6-3f6e-14c4b6aa8b64@redhat.com \
    --to=david@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=dfaggioli@suse.com \
    --cc=jroedel@suse.de \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rientjes@google.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=varad.gautam@suse.com \
    --cc=vbabka@suse.cz \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.