linux/Documentation
Zi Yan 42f46ed99a mm/page_alloc: pageblock flags functions clean up
Patch series "Make MIGRATE_ISOLATE a standalone bit", v10.

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.

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.


This patch (of 6):

No functional change is intended.

1. Add __NR_PAGEBLOCK_BITS for the number of pageblock flag bits and use
   roundup_pow_of_two(__NR_PAGEBLOCK_BITS) as NR_PAGEBLOCK_BITS to take
   right amount of bits for pageblock flags.
2. Rename PB_migrate_skip to PB_compact_skip.
3. Add {get,set,clear}_pfnblock_bit() to operate one a standalone bit,
   like PB_compact_skip.
3. Make {get,set}_pfnblock_flags_mask() internal functions and use
   {get,set}_pfnblock_migratetype() for pageblock migratetype operations.
4. Move pageblock flags common code to get_pfnblock_bitmap_bitidx().
3. Use MIGRATETYPE_MASK to get the migratetype of a pageblock from its
   flags.
4. Use PB_migrate_end in the definition of MIGRATETYPE_MASK instead of
   PB_migrate_bits.
5. Add a comment on is_migrate_cma_folio() to prevent one from changing it
   to use get_pageblock_migratetype() and causing issues.

Link: https://lkml.kernel.org/r/20250617021115.2331563-1-ziy@nvidia.com
Link: https://lkml.kernel.org/r/20250617021115.2331563-2-ziy@nvidia.com
Signed-off-by: Zi Yan <ziy@nvidia.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Kirill A. Shuemov <kirill.shutemov@linux.intel.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Richard Chang <richardycc@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-07-13 16:38:17 -07:00
..
ABI Power management fixes for 6.16-rc5 2025-07-04 17:27:30 -07:00
accel
accounting
admin-guide Merge branch 'mm-hotfixes-stable' into mm-stable to pick up changes which 2025-07-12 14:48:26 -07:00
arch docs: arm64: Fix ICC_SRE_EL2 register typo in booting.rst 2025-06-12 15:50:00 +01:00
block Documentation: ublk: Separate UBLK_F_AUTO_BUF_REG fallback behavior sublists 2025-06-13 09:25:42 -06:00
bpf bpf: Adjust free target to avoid global starvation of LRU map 2025-06-18 18:50:14 -07:00
cdrom
core-api mm,memory_hotplug: drop status_change_nid parameter from memory_notify 2025-07-13 16:38:17 -07:00
cpu-freq
crypto
dev-tools Documentation: kunit: improve example on testing static functions 2025-05-19 13:22:21 -06:00
devicetree i2c-for-6.16-rc5 2025-07-05 12:54:24 -07:00
doc-guide Docs: doc-guide: update sphinx.rst Sphinx version number 2025-05-21 04:28:29 -06:00
driver-api Char/Misc/IIO pull request for 6.16-rc1 2025-06-06 11:50:47 -07:00
edac cxl/edac: Add CXL memory device soft PPR control feature 2025-05-23 13:25:06 -07:00
fault-injection
fb fbdev: sstfb.rst: Fix spelling mistake 2025-05-31 10:24:02 +02:00
features LoongArch: Enable ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS 2025-05-30 21:45:42 +08:00
filesystems Several mount-related fixes 2025-06-25 20:48:48 -07:00
firmware_class
firmware-guide
fpga
gpu Documentation: nouveau: Update GSP message queue kernel-doc reference 2025-06-13 16:46:35 +02:00
hid
hwmon hwmon updates for v6.16 2025-06-03 09:11:26 -07:00
i2c docs: i2c: Fix "resitors" to "resistors" 2025-05-20 11:22:16 +02:00
iio docs: iio: ad3552r: fix malformed table 2025-05-21 14:19:46 +01:00
images
infiniband
input Input: amijoy - make headings compliant w/ guidelines in documentation 2025-05-30 15:34:38 -07:00
isdn
kbuild Kbuild updates for v6.16 2025-06-07 10:05:35 -07:00
kernel-hacking
leds LEDs for v6.16 2025-06-03 12:10:31 -07:00
litmus-tests
livepatch
locking
maintainer
mhi
misc-devices misc: amd-sbi: Add document for AMD SB IOCTL description 2025-05-21 14:44:41 +02:00
mm mm/page_alloc: pageblock flags functions clean up 2025-07-13 16:38:17 -07:00
netlabel
netlink netlink: specs: enforce strict naming of properties 2025-06-25 15:36:28 -07:00
networking doc: tls: socket needs to be established to enable ulp 2025-06-27 15:33:01 -07:00
nvdimm
nvme
PCI Merge branch 'pci/misc' 2025-06-04 10:50:45 -05:00
pcmcia
peci
power
process docs: netdev: correct the heading level for co-posting selftests 2025-06-27 15:31:24 -07:00
RCU
rust Documentation: rust: testing: add docs on the new KUnit #[test] tests 2025-05-27 20:09:59 +02:00
scheduler sched_ext: Changes for v6.16 2025-05-27 21:12:50 -07:00
scsi
security
sound ASoC: doc: cs35l56: Add CS35L63 to the list of supported devices 2025-06-18 17:22:48 +01:00
sphinx docs: kerneldoc.py: simplify exception handling logic 2025-05-21 03:53:40 -06:00
sphinx-static
spi
staging rpmsg updates for v6.16 2025-06-02 11:06:44 -07:00
sunrpc/xdr
target
tee
timers
tools
trace Char/Misc/IIO pull request for 6.16-rc1 2025-06-06 11:50:47 -07:00
translations mm,memory_hotplug: remove status_change_nid_normal and update documentation 2025-07-13 16:38:14 -07:00
usb
userspace-api LoongArch changes for v6.16 2025-06-07 09:56:18 -07:00
virt KVM: TDX: Exit to userspace for GetTdVmCallInfo 2025-06-20 13:55:47 -04:00
w1
watchdog
wmi platform/x86: wmi: Update documentation of WCxx/WExx ACPI methods 2025-06-26 18:19:27 +03:00
.gitignore
atomic_bitops.txt
atomic_t.txt
Changes
CodingStyle
conf.py
docutils.conf
index.rst
Kconfig
Makefile
memory-barriers.txt
SubmittingPatches
subsystem-apis.rst