From: Zi Yan <ziy@nvidia.com>
To: David Hildenbrand <david@redhat.com>,
Johannes Weiner <hannes@cmpxchg.org>,
linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Oscar Salvador <osalvador@suse.de>,
Vlastimil Babka <vbabka@suse.cz>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
Mel Gorman <mgorman@techsingularity.net>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <jackmanb@google.com>,
Richard Chang <richardycc@google.com>,
linux-kernel@vger.kernel.org, Zi Yan <ziy@nvidia.com>
Subject: [PATCH v3 0/4] Make MIGRATE_ISOLATE a standalone bit
Date: Wed, 7 May 2025 17:10:55 -0400 [thread overview]
Message-ID: <20250507211059.2211628-1-ziy@nvidia.com> (raw)
Hi Johannes,
I incorporated all your feedback on v2 (see Changelog below), except the
"decoupling enum migratetype from the pageblock bits" one[1], since all
5 migratetypes (not MIGRATE_ISOLATE) are just values and
"#define PB_migratetype_bits MIGRATE_TYPE_BITS" would take 5 bits
for migratetypes, which only requires 3 bits. Let me know if I
misunderstand your suggestion. Thanks.
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.
It is on top of mm-everything-2025-05-07-03-02.
In terms of performance for changing pageblock types, no performance
change is observed:
1. I used perf to collect stats of offlining and onlining all memory of a
40GB VM 10 times and see that get_pfnblock_flags_mask() and
set_pfnblock_flags_mask() take about 0.12% and 0.02% of the whole process
respectively with and without this patchset across 3 runs.
2. I used perf to collect stats of dd from /dev/random to a 40GB tmpfs file
and find get_pfnblock_flags_mask() takes about 0.05% of the process with and
without this patchset across 3 runs.
Changelog
===
From v2[2]:
1. Moved MIGRATETYPE_NO_ISO_MASK to Patch 2, where it is used.
2. Removed spurious changes in Patch 1.
3. Refactored code so that migratetype mask is passed properly for all
callers to {get,set}_pfnblock_flags_mask().
4. Added toggle_pageblock_isolate() for setting and clearing
MIGRATE_ISOLATE.
5. Changed get_pageblock_migratetype() when CONFIG_MEMORY_ISOLATION to
handle MIGRATE_ISOLATE case. It acts like a parsing layer for
get_pfnblock_flags_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 %.
Any comment and/or suggestion is welcome. Thanks.
[1] https://lore.kernel.org/linux-mm/20250214172032.GA241035@cmpxchg.org/
[2] https://lore.kernel.org/linux-mm/20250214154215.717537-1-ziy@nvidia.com/
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.
drivers/virtio/virtio_mem.c | 3 +-
include/linux/gfp.h | 6 +-
include/linux/mmzone.h | 19 ++++--
include/linux/page-isolation.h | 24 ++++---
include/linux/pageblock-flags.h | 33 ++++++++-
include/trace/events/kmem.h | 14 ++--
mm/cma.c | 2 +-
mm/memory_hotplug.c | 5 +-
mm/page_alloc.c | 114 +++++++++++++++++++++++++-------
mm/page_isolation.c | 66 ++++++++----------
10 files changed, 197 insertions(+), 89 deletions(-)
--
2.47.2
next reply other threads:[~2025-05-07 21:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-07 21:10 Zi Yan [this message]
2025-05-07 21:10 ` [PATCH v3 1/4] mm/page_isolation: make page isolation " Zi Yan
2025-05-08 5:24 ` Johannes Weiner
2025-05-08 15:27 ` Zi Yan
2025-05-08 19:17 ` Zi Yan
2025-05-08 20:46 ` Johannes Weiner
2025-05-08 20:53 ` Zi Yan
2025-05-09 1:33 ` Zi Yan
2025-05-09 12:48 ` Zi Yan
2025-05-08 20:22 ` Zi Yan
2025-05-08 21:13 ` Johannes Weiner
2025-05-09 13:57 ` Zi Yan
2025-05-07 21:10 ` [PATCH v3 2/4] mm/page_isolation: remove migratetype from move_freepages_block_isolate() Zi Yan
2025-05-08 20:23 ` Zi Yan
2025-05-07 21:10 ` [PATCH v3 3/4] mm/page_isolation: remove migratetype from undo_isolate_page_range() Zi Yan
2025-05-08 21:12 ` Johannes Weiner
2025-05-07 21:10 ` [PATCH v3 4/4] mm/page_isolation: remove migratetype parameter from more functions Zi Yan
2025-05-08 20:25 ` Zi Yan
2025-05-09 1:56 ` Zi Yan
2025-05-09 16:01 ` Zi Yan
2025-05-08 21:11 ` Johannes Weiner
2025-05-08 22:15 ` Zi Yan
2025-05-08 4:38 ` [PATCH v3 0/4] Make MIGRATE_ISOLATE a standalone bit Johannes Weiner
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=20250507211059.2211628-1-ziy@nvidia.com \
--to=ziy@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=osalvador@suse.de \
--cc=richardycc@google.com \
--cc=surenb@google.com \
--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