[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ff9e0bad-be9a-97ac-ae88-d22bcfbe80d4@redhat.com>
Date: Tue, 12 Apr 2022 10:15:07 +0200
From: David Hildenbrand <david@...hat.com>
To: Dave Hansen <dave.hansen@...el.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Borislav Petkov <bp@...en8.de>,
Andy Lutomirski <luto@...nel.org>,
Sean Christopherson <seanjc@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Joerg Roedel <jroedel@...e.de>,
Ard Biesheuvel <ardb@...nel.org>
Cc: Andi Kleen <ak@...ux.intel.com>,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
David Rientjes <rientjes@...gle.com>,
Vlastimil Babka <vbabka@...e.cz>,
Tom Lendacky <thomas.lendacky@....com>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Ingo Molnar <mingo@...hat.com>,
Varad Gautam <varad.gautam@...e.com>,
Dario Faggioli <dfaggioli@...e.com>,
Brijesh Singh <brijesh.singh@....com>,
Mike Rapoport <rppt@...nel.org>, x86@...nel.org,
linux-mm@...ck.org, linux-coco@...ts.linux.dev,
linux-efi@...r.kernel.org, linux-kernel@...r.kernel.org,
Mike Rapoport <rppt@...ux.ibm.com>
Subject: Re: [PATCHv4 1/8] mm: Add support for unaccepted memory
On 08.04.22 21:11, Dave Hansen wrote:
> On 4/5/22 16:43, Kirill A. Shutemov wrote:
>> 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.
>
> Let's also not sugar-coat this. Page acceptance is hideously slow.
> It's agonizingly slow. To boot, it's done holding a global spinlock
> with interrupts disabled (see patch 6/8). At the very, very least, each
> acceptance operation involves a couple of what are effectively ring
> transitions, a 2MB memset(), and a bunch of cache flushing.
>
> The system is going to be downright unusable during this time, right?
>
> Sure, it's *temporary* and only happens once at boot. But, it's going
> to suck.
>
> Am I over-stating this in any way?
>
> The ACCEPT_MEMORY vmstat is good to have around. Thanks for adding it.
> But, I think we should also write down some guidance like:
>
> If your TDX system seems as slow as snail after boot, look at
> the "accept_memory" counter in /proc/vmstat. If it is
> incrementing, then TDX memory acceptance is likely to blame.
>
> Do we need anything more discrete to tell users when acceptance is over?
> For instance, maybe they run something and it goes really slow, they
> watch "accept_memory" until it stops. They rejoice at their good
> fortune! Then, memory allocation starts falling over to a new node and
> the agony beings anew.
>
> I can think of dealing with this in two ways:
>
> cat /sys/.../unaccepted_pages_left
>
> which just walks the bitmap and counts the amount of pages remaining. or
> something like:
>
> echo 1 > /sys/devices/system/node/node0/make_the_pain_stop
>
> Which will, well, make the pain stop on node0.
>
Either I'm missing something important or the random pain might just
take a really long time to stop?
I mean, we tend to reallocate the memory first that we freed last
(putting it to the head of the freelist when freeing and picking from
the head when allocating).
So unless your kernel goes crazy and allocates each and every page right
after boot, essentially accepting all memory, you might have random
unaccepted pages lurking at the tail of the freelists.
So if the VM is running for 355 days without significant memory
pressure, you can still run into unaccepted pages at day 356 that
results in a random delay due to acceptance of memory.
I think we most certainly want some way to make the random pain stop, or
to make the random pain go away after boot quickly. The
"unaccepted_pages_left" indicator would just be a "hey, there might be
random delays, but you cannot do anything about it". Magic toggles like
"make_the_pain_stop" are not so nice.
Can we simply automate this using a kthread or smth like that, which
just traverses the free page lists and accepts pages (similar, but
different to free page reporting)?
--
Thanks,
David / dhildenb
Powered by blists - more mailing lists