linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Make MIGRATE_ISOLATE a standalone bit
@ 2025-02-14 15:42 Zi Yan
  2025-02-14 15:42 ` [PATCH v2 1/4] mm/page_isolation: make page isolation " Zi Yan
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Zi Yan @ 2025-02-14 15:42 UTC (permalink / raw)
  To: linux-mm, David Hildenbrand
  Cc: Oscar Salvador, Vlastimil Babka, Johannes Weiner, Baolin Wang,
	Kirill A. Shutemov, Mel Gorman, linux-kernel, Zi Yan

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-02-13-23-42.

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
200GB VM 10 times and see that set_pfnblock_flags_mask() takes about
0.13% of the whole process with and without this patchset across 3 runs.

2. I used perf to collect stats of dd from /dev/zero to a 200GB tmpfs file
and find get_pfnblock_flags_mask() takes about 0.30% of the process with and
without this patchset across 3 runs.


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.

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          | 18 +++++--
 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                 | 96 ++++++++++++++++++++++++---------
 mm/page_isolation.c             | 66 +++++++++--------------
 10 files changed, 175 insertions(+), 92 deletions(-)

-- 
2.47.2



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-02-14 18:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-14 15:42 [PATCH v2 0/4] Make MIGRATE_ISOLATE a standalone bit Zi Yan
2025-02-14 15:42 ` [PATCH v2 1/4] mm/page_isolation: make page isolation " Zi Yan
2025-02-14 16:45   ` Johannes Weiner
2025-02-14 17:58     ` Zi Yan
2025-02-14 15:42 ` [PATCH v2 2/4] mm/page_isolation: remove migratetype from move_freepages_block_isolate() Zi Yan
2025-02-14 17:20   ` Johannes Weiner
2025-02-14 18:04     ` Zi Yan
2025-02-14 15:42 ` [PATCH v2 3/4] mm/page_isolation: remove migratetype from undo_isolate_page_range() Zi Yan
2025-02-14 15:42 ` [PATCH v2 4/4] mm/page_isolation: remove migratetype parameter from more functions Zi Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox