From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
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>, Ard Biesheuvel <ardb@kernel.org>,
Andi Kleen <ak@linux.intel.com>,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@linux.intel.com>,
David Rientjes <rientjes@google.com>,
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>,
Dario Faggioli <dfaggioli@suse.com>,
Dave Hansen <dave.hansen@intel.com>,
Mike Rapoport <rppt@kernel.org>,
David Hildenbrand <david@redhat.com>,
Mel Gorman <mgorman@techsingularity.net>,
marcelo.cerri@canonical.com, tim.gardner@canonical.com,
khalid.elmously@canonical.com, philip.cox@canonical.com,
aarcange@redhat.com, peterx@redhat.com, x86@kernel.org,
linux-mm@kvack.org, linux-coco@lists.linux.dev,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCHv9 03/14] mm/page_alloc: Fake unaccepted memory
Date: Mon, 3 Apr 2023 17:39:15 +0300 [thread overview]
Message-ID: <20230403143915.uc4tnpgmssvpdqxu@box.shutemov.name> (raw)
In-Reply-To: <835dfe65-d9dd-0b16-37d4-920e97f1bca0@suse.cz>
On Mon, Apr 03, 2023 at 03:39:53PM +0200, Vlastimil Babka wrote:
> On 3/30/23 13:49, Kirill A. Shutemov wrote:
> > For testing purposes, it is useful to fake unaccepted memory in the
> > system. It helps to understand unaccepted memory overhead to the page
> > allocator.
>
> Ack on being useful for testing, but the question is if we want to also
> merge this patch into mainline as it is?
I don't insist on getting it upstream, but it can be handy to debug
related bugs in the future.
> > The patch allows to treat memory above the specified physical memory
> > address as unaccepted.
> >
> > The change only fakes unaccepted memory for page allocator. Memblock is
> > not affected.
> >
> > It also assumes that arch-provided accept_memory() on already accepted
> > memory is a nop.
>
> I guess to be in mainline it would have to at least gracefully handle the
> case of accept_memory actually not being a nop, and running on a system with
> actual unaccepted memory (probably by ignoring the parameter in such case).
> Then also the parameter would have to be documented.
As it is written now, accept_memory() is nop on system with real
unaccepted memory if the memory is already accepted. Arch-specific code
will check against own records to see if the memory needs accepting. If
not, just return.
And the option will not interfere with unaccepted memory declared by EFI
memmap. It can extend it, but that's it.
Looks safe to me.
> Speaking of documented parameters, I found at least two that seem a more
> generic variant of this (but I didn't look closely if that makes sense):
>
> efi_fake_mem= nn[KMG]@ss[KMG]:aa[,nn[KMG]@ss[KMG]:aa,..] [EFI; X86]
> Add arbitrary attribute to specific memory range by
> updating original EFI memory map.
>
> memmap=<size>%<offset>-<oldtype>+<newtype>
> [KNL,ACPI] Convert memory within the specified region
> from <oldtype> to <newtype>. If "-<oldtype>" is left
>
> Would any of those be usable for this usecase?
Oh. I missed them. Will take a closer look.
>
> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > ---
> > mm/page_alloc.c | 21 +++++++++++++++++++++
> > 1 file changed, 21 insertions(+)
> >
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index d62fcb2f28bd..509a93b7e5af 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -7213,6 +7213,8 @@ static DEFINE_STATIC_KEY_FALSE(zones_with_unaccepted_pages);
> >
> > static bool lazy_accept = true;
> >
> > +static unsigned long fake_unaccepted_start = -1UL;
> > +
> > static int __init accept_memory_parse(char *p)
> > {
> > if (!strcmp(p, "lazy")) {
> > @@ -7227,11 +7229,30 @@ static int __init accept_memory_parse(char *p)
> > }
> > early_param("accept_memory", accept_memory_parse);
> >
> > +static int __init fake_unaccepted_start_parse(char *p)
> > +{
> > + if (!p)
> > + return -EINVAL;
> > +
> > + fake_unaccepted_start = memparse(p, &p);
> > +
> > + if (*p != '\0') {
> > + fake_unaccepted_start = -1UL;
> > + return -EINVAL;
> > + }
> > +
> > + return 0;
> > +}
> > +early_param("fake_unaccepted_start", fake_unaccepted_start_parse);
> > +
> > static bool page_contains_unaccepted(struct page *page, unsigned int order)
> > {
> > phys_addr_t start = page_to_phys(page);
> > phys_addr_t end = start + (PAGE_SIZE << order);
> >
> > + if (start >= fake_unaccepted_start)
> > + return true;
> > +
> > return range_contains_unaccepted_memory(start, end);
> > }
> >
>
--
Kiryl Shutsemau / Kirill A. Shutemov
next prev parent reply other threads:[~2023-04-03 14:39 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 11:49 [PATCHv9 00/14] mm, x86/cc: Implement support for unaccepted memory Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 01/14] x86/boot: Centralize __pa()/__va() definitions Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 02/14] mm: Add support for unaccepted memory Kirill A. Shutemov
2023-04-03 9:26 ` Vlastimil Babka
2023-04-03 10:02 ` Kirill A. Shutemov
2023-04-03 13:07 ` Vlastimil Babka
2023-03-30 11:49 ` [PATCHv9 03/14] mm/page_alloc: Fake " Kirill A. Shutemov
2023-04-03 13:39 ` Vlastimil Babka
2023-04-03 14:39 ` Kirill A. Shutemov [this message]
2023-04-03 15:50 ` Kirill A. Shutemov
2023-04-14 10:19 ` Kirill A. Shutemov
2023-04-03 14:43 ` David Hildenbrand
2023-04-03 14:47 ` Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 04/14] mm/page_alloc: Add sysfs handle to accept accept_memory Kirill A. Shutemov
2023-04-03 13:43 ` Vlastimil Babka
2023-04-03 14:41 ` Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 05/14] efi/x86: Get full memory map in allocate_e820() Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 06/14] x86/boot: Add infrastructure required for unaccepted memory support Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 07/14] efi/x86: Implement support for unaccepted memory Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 08/14] x86/boot/compressed: Handle " Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 09/14] x86/mm: Reserve unaccepted memory bitmap Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 10/14] x86/mm: Provide helpers for unaccepted memory Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 11/14] x86/mm: Avoid load_unaligned_zeropad() stepping into " Kirill A. Shutemov
2023-04-03 13:28 ` Vlastimil Babka
2023-04-03 14:42 ` Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 12/14] x86/tdx: Make _tdx_hypercall() and __tdx_module_call() available in boot stub Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 13/14] x86/tdx: Refactor try_accept_one() Kirill A. Shutemov
2023-03-30 11:49 ` [PATCHv9 14/14] x86/tdx: Add unaccepted memory support Kirill A. Shutemov
2023-04-03 14:42 ` [PATCHv9 00/14] mm, x86/cc: Implement support for unaccepted memory Vlastimil Babka
2023-04-16 19:19 ` Kirill A. Shutemov
2023-04-17 7:37 ` Vlastimil Babka
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=20230403143915.uc4tnpgmssvpdqxu@box.shutemov.name \
--to=kirill@shutemov.name \
--cc=aarcange@redhat.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=david@redhat.com \
--cc=dfaggioli@suse.com \
--cc=jroedel@suse.de \
--cc=khalid.elmously@canonical.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-coco@lists.linux.dev \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=marcelo.cerri@canonical.com \
--cc=mgorman@techsingularity.net \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=peterz@infradead.org \
--cc=philip.cox@canonical.com \
--cc=rientjes@google.com \
--cc=rppt@kernel.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=tim.gardner@canonical.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).