From: David Hildenbrand <david@redhat.com>
To: Joerg Roedel <jroedel@suse.de>, Dave Hansen <dave.hansen@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>,
"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>,
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, 17 Aug 2021 17:00:55 +0200 [thread overview]
Message-ID: <b0228048-d2c2-6081-cfae-147e17acf785@redhat.com> (raw)
In-Reply-To: <YRaGch+D5HPtUk9l@suse.de>
On 13.08.21 16:49, Joerg Roedel wrote:
> Hi Dave,
>
> On Thu, Aug 12, 2021 at 07:14:20AM -0700, Dave Hansen wrote:
>> maybe_accept_page()
>> {
>> unsigned long huge_pfn = page_to_phys(page) / PMD_SIZE;
>>
>> /* Test the bit before taking any locks: */
>> if (test_bit(huge_pfn, &accepted_bitmap))
>> return;
>>
>> spin_lock_irq();
>> /* Retest inside the lock: */
>> if (test_bit(huge_pfn, &accepted_bitmap))
>> return;
>> tdx_accept_page(page, PMD_SIZE);
>> set_bit(huge_pfn, &accepted_bitmap));
>> spin_unlock_irq();
>> }
>
> Yeah, this could work, but the global lock is likely the show-stopper
> here. For SNP we also not allowed to double-validate, so we need
> something that basically indicates 'validation-is-ongoing' on a per 2MB
> basis.
>
> I am not an mm expert, but a page flag probably doesn't work. The flag
> would be on the head of the 2MB range and when that page is already used
> somewhere else there is no guarantee that the flag will survive. But
> correct me if I am wrong here :)
>
> The other options I can come up with are not great either:
>
> 1) using an AVL bit in the direct-mapping PMD of that page. The
> page-table would only be walked if the bit in the
> accept_bitmap is clear. But I am not sure that all memory
> which needs to be validated is in the direct-map.
>
> 2) Use another page-sized bitmap. If the machine has more than
> 64GB of memory the bit index is wrapped around. This
> shouldn't be a performance problem at runtime, if this page
> is only consulted when the valid bit is clear in the
> accept_bitmap.
>
> MM experts could certainly come up with better ideas :)
Not sure if already discussed, but what about making sure that free
pages are not a mixture (partially unaccepted, partially accepted).
You'd have to expose the pages in that granularity to the buddy
(__free_pages_core), indicating the state. You'd have to reject merging
pages of differing acceptance state.
Accepting a page would then be handled outside of the zone lock,
completely controlled by the state.
So a page in the buddy would either be completely accepted or completely
unaccepted, signaled e.g., by PageOffline().
Consequently, when allocating a 4KiB page, you'd split an unaccepted
2MiB page into separate unaccepted pages. You'd grab one of the
unaccepted 4KiB pages and accept it before initializing it and handing
it out.
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2021-08-17 15:01 UTC|newest]
Thread overview: 49+ 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 ` [PATCH 1/5] mm: Add " Kirill A. Shutemov
2021-08-10 7:48 ` David Hildenbrand
2021-08-10 15:02 ` Kirill A. Shutemov
2021-08-10 15:21 ` David Hildenbrand
2021-08-12 20:34 ` Kirill A. Shutemov
2021-08-10 18:13 ` Dave Hansen
2021-08-10 18:30 ` Andi Kleen
2021-08-10 18:56 ` Dave Hansen
2021-08-10 19:23 ` Andi Kleen
2021-08-10 19:46 ` Dave Hansen
2021-08-10 21:20 ` Andi Kleen
2021-08-12 8:19 ` Joerg Roedel
2021-08-12 14:14 ` Dave Hansen
2021-08-12 20:49 ` Kirill A. Shutemov
2021-08-12 20:59 ` Dave Hansen
2021-08-12 21:23 ` Kirill A. Shutemov
2021-08-13 14:49 ` Joerg Roedel
2021-08-17 15:00 ` David Hildenbrand [this message]
2021-08-19 9:55 ` Joerg Roedel
2021-08-19 10:06 ` David Hildenbrand
2021-08-10 20:50 ` Dave Hansen
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 17:50 ` Dave Hansen
2021-08-12 21:14 ` Kirill A. Shutemov
2021-08-12 21:43 ` Dave Hansen
2021-08-10 18:30 ` Dave Hansen
2021-08-10 19:08 ` Kirill A. Shutemov
2021-08-10 19:19 ` Dave Hansen
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 ` [PATCH 4/5] x86/mm: Provide helpers for " Kirill A. Shutemov
2021-08-10 18:16 ` Dave Hansen
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 14:08 ` [PATCH 0/5] x86: Impplement support for unaccepted memory Dave Hansen
2021-08-10 15:15 ` Kirill A. Shutemov
2021-08-10 15:51 ` Dave Hansen
2021-08-10 17:31 ` Kirill A. Shutemov
2021-08-10 17:36 ` Dave Hansen
2021-08-10 17:51 ` Kirill A. Shutemov
2021-08-10 18:19 ` Dave Hansen
2021-08-10 18:39 ` Kirill A. Shutemov
2021-08-12 8:23 ` Joerg Roedel
2021-08-12 10:10 ` Kirill A. Shutemov
2021-08-12 19:33 ` Andi Kleen
2021-08-12 20:22 ` Kirill A. Shutemov
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=b0228048-d2c2-6081-cfae-147e17acf785@redhat.com \
--to=david@redhat.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).