From: David Hildenbrand <david@redhat.com>
To: Mike Rapoport <rppt@kernel.org>, linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andy Lutomirski <luto@kernel.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Kees Cook <keescook@chromium.org>,
Mike Rapoport <rppt@linux.ibm.com>,
Peter Zijlstra <peterz@infradead.org>,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
Vlastimil Babka <vbabka@suse.cz>,
x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 3/4] mm/page_alloc: introduce __GFP_PTE_MAPPED flag to allocate pte-mapped pages
Date: Wed, 25 Aug 2021 10:43:14 +0200 [thread overview]
Message-ID: <0a6341d6-c5be-ade3-9fb9-66cc8ebe1619@redhat.com> (raw)
In-Reply-To: <20210823132513.15836-4-rppt@kernel.org>
On 23.08.21 15:25, Mike Rapoport wrote:
> From: Mike Rapoport <rppt@linux.ibm.com>
>
> When __GFP_PTE_MAPPED flag is passed to an allocation request of order 0,
> the allocated page will be mapped at PTE level in the direct map.
>
> To reduce the direct map fragmentation, maintain a cache of 4K pages that
> are already mapped at PTE level in the direct map. Whenever the cache
> should be replenished, try to allocate 2M page and split it to 4K pages
> to localize shutter of the direct map. If the allocation of 2M page fails,
> fallback to a single page allocation at expense of the direct map
> fragmentation.
>
> The cache registers a shrinker that releases free pages from the cache to
> the page allocator.
>
> The __GFP_PTE_MAPPED and caching of 4K pages are enabled only if an
> architecture selects ARCH_WANTS_PTE_MAPPED_CACHE in its Kconfig.
>
> [
> cache management are mostly copied from
> https://lore.kernel.org/lkml/20210505003032.489164-4-rick.p.edgecombe@intel.com/
> ]
>
> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
> ---
> arch/Kconfig | 8 +
> arch/x86/Kconfig | 1 +
> include/linux/gfp.h | 11 +-
> include/linux/mm.h | 2 +
> include/linux/pageblock-flags.h | 26 ++++
> init/main.c | 1 +
> mm/internal.h | 3 +-
> mm/page_alloc.c | 261 +++++++++++++++++++++++++++++++-
> 8 files changed, 309 insertions(+), 4 deletions(-)
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 129df498a8e1..2db95331201b 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -243,6 +243,14 @@ config ARCH_HAS_SET_MEMORY
> config ARCH_HAS_SET_DIRECT_MAP
> bool
[...]
> +static int __pte_mapped_cache_init(struct pte_mapped_cache *cache)
> +{
> + int err;
> +
> + err = list_lru_init(&cache->lru);
> + if (err)
> + return err;
> +
> + cache->shrinker.count_objects = pte_mapped_cache_shrink_count;
> + cache->shrinker.scan_objects = pte_mapped_cache_shrink_scan;
> + cache->shrinker.seeks = DEFAULT_SEEKS;
> + cache->shrinker.flags = SHRINKER_NUMA_AWARE;
> +
> + err = register_shrinker(&cache->shrinker);
> + if (err)
> + goto err_list_lru_destroy;
With a shrinker in place, it really does somewhat feel like this should
be a cache outside of the buddy. Or at least moved outside of
page_alloc.c with a clean interface to work with the buddy.
But I only had a quick glimpse over this patch.
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2021-08-25 8:43 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-23 13:25 [RFC PATCH 0/4] mm/page_alloc: cache pte-mapped allocations Mike Rapoport
2021-08-23 13:25 ` [RFC PATCH 1/4] list: Support getting most recent element in list_lru Mike Rapoport
2021-08-23 13:25 ` [RFC PATCH 2/4] list: Support list head not in object for list_lru Mike Rapoport
2021-08-23 13:25 ` [RFC PATCH 3/4] mm/page_alloc: introduce __GFP_PTE_MAPPED flag to allocate pte-mapped pages Mike Rapoport
2021-08-23 20:29 ` Edgecombe, Rick P
2021-08-24 13:02 ` Mike Rapoport
2021-08-24 16:38 ` Edgecombe, Rick P
2021-08-24 16:54 ` Mike Rapoport
2021-08-24 17:23 ` Edgecombe, Rick P
2021-08-24 17:37 ` Mike Rapoport
2021-08-24 16:12 ` Vlastimil Babka
2021-08-25 8:43 ` David Hildenbrand [this message]
2021-08-23 13:25 ` [RFC PATCH 4/4] x86/mm: write protect (most) page tables Mike Rapoport
2021-08-23 20:08 ` Edgecombe, Rick P
2021-08-23 23:50 ` Dave Hansen
2021-08-24 3:34 ` Andy Lutomirski
2021-08-25 14:59 ` Dave Hansen
2021-08-24 13:32 ` Mike Rapoport
2021-08-25 8:38 ` David Hildenbrand
2021-08-26 8:02 ` Mike Rapoport
2021-08-26 9:01 ` Vlastimil Babka
[not found] ` <FB6C09CD-9CEA-4FE8-B179-98DB63EBDD68@gmail.com>
2021-08-24 5:34 ` Nadav Amit
2021-08-24 13:36 ` Mike Rapoport
2021-08-23 20:02 ` [RFC PATCH 0/4] mm/page_alloc: cache pte-mapped allocations Edgecombe, Rick P
2021-08-24 13:03 ` Mike Rapoport
2021-08-24 16:09 ` Vlastimil Babka
2021-08-29 7:06 ` Mike Rapoport
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=0a6341d6-c5be-ade3-9fb9-66cc8ebe1619@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@linux.intel.com \
--cc=ira.weiny@intel.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=rppt@kernel.org \
--cc=rppt@linux.ibm.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).