Skip to content

Commit 6e2e07c

Browse files
davidhildenbrandtorvalds
authored andcommitted
mm: better document PG_reserved
The usage of PG_reserved and how PG_reserved pages are to be treated is buried deep down in different parts of the kernel. Let's shine some light onto these details by documenting current users and expected behavior. Especially, clarify on the "Some of them might not even exist" case. These are physical memory gaps that will never be dumped as they are not marked as IORESOURCE_SYSRAM. PG_reserved does in general not hinder anybody from dumping or swapping. In some cases, these pages will not be stored in the hibernation image. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: David Hildenbrand <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Pavel Tatashin <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Alexander Duyck <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Anthony Yznaga <[email protected]> Cc: Miles Chen <[email protected]> Cc: <[email protected]> Cc: Dan Williams <[email protected]> Cc: Randy Dunlap <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 731351d commit 6e2e07c

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

include/linux/page-flags.h

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,37 @@
1717
/*
1818
* Various page->flags bits:
1919
*
20-
* PG_reserved is set for special pages, which can never be swapped out. Some
21-
* of them might not even exist...
20+
* PG_reserved is set for special pages. The "struct page" of such a page
21+
* should in general not be touched (e.g. set dirty) except by its owner.
22+
* Pages marked as PG_reserved include:
23+
* - Pages part of the kernel image (including vDSO) and similar (e.g. BIOS,
24+
* initrd, HW tables)
25+
* - Pages reserved or allocated early during boot (before the page allocator
26+
* was initialized). This includes (depending on the architecture) the
27+
* initial vmemmap, initial page tables, crashkernel, elfcorehdr, and much
28+
* much more. Once (if ever) freed, PG_reserved is cleared and they will
29+
* be given to the page allocator.
30+
* - Pages falling into physical memory gaps - not IORESOURCE_SYSRAM. Trying
31+
* to read/write these pages might end badly. Don't touch!
32+
* - The zero page(s)
33+
* - Pages not added to the page allocator when onlining a section because
34+
* they were excluded via the online_page_callback() or because they are
35+
* PG_hwpoison.
36+
* - Pages allocated in the context of kexec/kdump (loaded kernel image,
37+
* control pages, vmcoreinfo)
38+
* - MMIO/DMA pages. Some architectures don't allow to ioremap pages that are
39+
* not marked PG_reserved (as they might be in use by somebody else who does
40+
* not respect the caching strategy).
41+
* - Pages part of an offline section (struct pages of offline sections should
42+
* not be trusted as they will be initialized when first onlined).
43+
* - MCA pages on ia64
44+
* - Pages holding CPU notes for POWER Firmware Assisted Dump
45+
* - Device memory (e.g. PMEM, DAX, HMM)
46+
* Some PG_reserved pages will be excluded from the hibernation image.
47+
* PG_reserved does in general not hinder anybody from dumping or swapping
48+
* and is no longer required for remap_pfn_range(). ioremap might require it.
49+
* Consequently, PG_reserved for a page mapped into user space can indicate
50+
* the zero page, the vDSO, MMIO pages or device memory.
2251
*
2352
* The PG_private bitflag is set on pagecache pages if they contain filesystem
2453
* specific data (which is normally at page->private). It can be used by

0 commit comments

Comments
 (0)