Skip to contentSkip to conversation

mm: PG_reserved cleanups and documentation

RFC PATCH In review David Hildenbrand 5 participants 18 messages Dec 5, 2018 – Dec 7, 2018

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

cover mm: PG_reserved cleanups and documentation

I was recently going over all users of PG_reserved. Short story: it is difficult and sometimes not really clear if setting/checking for PG_reserved is only a relict from the past. Easy to break things.

I had way more cleanups in this series inititally,
but some architectures take PG_reserved as a way to apply a different caching strategy (for MMIO pages). So I decided to only include the most obvious changes (that are less likely to break something).

So let's see if the documentation update for PG_reserved I crafted actually covers most cases or if there is plenty more.

Most notably, for device memory we can hopefully soon stop setting it PG_reserved

I only briefly tested this on s390x.

David Hildenbrand (7):
agp: efficeon: no need to set PG_reserved on GATT tables s390/vdso: don't clear PG_reserved powerpc/vdso: don't clear PG_reserved riscv/vdso: don't clear PG_reserved
m68k/mm: use __ClearPageReserved()
arm64: kexec: no need to ClearPageReserved()
mm: better document PG_reserved

 arch/arm64/kernel/machine_kexec.c |  1 -
 arch/m68k/mm/memory.c             |  2 +-
 arch/powerpc/kernel/vdso.c        |  2 --
 arch/riscv/kernel/vdso.c          |  1 -
 arch/s390/kernel/vdso.c           |  2 --
 drivers/char/agp/efficeon-agp.c   |  2 --
 include/linux/page-flags.h        | 18 ++++++++++++++++--
 7 files changed, 17 insertions(+), 11 deletions(-)
Signature · 1 line
2.17.2
#1 lore raw

RFC PATCH 1/7 agp: efficeon: no need to set PG_reserved on GATT tables

The l1 GATT page table is kept in a special on-chip page with 64 entries. We allocate the l2 page table pages via get_zeroed_page() and enter them into the table. These l2 pages are modified accordingly when inserting/removing memory via efficeon_insert_memory and efficeon_remove_memory.

Apart from that, these pages are not exposed or ioremap'ed. We can stop setting them reserved (propably copied from generic code).

Cc David Airlie <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Matthew Wilcox <[email protected]>
---
 drivers/char/agp/efficeon-agp.c | 2 --
 1 file changed, 2 deletions(-)
drivers/char/agp/efficeon-agp.c +0 -2
index 7f88490b5479..c53f0f9ef5b0 100644
@@ -163,7 +163,6 @@ static int efficeon_free_gatt_table(struct agp_bridge_data *bridge)
 		unsigned long page = efficeon_private.l1_table[index];
 		if (page) {
 			efficeon_private.l1_table[index] = 0;
-			ClearPageReserved(virt_to_page((char *)page));
 			free_page(page);
 			freed++;
 		}
@@ -219,7 +218,6 @@ static int efficeon_create_gatt_table(struct agp_bridge_data *bridge)
 			efficeon_free_gatt_table(agp_bridge);
 			return -ENOMEM;
 		}
-		SetPageReserved(virt_to_page((char *)page));
 
 		for (offset = 0; offset < PAGE_SIZE; offset += clflush_chunk)
 			clflush((char *)page+offset);
Signature · 1 line
2.17.2
#2 lore raw

RFC PATCH 2/7 s390/vdso: don't clear PG_reserved

In reply to David Hildenbrand

The VDSO is part of the kernel image and therefore the struct pages are marked as reserved during boot.

As we install a special mapping, the actual struct pages will never be exposed to MM via the page tables. We can therefore leave the pages marked as reserved.

Cc Martin Schwidefsky <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Mike Rapoport <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Kees Cook <[email protected]>
Cc Souptick Joarder <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
---
 arch/s390/kernel/vdso.c | 2 --
 1 file changed, 2 deletions(-)
arch/s390/kernel/vdso.c +0 -2
index ebe748a9f472..9e24d23c26c0 100644
@@ -292,7 +292,6 @@ static int __init vdso_init(void)
 	BUG_ON(vdso32_pagelist == NULL);
 	for (i = 0; i < vdso32_pages - 1; i++) {
 		struct page *pg = virt_to_page(vdso32_kbase + i*PAGE_SIZE);
-		ClearPageReserved(pg);
 		get_page(pg);
 		vdso32_pagelist[i] = pg;
 	}
@@ -310,7 +309,6 @@ static int __init vdso_init(void)
 	BUG_ON(vdso64_pagelist == NULL);
 	for (i = 0; i < vdso64_pages - 1; i++) {
 		struct page *pg = virt_to_page(vdso64_kbase + i*PAGE_SIZE);
-		ClearPageReserved(pg);
 		get_page(pg);
 		vdso64_pagelist[i] = pg;
 	}
Signature · 1 line
2.17.2
#3 lore raw

RFC PATCH 3/7 powerpc/vdso: don't clear PG_reserved

In reply to David Hildenbrand

The VDSO is part of the kernel image and therefore the struct pages are marked as reserved during boot.

As we install a special mapping, the actual struct pages will never be exposed to MM via the page tables. We can therefore leave the pages marked as reserved.

Cc Benjamin Herrenschmidt <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Kees Cook <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Matthew Wilcox <[email protected]>
---
 arch/powerpc/kernel/vdso.c | 2 --
 1 file changed, 2 deletions(-)
arch/powerpc/kernel/vdso.c +0 -2
index 65b3bdb99f0b..d59dc2e9a695 100644
@@ -795,7 +795,6 @@ static int __init vdso_init(void)
 	BUG_ON(vdso32_pagelist == NULL);
 	for (i = 0; i < vdso32_pages; i++) {
 		struct page *pg = virt_to_page(vdso32_kbase + i*PAGE_SIZE);
-		ClearPageReserved(pg);
 		get_page(pg);
 		vdso32_pagelist[i] = pg;
 	}
@@ -809,7 +808,6 @@ static int __init vdso_init(void)
 	BUG_ON(vdso64_pagelist == NULL);
 	for (i = 0; i < vdso64_pages; i++) {
 		struct page *pg = virt_to_page(vdso64_kbase + i*PAGE_SIZE);
-		ClearPageReserved(pg);
 		get_page(pg);
 		vdso64_pagelist[i] = pg;
 	}
Signature · 1 line
2.17.2
#4 lore raw

RFC PATCH 4/7 riscv/vdso: don't clear PG_reserved

In reply to David Hildenbrand

The VDSO is part of the kernel image and therefore the struct pages are marked as reserved during boot.

As we install a special mapping, the actual struct pages will never be exposed to MM via the page tables. We can therefore leave the pages marked as reserved.

Cc Palmer Dabbelt <[email protected]>
Cc Albert Ou <[email protected]>
Cc Tobias Klauser <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Matthew Wilcox <[email protected]>
---
 arch/riscv/kernel/vdso.c | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/kernel/vdso.c +0 -1
index 582cb153eb24..0cd044122234 100644
@@ -54,7 +54,6 @@ static int __init vdso_init(void)
 		struct page *pg;
 
 		pg = virt_to_page(vdso_start + (i << PAGE_SHIFT));
-		ClearPageReserved(pg);
 		vdso_pagelist[i] = pg;
 	}
 	vdso_pagelist[i] = virt_to_page(vdso_data);
Signature · 1 line
2.17.2
Acked-by on v1 4/7
#5 lore raw

Re: [PATCH RFC 4/7] riscv/vdso: don't clear PG_reserved

Quoted 23 lines · On Wed, 05 Dec 2018 04:28:48 PST (-0800), [email protected] wrote:

The VDSO is part of the kernel image and therefore the struct pages are marked as reserved during boot.

As we install a special mapping, the actual struct pages will never be exposed to MM via the page tables. We can therefore leave the pages marked as reserved.

Cc Palmer Dabbelt <[email protected]>
Cc Albert Ou <[email protected]>
Cc Tobias Klauser <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Matthew Wilcox <[email protected]>
---
 arch/riscv/kernel/vdso.c | 1 -
 1 file changed, 1 deletion(-)
arch/riscv/kernel/vdso.c +0 -0
index 582cb153eb24..0cd044122234 100644

arch/riscv/kernel/vdso.c static int __init vdso_init(void) · line 59

Quoted 7 lines
arch/riscv/kernel/vdso.c +0 -1
@@ -54,7 +54,6 @@ static int __init vdso_init(void)
 		struct page *pg;
 
 		pg = virt_to_page(vdso_start + (i << PAGE_SHIFT));
-		ClearPageReserved(pg);
 		vdso_pagelist[i] = pg;
 	}
 	vdso_pagelist[i] = virt_to_page(vdso_data);

I'm going to assume this will go in through another tree along with the rest of the set assuming everyone else is happy with it.

Thanks!

#6 lore raw

RFC PATCH 5/7 m68k/mm: use __ClearPageReserved()

In reply to David Hildenbrand

The PG_reserved flag is cleared from memory that is part of the kernel image (and therefore marked as PG_reserved). Avoid using PG_reserved directly.

Cc Geert Uytterhoeven <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Matthew Wilcox <[email protected]>
---
 arch/m68k/mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/mm/memory.c +1 -1
index b86a2e21693b..227c04fe60d2 100644
@@ -51,7 +51,7 @@ void __init init_pointer_table(unsigned long ptable)
 	pr_debug("init_pointer_table: %lx, %x\n", ptable, PD_MARKBITS(dp));
 
 	/* unreserve the page so it's possible to free that page */
-	PD_PAGE(dp)->flags &= ~(1 << PG_reserved);
+	__ClearPageReserved(PD_PAGE(dp));
 	init_page_count(PD_PAGE(dp));
 
 	return;
Signature · 1 line
2.17.2
#7 lore raw

RFC PATCH 6/7 arm64: kexec: no need to ClearPageReserved()

In reply to David Hildenbrand

This will already be done by free_reserved_page().

Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>
Cc Bhupesh Sharma <[email protected]>
Cc James Morse <[email protected]>
Cc Marc Zyngier <[email protected]>
Cc Dave Kleikamp <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Matthew Wilcox <[email protected]>
---
 arch/arm64/kernel/machine_kexec.c | 1 -
 1 file changed, 1 deletion(-)
arch/arm64/kernel/machine_kexec.c +0 -1
index 922add8adb74..0ef4ea73aa54 100644
@@ -353,7 +353,6 @@ void crash_free_reserved_phys_range(unsigned long begin, unsigned long end)
 
 	for (addr = begin; addr < end; addr += PAGE_SIZE) {
 		page = phys_to_page(addr);
-		ClearPageReserved(page);
 		free_reserved_page(page);
 	}
 }
Signature · 1 line
2.17.2
Acked-by on v1 6/7
#8 lore raw

Re: [PATCH RFC 6/7] arm64: kexec: no need to ClearPageReserved()

Hi David,

(CC: +Akashi)

Quoted 1 line · David Hildenbrand

This will already be done by free_reserved_page().

(will already be -> will be ?)

So it does!

arch/arm64/kernel/machine_kexec.c void crash_free_reserved_phys_range(unsigned long begin, unsigned long end) · line 358

Quoted 13 lines
arch/arm64/kernel/machine_kexec.c +0 -1
index 922add8adb74..0ef4ea73aa54 100644
@@ -353,7 +353,6 @@ void crash_free_reserved_phys_range(unsigned long begin, unsigned long end)
 
 	for (addr = begin; addr < end; addr += PAGE_SIZE) {
 		page = phys_to_page(addr);
-		ClearPageReserved(page);
 		free_reserved_page(page);
 	}
 }

Thanks,

James

#9 lore raw

RFC PATCH 7/7 mm: better document PG_reserved

In reply to David Hildenbrand

The usage of PG_reserved and how PG_reserved pages are to be treated is burried deep down in different parts of the kernel. Let's shine some light onto these details by documenting (most?) current users and expected behavior.

I don't see a reason why we have to document "Some of them might not even exist". If there is a user, we should document it. E.g. for balloon drivers we now use PG_offline to indicate that a page might currently not be backed by memory in the hypervisor. And that is independent from PG_reserved.

Cc 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 Dan Williams <[email protected]>
---
 include/linux/page-flags.h | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
include/linux/page-flags.h +16 -2
index 68b8495e2fbc..112526f5ba61 100644
@@ -17,8 +17,22 @@
 /*
  * Various page->flags bits:
  *
- * PG_reserved is set for special pages, which can never be swapped out. Some
- * of them might not even exist...
+ * PG_reserved is set for special pages. The "struct page" of such a page
+ * should in general not be touched (e.g. set dirty) except by their owner.
+ * Pages marked as PG_reserved include:
+ * - Kernel image (including vDSO) and similar (e.g. BIOS, initrd)
+ * - Pages allocated early during boot (bootmem, memblock)
+ * - Zero pages
+ * - Pages that have been associated with a zone but are not available for
+ *   the page allocator (e.g. excluded via online_page_callback())
+ * - Pages to exclude from the hibernation image (e.g. loaded kexec images)
+ * - MMIO pages (communicate with a device, special caching strategy needed)
+ * - MCA pages on ia64 (pages with memory errors)
+ * - Device memory (e.g. PMEM, DAX, HMM)
+ * Some architectures don't allow to ioremap pages that are not marked
+ * PG_reserved (as they might be in use by somebody else who does not respect
+ * the caching strategy). Consequently, PG_reserved for a page mapped into
+ * user space can indicate the zero page, the vDSO, MMIO pages or device memory.
  *
  * The PG_private bitflag is set on pagecache pages if they contain filesystem
  * specific data (which is normally at page->private). It can be used by
Signature · 1 line
2.17.2
#10 lore raw

Re: [PATCH RFC 7/7] mm: better document PG_reserved

Quoted 11 lines · David Hildenbrand

The usage of PG_reserved and how PG_reserved pages are to be treated is burried deep down in different parts of the kernel. Let's shine some light onto these details by documenting (most?) current users and expected behavior.

I don't see a reason why we have to document "Some of them might not even exist". If there is a user, we should document it. E.g. for balloon drivers we now use PG_offline to indicate that a page might currently not be backed by memory in the hypervisor. And that is independent from PG_reserved.

Quoted 11 lines
Cc 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 Dan Williams <[email protected]>

This looks like an improvement. The essential part is that PG_reserved page belongs to its user and no generic code should touch it. The rest is a description of current users which I haven't checked due to to lack of time but yeah, I like the updated wording because I have seen multiple people confused from the swapped out part which is not true for many many years. I have tried to dig out when it was actually the case but failed.

So I cannot give my Ack because I didn't really do a real review but I like this FWIW.

Quoted 36 lines
---
 include/linux/page-flags.h | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
include/linux/page-flags.h +16 -2
index 68b8495e2fbc..112526f5ba61 100644
@@ -17,8 +17,22 @@
 /*
  * Various page->flags bits:
  *
- * PG_reserved is set for special pages, which can never be swapped out. Some
- * of them might not even exist...
+ * PG_reserved is set for special pages. The "struct page" of such a page
+ * should in general not be touched (e.g. set dirty) except by their owner.
+ * Pages marked as PG_reserved include:
+ * - Kernel image (including vDSO) and similar (e.g. BIOS, initrd)
+ * - Pages allocated early during boot (bootmem, memblock)
+ * - Zero pages
+ * - Pages that have been associated with a zone but are not available for
+ *   the page allocator (e.g. excluded via online_page_callback())
+ * - Pages to exclude from the hibernation image (e.g. loaded kexec images)
+ * - MMIO pages (communicate with a device, special caching strategy needed)
+ * - MCA pages on ia64 (pages with memory errors)
+ * - Device memory (e.g. PMEM, DAX, HMM)
+ * Some architectures don't allow to ioremap pages that are not marked
+ * PG_reserved (as they might be in use by somebody else who does not respect
+ * the caching strategy). Consequently, PG_reserved for a page mapped into
+ * user space can indicate the zero page, the vDSO, MMIO pages or device memory.
  *
  * The PG_private bitflag is set on pagecache pages if they contain filesystem
  * specific data (which is normally at page->private). It can be used by
Signature · 1 line
2.17.2
Signature · 2 lines
Michal Hocko
SUSE Labs
#11 lore raw

Re: [PATCH RFC 7/7] mm: better document PG_reserved

In reply to David Hildenbrand
Quoted 5 lines · David Hildenbrand

I don't see a reason why we have to document "Some of them might not even exist". If there is a user, we should document it. E.g. for balloon drivers we now use PG_offline to indicate that a page might currently not be backed by memory in the hypervisor. And that is independent from PG_reserved.

I think you're confused by the meaning of "some of them might not even exist". What this means is that there might not be memory there; maybe writes to that memory will be discarded, or maybe they'll cause a machine check. Maybe reads will return ~0, or 0, or cause a machine check. We just don't know what's there, and we shouldn't try touching the memory.

Quoted 13 lines

+++ b/include/linux/page-flags.h

include/linux/page-flags.h +6 -2
@@ -17,8 +17,22 @@
 /*
  * Various page->flags bits:
  *
- * PG_reserved is set for special pages, which can never be swapped out. Some
- * of them might not even exist...
+ * PG_reserved is set for special pages. The "struct page" of such a page
+ * should in general not be touched (e.g. set dirty) except by their owner.
+ * Pages marked as PG_reserved include:
+ * - Kernel image (including vDSO) and similar (e.g. BIOS, initrd)
+ * - Pages allocated early during boot (bootmem, memblock)
+ * - Zero pages

include/linux/page-flags.h line 35

Quoted 10 lines
include/linux/page-flags.h +10 -0
+ * - Pages that have been associated with a zone but are not available for
+ *   the page allocator (e.g. excluded via online_page_callback())
+ * - Pages to exclude from the hibernation image (e.g. loaded kexec images)
+ * - MMIO pages (communicate with a device, special caching strategy needed)
+ * - MCA pages on ia64 (pages with memory errors)
+ * - Device memory (e.g. PMEM, DAX, HMM)
+ * Some architectures don't allow to ioremap pages that are not marked
+ * PG_reserved (as they might be in use by somebody else who does not respect
+ * the caching strategy). Consequently, PG_reserved for a page mapped into
+ * user space can indicate the zero page, the vDSO, MMIO pages or device memory.

So maybe just add one more option to the list.

#12 lore raw

Re: [PATCH RFC 7/7] mm: better document PG_reserved

Quoted 7 lines · Matthew Wilcox
Quoted 5 lines · David Hildenbrand

I don't see a reason why we have to document "Some of them might not even exist". If there is a user, we should document it. E.g. for balloon drivers we now use PG_offline to indicate that a page might currently not be backed by memory in the hypervisor. And that is independent from PG_reserved.

Quoted 5 lines

I think you're confused by the meaning of "some of them might not even exist". What this means is that there might not be memory there; maybe writes to that memory will be discarded, or maybe they'll cause a machine check. Maybe reads will return ~0, or 0, or cause a machine check. We just don't know what's there, and we shouldn't try touching the memory.

If there are users, let's document it. And I need more details for that :)

1. machine check: if there is a HW error, we set PG_hwpoison (except ia64 MCA, see the list)

2. Writes to that memory will be discarded

Who is the user of that? When will we have such pages right now?

3. Reads will return ~0, / 0?

I think this is a special case of e.g. x86? But where do we have that, are there any user?

In summary: When can we have memory sections that are online but pages reserved and not accessible? (one example is ballooning I mention here)

(I classify this as dangerous as dump tools will happily dump PG_reserved pages (unless PG_hwpoison/PG_offline) and that's the right thing to do).

I want to avoid documenting things that are not actually getting used.

Quoted 27 lines
Quoted 14 lines

+++ b/include/linux/page-flags.h

include/linux/page-flags.h +6 -2
@@ -17,8 +17,22 @@
 /*
  * Various page->flags bits:
  *
- * PG_reserved is set for special pages, which can never be swapped out. Some
- * of them might not even exist...
+ * PG_reserved is set for special pages. The "struct page" of such a page
+ * should in general not be touched (e.g. set dirty) except by their owner.
+ * Pages marked as PG_reserved include:
+ * - Kernel image (including vDSO) and similar (e.g. BIOS, initrd)
+ * - Pages allocated early during boot (bootmem, memblock)
+ * - Zero pages

include/linux/page-flags.h line 35

Quoted 10 lines
include/linux/page-flags.h +10 -0
+ * - Pages that have been associated with a zone but are not available for
+ *   the page allocator (e.g. excluded via online_page_callback())
+ * - Pages to exclude from the hibernation image (e.g. loaded kexec images)
+ * - MMIO pages (communicate with a device, special caching strategy needed)
+ * - MCA pages on ia64 (pages with memory errors)
+ * - Device memory (e.g. PMEM, DAX, HMM)
+ * Some architectures don't allow to ioremap pages that are not marked
+ * PG_reserved (as they might be in use by somebody else who does not respect
+ * the caching strategy). Consequently, PG_reserved for a page mapped into
+ * user space can indicate the zero page, the vDSO, MMIO pages or device memory.

So maybe just add one more option to the list.

Signature · 3 lines
Thanks,

David / dhildenb
#13 lore raw

Re: [PATCH RFC 7/7] mm: better document PG_reserved

Quoted 19 lines · David Hildenbrand
Quoted 7 lines · Matthew Wilcox
Quoted 5 lines · David Hildenbrand

I don't see a reason why we have to document "Some of them might not even exist". If there is a user, we should document it. E.g. for balloon drivers we now use PG_offline to indicate that a page might currently not be backed by memory in the hypervisor. And that is independent from PG_reserved.

Quoted 5 lines

I think you're confused by the meaning of "some of them might not even exist". What this means is that there might not be memory there; maybe writes to that memory will be discarded, or maybe they'll cause a machine check. Maybe reads will return ~0, or 0, or cause a machine check. We just don't know what's there, and we shouldn't try touching the memory.

If there are users, let's document it. And I need more details for that :)

1. machine check: if there is a HW error, we set PG_hwpoison (except ia64 MCA, see the list)

Quoted 8 lines

2. Writes to that memory will be discarded

Who is the user of that? When will we have such pages right now?

3. Reads will return ~0, / 0?

I think this is a special case of e.g. x86? But where do we have that, are there any user?

When there are gaps in the physical memory. As in, if you put that physical address on the bus (or in a packet), no device will respond to it. Look:

00000000-00000fff : Reserved
00001000-00057fff : System RAM
00058000-00058fff : Reserved
00059000-0009dfff : System RAM
0009e000-000fffff : Reserved

Those examples I gave are examples of how various different architectures respond to "no device responded to this memory access".

#14 lore raw

Re: [PATCH RFC 7/7] mm: better document PG_reserved

Quoted 33 lines · Matthew Wilcox
Quoted 19 lines · David Hildenbrand
Quoted 7 lines · Matthew Wilcox
Quoted 5 lines · David Hildenbrand

I don't see a reason why we have to document "Some of them might not even exist". If there is a user, we should document it. E.g. for balloon drivers we now use PG_offline to indicate that a page might currently not be backed by memory in the hypervisor. And that is independent from PG_reserved.

Quoted 5 lines

I think you're confused by the meaning of "some of them might not even exist". What this means is that there might not be memory there; maybe writes to that memory will be discarded, or maybe they'll cause a machine check. Maybe reads will return ~0, or 0, or cause a machine check. We just don't know what's there, and we shouldn't try touching the memory.

If there are users, let's document it. And I need more details for that :)

1. machine check: if there is a HW error, we set PG_hwpoison (except ia64 MCA, see the list)

Quoted 8 lines

2. Writes to that memory will be discarded

Who is the user of that? When will we have such pages right now?

3. Reads will return ~0, / 0?

I think this is a special case of e.g. x86? But where do we have that, are there any user?

When there are gaps in the physical memory. As in, if you put that physical address on the bus (or in a packet), no device will respond to it. Look:

Quoted 9 lines

00000000-00000fff : Reserved
00001000-00057fff : System RAM
00058000-00058fff : Reserved
00059000-0009dfff : System RAM
0009e000-000fffff : Reserved

Those examples I gave are examples of how various different architectures respond to "no device responded to this memory access".

Okay, so for this memory we will have
a) vmmaps
b) Memory block devices
c) A sections that is online

So essentially "Gaps in physical memory" which is part of a online section.

This might be a candidate for PG_offline as well.

Thanks for the info, I'll try to find out how such things are handled. In general I assume this memory has to be readable, because otherwise kdump and friends would crash already when trying to dump?

Signature · 3 lines
Thanks,

David / dhildenb
#15 lore raw

Re: [PATCH RFC 7/7] mm: better document PG_reserved

Quoted 49 lines · David Hildenbrand
Quoted 33 lines · Matthew Wilcox
Quoted 19 lines · David Hildenbrand
Quoted 7 lines · Matthew Wilcox
Quoted 5 lines · David Hildenbrand

I don't see a reason why we have to document "Some of them might not even exist". If there is a user, we should document it. E.g. for balloon drivers we now use PG_offline to indicate that a page might currently not be backed by memory in the hypervisor. And that is independent from PG_reserved.

Quoted 5 lines

I think you're confused by the meaning of "some of them might not even exist". What this means is that there might not be memory there; maybe writes to that memory will be discarded, or maybe they'll cause a machine check. Maybe reads will return ~0, or 0, or cause a machine check. We just don't know what's there, and we shouldn't try touching the memory.

If there are users, let's document it. And I need more details for that :)

1. machine check: if there is a HW error, we set PG_hwpoison (except ia64 MCA, see the list)

Quoted 8 lines

2. Writes to that memory will be discarded

Who is the user of that? When will we have such pages right now?

3. Reads will return ~0, / 0?

I think this is a special case of e.g. x86? But where do we have that, are there any user?

When there are gaps in the physical memory. As in, if you put that physical address on the bus (or in a packet), no device will respond to it. Look:

Quoted 9 lines

00000000-00000fff : Reserved
00001000-00057fff : System RAM
00058000-00058fff : Reserved
00059000-0009dfff : System RAM
0009e000-000fffff : Reserved

Those examples I gave are examples of how various different architectures respond to "no device responded to this memory access".

Okay, so for this memory we will have
a) vmmaps
b) Memory block devices
c) A sections that is online

Quoted 8 lines

So essentially "Gaps in physical memory" which is part of a online section.

This might be a candidate for PG_offline as well.

Thanks for the info, I'll try to find out how such things are handled. In general I assume this memory has to be readable, because otherwise kdump and friends would crash already when trying to dump?

So I finally understood how physical memory holes in online sections are handled when dumping. They won't be dumped because the list of dumpable chunks (contained in /proc/kcore and after a crash /proc/vmcore) is built using walk_system_ram_range(). So anything not listed as RAM will be ignored.

I will update the documentation, describing that if we have an online section that is not completely IORESOURCE_SYSTEM_RAM, that the physical memory gaps will also be set to PG_reserved.

Trying to touch this memory is indeed dangerous, luckily dumping is properly handled.

I'll think about if marking these ranges as PG_offline might make sense (and if it can be easily added). Then we directly know when seeing that page type that we should not touch it. Ever.

That hint was really helpful :)

Signature · 3 lines
Thanks,

David / dhildenb
#16 lore raw
In reply to David Hildenbrand

On Wed 05-12-18 13:28:44, David Hildenbrand wrote:
[...]

Quoted 2 lines

Most notably, for device memory we can hopefully soon stop setting it PG_reserved

I am busy as hell so I am not likely to look at specific patche this week. But could you be more specific why we need to get rid of other PG_reserved users before we can do so for device memory?

I am all for removing relicts because they just confuse people but I fail to see any relation here.

Signature · 2 lines
Michal Hocko
SUSE Labs
#17 lore raw
Quoted 9 lines · Michal Hocko

On Wed 05-12-18 13:28:44, David Hildenbrand wrote:
[...]

Quoted 2 lines

Most notably, for device memory we can hopefully soon stop setting it PG_reserved

I am busy as hell so I am not likely to look at specific patche this week. But could you be more specific why we need to get rid of other PG_reserved users before we can do so for device memory?

No worries, this has time.

For device memory, nothing should really be needed. I am only collecting and docuumenting users and this is one user soon to go (eventually) :)

Quoted 3 lines

I am all for removing relicts because they just confuse people but I fail to see any relation here.

It's really only "why is this patch set not bigger", nothing related to device memory actually :)

Signature · 3 lines
Thanks,

David / dhildenb