From: Zi Yan <ziy@nvidia.com>
To: linux-mm@kvack.org, David Hildenbrand <david@redhat.com>
Cc: Oscar Salvador <osalvador@suse.de>,
Vlastimil Babka <vbabka@suse.cz>,
Johannes Weiner <hannes@cmpxchg.org>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Mel Gorman <mgorman@suse.de>,
linux-kernel@vger.kernel.org, Zi Yan <ziy@nvidia.com>
Subject: [RFC PATCH 0/4] Make MIGRATE_ISOLATE a standalone bit
Date: Wed, 28 Aug 2024 16:22:36 -0400 [thread overview]
Message-ID: <20240828202240.2809740-1-ziy@nvidia.com> (raw)
Hi all,
This patchset moves MIGRATE_ISOLATE to a standalone bit to avoid
being overwritten during pageblock isolation process. Currently,
MIGRATE_ISOLATE is part of enum migratetype (in include/linux/mmzone.h),
thus, setting a pageblock to MIGRATE_ISOLATE overwrites its original
migratetype. This causes pageblock migratetype loss during
alloc_contig_range() and memory offline, especially when the process
fails due to a failed pageblock isolation and the code tries to undo the
finished pageblock isolations.
I am also trying to collect feedback on how to handle MIGRATE_ISOLATE in
existing code. As MIGRATE_ISOLATE becomes a standalone bit like
PB_migrate_skip (pageblock skipped by compaction), in theory, existing code
could be changed to use {get,clear,set}_pageblock_isolate() like
{get,clear,set}_pageblock_skip() and MIGRATE_ISOLATE could be removed
from enum migratetype. But free list has a separate MIGRATE_ISOLATE list
and the memory info code used by OOM also shows free memory with
different migratetypes. I wonder if we want more extensive changes to
existing code to remove MIGRATE_ISOLATE. If not, what can I do to improve
the MIGRATE_ISOLATE specialized code in Patch 1? For example:
void set_pageblock_migratetype(struct page *page, int migratetype)
{
if (unlikely(page_group_by_mobility_disabled &&
migratetype < MIGRATE_PCPTYPES))
migratetype = MIGRATE_UNMOVABLE;
#ifdef CONFIG_MEMORY_ISOLATION
if (migratetype == MIGRATE_ISOLATE)
set_pageblock_isolate(page);
else
#endif
{
if (get_pageblock_isolate(page))
clear_pageblock_isolate(page);
set_pfnblock_flags_mask(page, (unsigned long)migratetype,
page_to_pfn(page), MIGRATETYPE_MASK);
}
}
Design
===
Pageblock flags are read in words to achieve good performance and existing
pageblock flags take 4 bits per pageblock. To avoid a substantial change
to the pageblock flag code, pageblock flag bits are expanded to use 8
and MIGRATE_ISOLATE is moved to use the last bit (bit 7).
It might look like the pageblock flags have doubled the overhead, but in
reality, the overhead is only 1 byte per 2MB/4MB (based on pageblock config),
or 0.0000476 %.
In terms of performance for changing pageblock types, I did a very
simple test by offlining and onlining all memory of a 16GB VM 10 times
and did not see a noticeable runtime difference with the patchset.
TODOs
===
1. improve pageblock migratetype handling code to be less hacky (see the
example above).
2. more performance tests on pageblock migratetype change.
Any comment and/or suggestion is welcome. Thanks.
Zi Yan (4):
mm/page_isolation: make page isolation a standalone bit.
mm/page_isolation: remove migratetype from
move_freepages_block_isolate()
mm/page_isolation: remove migratetype from undo_isolate_page_range()
mm/page_isolation: remove migratetype parameter from more functions.
include/linux/mmzone.h | 24 +++++++++++---
include/linux/page-isolation.h | 11 +++----
include/linux/pageblock-flags.h | 29 ++++++++++++++++-
mm/memory_hotplug.c | 5 ++-
mm/page_alloc.c | 55 +++++++++++++++++++++++++++------
mm/page_isolation.c | 55 ++++++++++++++-------------------
6 files changed, 123 insertions(+), 56 deletions(-)
--
2.45.2
next reply other threads:[~2024-08-28 20:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-28 20:22 Zi Yan [this message]
2024-08-28 20:22 ` [RFC PATCH 1/4] mm/page_isolation: make page isolation " Zi Yan
2024-08-28 20:22 ` [RFC PATCH 2/4] mm/page_isolation: remove migratetype from move_freepages_block_isolate() Zi Yan
2024-09-02 14:42 ` David Hildenbrand
2024-09-02 15:30 ` Zi Yan
2024-08-28 20:22 ` [RFC PATCH 3/4] mm/page_isolation: remove migratetype from undo_isolate_page_range() Zi Yan
2024-09-02 9:00 ` David Hildenbrand
2024-09-02 15:34 ` Zi Yan
2024-08-28 20:22 ` [RFC PATCH 4/4] mm/page_isolation: remove migratetype parameter from more functions Zi Yan
2024-09-02 9:06 ` David Hildenbrand
2024-09-02 15:34 ` Zi Yan
2024-09-02 16:42 ` David Hildenbrand
2024-09-04 2:02 ` Zi Yan
2024-09-04 8:50 ` David Hildenbrand
2024-09-04 13:53 ` Zi Yan
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=20240828202240.2809740-1-ziy@nvidia.com \
--to=ziy@nvidia.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=osalvador@suse.de \
--cc=vbabka@suse.cz \
/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