From: David Hildenbrand <david@redhat.com>
To: Rong Qianfeng <rongqianfeng@vivo.com>,
vbabka@suse.cz, mgorman@techsingularity.net,
Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <rppt@kernel.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com
Subject: Re: [PATCH] mm: Skip the reserved bootmem for compaction
Date: Mon, 2 Sep 2024 15:45:03 +0200 [thread overview]
Message-ID: <3b8994a6-cbe5-46be-86eb-b78198c31ef8@redhat.com> (raw)
In-Reply-To: <20240902122445.11805-1-rongqianfeng@vivo.com>
On 02.09.24 14:24, Rong Qianfeng wrote:
> Reserved pages are basically non-lru pages. This kind of memory can't be
> used as migration sources and targets, skip it can bring some performance
> benefits.
Any numbers? :)
>
> Because some drivers may also use PG_reserved, we just set PB_migrate_skip
> for those clustered reserved bootmem during memory initialization.
>
> Signed-off-by: Rong Qianfeng <rongqianfeng@vivo.com>
> ---
> include/linux/pageblock-flags.h | 13 +++++++++++
> mm/compaction.c | 40 +++++++++++++++++++++++++++++++++
> mm/mm_init.c | 14 ++++++++++++
> mm/page_alloc.c | 7 ++++++
> 4 files changed, 74 insertions(+)
>
> diff --git a/include/linux/pageblock-flags.h b/include/linux/pageblock-flags.h
> index fc6b9c87cb0a..63c5b0c69c1a 100644
> --- a/include/linux/pageblock-flags.h
> +++ b/include/linux/pageblock-flags.h
> @@ -86,6 +86,11 @@ void set_pfnblock_flags_mask(struct page *page,
> set_pfnblock_flags_mask(page, (1 << PB_migrate_skip), \
> page_to_pfn(page), \
> (1 << PB_migrate_skip))
> +
> +extern void set_pageblock_skip_range(unsigned long start_pfn,
> + unsigned long end_pfn);
two tabs indentation on the second line please. Applies to all others as
well.
> +extern void clear_pageblock_skip_range(unsigned long start_pfn,
> + unsigned long end_pfn);
> #else
> static inline bool get_pageblock_skip(struct page *page)
> {
> @@ -97,6 +102,14 @@ static inline void clear_pageblock_skip(struct page *page)
> static inline void set_pageblock_skip(struct page *page)
> {
> }
> +static inline void set_pageblock_skip_range(unsigned long start_pfn,
> + unsigned long end_pfn)
> +{
> +}
> +static inline void clear_pageblock_skip_range(unsigned long start_pfn,
> + unsigned long end_pfn)
> +{
> +}
[...]
> /*
> * Compound pages of >= pageblock_order should consistently be skipped until
> * released. It is always pointless to compact pages of such order (if they are
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 4ba5607aaf19..8b7dc8e00bf1 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -768,6 +768,13 @@ void __meminit reserve_bootmem_region(phys_addr_t start,
> __SetPageReserved(page);
> }
> }
> +
> + /*
> + * Set PB_migrate_skip for reserved region. for cma memory
> + * and the memory released by free_reserved_area(), we will
> + * clear PB_migrate_skip when they are initialized.
> + */
> + set_pageblock_skip_range(start_pfn, end_pfn);
> }
>
> /* If zone is ZONE_MOVABLE but memory is mirrored, it is an overlapped init */
> @@ -2236,6 +2243,13 @@ void __init init_cma_reserved_pageblock(struct page *page)
> set_page_count(p, 0);
> } while (++p, --i);
>
> + /*
> + * We set the PB_migrate_skip in
> + * reserve_bootmem_region() for cma
> + * memory, clear it now.
You can fit this easily into less lines
> + */
> + clear_pageblock_skip(page);
> +
> set_pageblock_migratetype(page, MIGRATE_CMA);
> set_page_refcounted(page);
> /* pages were reserved and not allocated */
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index b98f9bb28234..a7729dac0198 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5887,6 +5887,13 @@ unsigned long free_reserved_area(void *start, void *end, int poison, const char
> if (pages && s)
> pr_info("Freeing %s memory: %ldK\n", s, K(pages));
>
> + /*
> + * Clear PB_migrate_skip if the memory have released
> + * to the buddy system.
> + */
... after freeing the memory to the buddy."
And maybe
if (pages) {
if (s)
pr_info("Freeing %s memory: %ldK\n", s, K(pages));
clear_pageblock_skip_range(...)
}
> + clear_pageblock_skip_range(page_to_pfn(virt_to_page(start)),
> + page_to_pfn(virt_to_page(end)));
> +
PHYS_PFN(virt_to_phys(start)) might look a bit nicer, not need to
get pages involved. virt_to_pfn might be even better(), but it's
not available on all archs I think.
What about free_reserved_page() ? There might be more, though
(kimage_free_pages()). You have to take a look at all functions where we
clear PageReserved.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-09-02 13:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 12:24 [PATCH] mm: Skip the reserved bootmem for compaction Rong Qianfeng
2024-09-02 13:45 ` David Hildenbrand [this message]
2024-09-03 7:14 ` Rong Qianfeng
2024-09-03 9:56 ` David Hildenbrand
2024-09-04 11:13 ` Mel Gorman
2024-09-04 11:59 ` Rong Qianfeng
2024-09-04 15:38 ` Mike Rapoport
2024-09-05 3:10 ` Rong Qianfeng
2024-09-04 14:54 ` kernel test robot
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=3b8994a6-cbe5-46be-86eb-b78198c31ef8@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=opensource.kernel@vivo.com \
--cc=rongqianfeng@vivo.com \
--cc=rppt@kernel.org \
--cc=vbabka@suse.cz \
--cc=ziy@nvidia.com \
/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).