All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v3 0/3] Introduce persistent memory pool
@ 2023-10-04 22:23 ` Stanislav Kinsburskii
  0 siblings, 0 replies; 13+ messages in thread
From: Stanislav Kinsburskii @ 2023-10-04 22:23 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86, hpa, ebiederm, akpm,
	stanislav.kinsburskii, corbet, linux-kernel, kexec, linux-mm,
	kys, jgowans, wei.liu, arnd, gregkh, graf, pbonzini, bhe,
	dave.hansen, kirill.shutemov

This patch introduces a memory allocator specifically tailored for
persistent memory within the kernel. The allocator maintains
kernel-specific states like DMA passthrough device states, IOMMU state, and
more across kexec.

The current implementation provides a foundation for custom solutions that
may be developed in the future. Although the design is kept concise and
straightforward to encourage discussion and feedback, it remains fully
functional.

The immediate need for the allocator is in ability to persist the kernel
pages deposited into Microsoft Hypervisor across kexec: these pages must
not be accessed by kernel when deposited, but can be withdrawn and released
back to kernel. Kexec in turn is used for servicing purposes and aimed to
minimize service downtime upon kernel upgrade in a fleet of machines.

The persistent memory pool builds upon the continuous memory allocator
(CMA) and ensures CMA state persistency across kexec by incorporating the
CMA bitmap into the memory region instead of allocation it from kernel
memory.

Persistent memory pool metadata is passed across kexec by using Flattened
Device Tree, which is added as another kexec segment for x86 architecture.

Potential applications include:

  1. Enabling various in-kernel entities to allocate persistent pages from
     a unified memory pool, obviating the need for reserving multiple
     regions.

  2. For in-kernel components that need the allocation address to be
     retained on kernel kexec, this address can be exposed to user space
     and subsequently passed through the command line.

  3. Distinct subsystems or drivers can set aside their region, allocating
     a segment for their persistent memory pool, suitable for uses such as
     file systems, key-value stores, and other applications.

Changes since v2:

  1. Device tree-related change are removed.

  2. Persistent memory pool region is marked as "reserved by kernel" in
     kexec e820 table, which indicates to the new kernel, that the pool
     must restored.

Changes since v1:

  1. Persistent memory pool is now a wrapper on top of CMA instead of being a
     new allocator.

  2. Persistent memory pool metadata doesn't belong to the pool anymore and
     is now passed via Flattened Device Tree instead over kexec to the new
     kernel.

The following series implements...

---

Stanislav Kinsburskii (3):
      x86/boot/e820: Expose kexec range update, remove and table update functions
      pmpool: Introduce persistent memory pool
      pmpool: Mark reserved range as "kernel reserved" in kexec e820 table


 arch/x86/include/asm/e820/api.h |    4 +
 arch/x86/kernel/e820.c          |   21 ++++-
 include/linux/pmpool.h          |   22 +++++
 mm/Kconfig                      |    8 ++
 mm/Makefile                     |    1 
 mm/pmpool.c                     |  159 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 209 insertions(+), 6 deletions(-)
 create mode 100644 include/linux/pmpool.h
 create mode 100644 mm/pmpool.c



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

* [RFC PATCH v3 0/3] Introduce persistent memory pool
@ 2023-10-04 22:23 ` Stanislav Kinsburskii
  0 siblings, 0 replies; 13+ messages in thread
From: Stanislav Kinsburskii @ 2023-10-04 22:23 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86, hpa, ebiederm, akpm,
	stanislav.kinsburskii, corbet, linux-kernel, kexec, linux-mm,
	kys, jgowans, wei.liu, arnd, gregkh, graf, pbonzini, bhe,
	dave.hansen, kirill.shutemov

This patch introduces a memory allocator specifically tailored for
persistent memory within the kernel. The allocator maintains
kernel-specific states like DMA passthrough device states, IOMMU state, and
more across kexec.

The current implementation provides a foundation for custom solutions that
may be developed in the future. Although the design is kept concise and
straightforward to encourage discussion and feedback, it remains fully
functional.

The immediate need for the allocator is in ability to persist the kernel
pages deposited into Microsoft Hypervisor across kexec: these pages must
not be accessed by kernel when deposited, but can be withdrawn and released
back to kernel. Kexec in turn is used for servicing purposes and aimed to
minimize service downtime upon kernel upgrade in a fleet of machines.

The persistent memory pool builds upon the continuous memory allocator
(CMA) and ensures CMA state persistency across kexec by incorporating the
CMA bitmap into the memory region instead of allocation it from kernel
memory.

Persistent memory pool metadata is passed across kexec by using Flattened
Device Tree, which is added as another kexec segment for x86 architecture.

Potential applications include:

  1. Enabling various in-kernel entities to allocate persistent pages from
     a unified memory pool, obviating the need for reserving multiple
     regions.

  2. For in-kernel components that need the allocation address to be
     retained on kernel kexec, this address can be exposed to user space
     and subsequently passed through the command line.

  3. Distinct subsystems or drivers can set aside their region, allocating
     a segment for their persistent memory pool, suitable for uses such as
     file systems, key-value stores, and other applications.

Changes since v2:

  1. Device tree-related change are removed.

  2. Persistent memory pool region is marked as "reserved by kernel" in
     kexec e820 table, which indicates to the new kernel, that the pool
     must restored.

Changes since v1:

  1. Persistent memory pool is now a wrapper on top of CMA instead of being a
     new allocator.

  2. Persistent memory pool metadata doesn't belong to the pool anymore and
     is now passed via Flattened Device Tree instead over kexec to the new
     kernel.

The following series implements...

---

Stanislav Kinsburskii (3):
      x86/boot/e820: Expose kexec range update, remove and table update functions
      pmpool: Introduce persistent memory pool
      pmpool: Mark reserved range as "kernel reserved" in kexec e820 table


 arch/x86/include/asm/e820/api.h |    4 +
 arch/x86/kernel/e820.c          |   21 ++++-
 include/linux/pmpool.h          |   22 +++++
 mm/Kconfig                      |    8 ++
 mm/Makefile                     |    1 
 mm/pmpool.c                     |  159 +++++++++++++++++++++++++++++++++++++++
 6 files changed, 209 insertions(+), 6 deletions(-)
 create mode 100644 include/linux/pmpool.h
 create mode 100644 mm/pmpool.c


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [RFC PATCH v3 1/3] x86/boot/e820: Expose kexec range update, remove and table update functions
  2023-10-04 22:23 ` Stanislav Kinsburskii
@ 2023-10-04 22:23   ` Stanislav Kinsburskii
  -1 siblings, 0 replies; 13+ messages in thread
From: Stanislav Kinsburskii @ 2023-10-04 22:23 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86, hpa, ebiederm, akpm,
	stanislav.kinsburskii, corbet, linux-kernel, kexec, linux-mm,
	kys, jgowans, wei.liu, arnd, gregkh, graf, pbonzini, bhe,
	dave.hansen, kirill.shutemov

This functions are to be used to reserve memory regions in kexec kernel by
other kernel subsystems.

Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
 arch/x86/include/asm/e820/api.h |    4 ++++
 arch/x86/kernel/e820.c          |   21 +++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/api.h
index e8f58ddd06d9..24bb8da928bb 100644
--- a/arch/x86/include/asm/e820/api.h
+++ b/arch/x86/include/asm/e820/api.h
@@ -22,6 +22,10 @@ extern void e820__print_table(char *who);
 extern int  e820__update_table(struct e820_table *table);
 extern void e820__update_table_print(void);
 
+extern u64  e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type);
+extern u64  e820__range_remove_kexec(u64 start, u64 size, enum e820_type old_type, bool check_type);
+extern void e820__update_table_kexec(void);
+
 extern unsigned long e820__end_of_ram_pfn(void);
 extern unsigned long e820__end_of_low_ram_pfn(void);
 
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index fb8cf953380d..f339815029f7 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -532,13 +532,12 @@ u64 __init e820__range_update(u64 start, u64 size, enum e820_type old_type, enum
 	return __e820__range_update(e820_table, start, size, old_type, new_type);
 }
 
-static u64 __init e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type  new_type)
+u64 __init e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type  new_type)
 {
 	return __e820__range_update(e820_table_kexec, start, size, old_type, new_type);
 }
 
-/* Remove a range of memory from the E820 table: */
-u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool check_type)
+u64 __init __e820__range_remove(struct e820_table *table, u64 start, u64 size, enum e820_type old_type, bool check_type)
 {
 	int i;
 	u64 end;
@@ -553,8 +552,8 @@ u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool
 		e820_print_type(old_type);
 	pr_cont("\n");
 
-	for (i = 0; i < e820_table->nr_entries; i++) {
-		struct e820_entry *entry = &e820_table->entries[i];
+	for (i = 0; i < table->nr_entries; i++) {
+		struct e820_entry *entry = &table->entries[i];
 		u64 final_start, final_end;
 		u64 entry_end;
 
@@ -599,6 +598,16 @@ u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool
 	return real_removed_size;
 }
 
+u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool check_type)
+{
+	return __e820__range_remove(e820_table, start, size, old_type, check_type);
+}
+
+u64 __init e820__range_remove_kexec(u64 start, u64 size, enum e820_type old_type, bool check_type)
+{
+	return __e820__range_remove(e820_table_kexec, start, size, old_type, check_type);
+}
+
 void __init e820__update_table_print(void)
 {
 	if (e820__update_table(e820_table))
@@ -608,7 +617,7 @@ void __init e820__update_table_print(void)
 	e820__print_table("modified");
 }
 
-static void __init e820__update_table_kexec(void)
+void __init e820__update_table_kexec(void)
 {
 	e820__update_table(e820_table_kexec);
 }




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

* [RFC PATCH v3 1/3] x86/boot/e820: Expose kexec range update, remove and table update functions
@ 2023-10-04 22:23   ` Stanislav Kinsburskii
  0 siblings, 0 replies; 13+ messages in thread
From: Stanislav Kinsburskii @ 2023-10-04 22:23 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86, hpa, ebiederm, akpm,
	stanislav.kinsburskii, corbet, linux-kernel, kexec, linux-mm,
	kys, jgowans, wei.liu, arnd, gregkh, graf, pbonzini, bhe,
	dave.hansen, kirill.shutemov

This functions are to be used to reserve memory regions in kexec kernel by
other kernel subsystems.

Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
 arch/x86/include/asm/e820/api.h |    4 ++++
 arch/x86/kernel/e820.c          |   21 +++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/api.h
index e8f58ddd06d9..24bb8da928bb 100644
--- a/arch/x86/include/asm/e820/api.h
+++ b/arch/x86/include/asm/e820/api.h
@@ -22,6 +22,10 @@ extern void e820__print_table(char *who);
 extern int  e820__update_table(struct e820_table *table);
 extern void e820__update_table_print(void);
 
+extern u64  e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type);
+extern u64  e820__range_remove_kexec(u64 start, u64 size, enum e820_type old_type, bool check_type);
+extern void e820__update_table_kexec(void);
+
 extern unsigned long e820__end_of_ram_pfn(void);
 extern unsigned long e820__end_of_low_ram_pfn(void);
 
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index fb8cf953380d..f339815029f7 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -532,13 +532,12 @@ u64 __init e820__range_update(u64 start, u64 size, enum e820_type old_type, enum
 	return __e820__range_update(e820_table, start, size, old_type, new_type);
 }
 
-static u64 __init e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type  new_type)
+u64 __init e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type  new_type)
 {
 	return __e820__range_update(e820_table_kexec, start, size, old_type, new_type);
 }
 
-/* Remove a range of memory from the E820 table: */
-u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool check_type)
+u64 __init __e820__range_remove(struct e820_table *table, u64 start, u64 size, enum e820_type old_type, bool check_type)
 {
 	int i;
 	u64 end;
@@ -553,8 +552,8 @@ u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool
 		e820_print_type(old_type);
 	pr_cont("\n");
 
-	for (i = 0; i < e820_table->nr_entries; i++) {
-		struct e820_entry *entry = &e820_table->entries[i];
+	for (i = 0; i < table->nr_entries; i++) {
+		struct e820_entry *entry = &table->entries[i];
 		u64 final_start, final_end;
 		u64 entry_end;
 
@@ -599,6 +598,16 @@ u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool
 	return real_removed_size;
 }
 
+u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool check_type)
+{
+	return __e820__range_remove(e820_table, start, size, old_type, check_type);
+}
+
+u64 __init e820__range_remove_kexec(u64 start, u64 size, enum e820_type old_type, bool check_type)
+{
+	return __e820__range_remove(e820_table_kexec, start, size, old_type, check_type);
+}
+
 void __init e820__update_table_print(void)
 {
 	if (e820__update_table(e820_table))
@@ -608,7 +617,7 @@ void __init e820__update_table_print(void)
 	e820__print_table("modified");
 }
 
-static void __init e820__update_table_kexec(void)
+void __init e820__update_table_kexec(void)
 {
 	e820__update_table(e820_table_kexec);
 }



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [RFC PATCH v3 2/3] pmpool: Introduce persistent memory pool
  2023-10-04 22:23 ` Stanislav Kinsburskii
@ 2023-10-04 22:23   ` Stanislav Kinsburskii
  -1 siblings, 0 replies; 13+ messages in thread
From: Stanislav Kinsburskii @ 2023-10-04 22:23 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86, hpa, ebiederm, akpm,
	stanislav.kinsburskii, corbet, linux-kernel, kexec, linux-mm,
	kys, jgowans, wei.liu, arnd, gregkh, graf, pbonzini, bhe,
	dave.hansen, kirill.shutemov

This patch introduces a memory allocator specifically tailored for
persistent memory within the kernel. The allocator maintains
kernel-specific states like DMA passthrough device states, IOMMU state, and
more across kexec.

The current implementation provides a foundation for custom solutions that
may be developed in the future. Although the design is kept concise and
straightforward to encourage discussion and feedback, it remains fully
functional.

The persistent memory pool builds upon the continuous memory allocator
(CMA) and ensures CMA state persistency across kexec by incorporating the
CMA bitmap into the memory region.

Potential applications include:

  1. Enabling various in-kernel entities to allocate persistent pages from
     a unified memory pool, obviating the need for reserving multiple
     regions.

  2. For in-kernel components that need the allocation address to be
     retained on kernel kexec, this address can be exposed to user space
     and subsequently passed through the command line.

  3. Distinct subsystems or drivers can set aside their region, allocating
     a segment for their persistent memory pool, suitable for uses such as
     file systems, key-value stores, and other applications.

Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
 include/linux/pmpool.h |   22 +++++++++
 mm/Kconfig             |    8 +++
 mm/Makefile            |    1 
 mm/pmpool.c            |  115 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 146 insertions(+)
 create mode 100644 include/linux/pmpool.h
 create mode 100644 mm/pmpool.c

diff --git a/include/linux/pmpool.h b/include/linux/pmpool.h
new file mode 100644
index 000000000000..b41f16fa9660
--- /dev/null
+++ b/include/linux/pmpool.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _PMPOOL_H
+#define _PMPOOL_H
+
+struct page;
+
+#if defined(CONFIG_PMPOOL)
+struct page *pmpool_alloc(unsigned long count);
+bool pmpool_release(struct page *pages, unsigned long count);
+#else
+static inline struct page *pmpool_alloc(unsigned long count)
+{
+	return NULL;
+}
+static inline bool pmpool_release(struct page *pages, unsigned long count)
+{
+	return false;
+}
+#endif
+
+#endif /* _PMPOOL_H */
diff --git a/mm/Kconfig b/mm/Kconfig
index 09130434e30d..e7c10094fb10 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -922,6 +922,14 @@ config CMA_AREAS
 
 	  If unsure, leave the default value "7" in UMA and "19" in NUMA.
 
+config PMPOOL
+	bool "Persistent memory pool support"
+	select CMA
+	help
+	  This option adds support for CMA-based persistent memory pool
+	  feature, which provides pages allocation and freeing from a set of
+	  persistent memory ranges, deposited to the memory pool.
+
 config MEM_SOFT_DIRTY
 	bool "Track memory changes"
 	depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY && PROC_FS
diff --git a/mm/Makefile b/mm/Makefile
index 678530a07326..8d3579e58c2c 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -139,3 +139,4 @@ obj-$(CONFIG_IO_MAPPING) += io-mapping.o
 obj-$(CONFIG_HAVE_BOOTMEM_INFO_NODE) += bootmem_info.o
 obj-$(CONFIG_GENERIC_IOREMAP) += ioremap.o
 obj-$(CONFIG_SHRINKER_DEBUG) += shrinker_debug.o
+obj-$(CONFIG_PMPOOL) += pmpool.o
diff --git a/mm/pmpool.c b/mm/pmpool.c
new file mode 100644
index 000000000000..c74f09b99283
--- /dev/null
+++ b/mm/pmpool.c
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#define pr_fmt(fmt) "pmpool: " fmt
+
+#include <linux/bitmap.h>
+#include <linux/cma.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/kexec.h>
+#include <linux/memblock.h>
+#include <linux/mm.h>
+#include <linux/pmpool.h>
+
+#include "cma.h"
+
+struct pmpool {
+	struct resource resource;
+	struct cma *cma;
+};
+
+static struct pmpool *default_pmpool;
+
+bool pmpool_release(struct page *pages, unsigned long count)
+{
+	if (!default_pmpool)
+		return false;
+
+	return cma_release(default_pmpool->cma, pages, count);
+}
+
+struct page *pmpool_alloc(unsigned long count)
+{
+	if (!default_pmpool)
+		return NULL;
+
+	return cma_alloc(default_pmpool->cma, count, 0, true);
+}
+
+static void pmpool_cma_accomodate_bitmap(struct cma *cma)
+{
+	unsigned long bitmap_size;
+
+	bitmap_free(cma->bitmap);
+	cma->bitmap = phys_to_virt(PFN_PHYS(cma->base_pfn));
+
+	bitmap_size = BITS_TO_LONGS(cma_bitmap_maxno(cma));
+	memset(cma->bitmap, 0, bitmap_size);
+	bitmap_set(cma->bitmap, 0, PAGE_ALIGN(bitmap_size) >> PAGE_SHIFT);
+
+	pr_info("CMA bitmap moved to %#llx\n", virt_to_phys(cma->bitmap));
+}
+
+static int __init default_pmpool_fixup(void)
+{
+	if (!default_pmpool)
+		return 0;
+
+	if (insert_resource(&iomem_resource, &default_pmpool->resource))
+		pr_err("failed to insert resource\n");
+
+	pmpool_cma_accomodate_bitmap(default_pmpool->cma);
+	return 0;
+}
+postcore_initcall(default_pmpool_fixup);
+
+static int __init parse_pmpool_opt(char *str)
+{
+	static struct pmpool pmpool = {
+		.resource = {
+			.name  = "Persistent Memory Pool",
+			.flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM,
+			.desc  = IORES_DESC_CXL
+		}
+	};
+	phys_addr_t base, size, end;
+	int err;
+
+	/* Format is pmpool=<base>,<size> */
+	base = memparse(str, &str);
+	size = memparse(str + 1, NULL);
+	end = base + size - 1;
+
+	err = memblock_is_region_reserved(base, size);
+	if (err) {
+		pr_err("memory block overlaps with another one: %d\n", err);
+		return 0;
+	}
+
+	err = memblock_reserve(base, size);
+	if (err) {
+		pr_err("failed to reserve memory block: %d\n", err);
+		return 0;
+	}
+
+	err = cma_init_reserved_mem(base, size, 0, "pmpool", &pmpool.cma);
+	if (err) {
+		pr_err("failed to initialize CMA: %d\n", err);
+		goto free_memblock;
+	}
+
+	pmpool.resource.start = base;
+	pmpool.resource.end = end;
+
+	pr_info("default memory pool is created: %#llx-%#llx\n",
+		base, end);
+
+	default_pmpool = &pmpool;
+
+	return 0;
+
+free_memblock:
+	memblock_phys_free(base, size);
+	return 0;
+}
+early_param("pmpool", parse_pmpool_opt);




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

* [RFC PATCH v3 2/3] pmpool: Introduce persistent memory pool
@ 2023-10-04 22:23   ` Stanislav Kinsburskii
  0 siblings, 0 replies; 13+ messages in thread
From: Stanislav Kinsburskii @ 2023-10-04 22:23 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86, hpa, ebiederm, akpm,
	stanislav.kinsburskii, corbet, linux-kernel, kexec, linux-mm,
	kys, jgowans, wei.liu, arnd, gregkh, graf, pbonzini, bhe,
	dave.hansen, kirill.shutemov

This patch introduces a memory allocator specifically tailored for
persistent memory within the kernel. The allocator maintains
kernel-specific states like DMA passthrough device states, IOMMU state, and
more across kexec.

The current implementation provides a foundation for custom solutions that
may be developed in the future. Although the design is kept concise and
straightforward to encourage discussion and feedback, it remains fully
functional.

The persistent memory pool builds upon the continuous memory allocator
(CMA) and ensures CMA state persistency across kexec by incorporating the
CMA bitmap into the memory region.

Potential applications include:

  1. Enabling various in-kernel entities to allocate persistent pages from
     a unified memory pool, obviating the need for reserving multiple
     regions.

  2. For in-kernel components that need the allocation address to be
     retained on kernel kexec, this address can be exposed to user space
     and subsequently passed through the command line.

  3. Distinct subsystems or drivers can set aside their region, allocating
     a segment for their persistent memory pool, suitable for uses such as
     file systems, key-value stores, and other applications.

Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
 include/linux/pmpool.h |   22 +++++++++
 mm/Kconfig             |    8 +++
 mm/Makefile            |    1 
 mm/pmpool.c            |  115 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 146 insertions(+)
 create mode 100644 include/linux/pmpool.h
 create mode 100644 mm/pmpool.c

diff --git a/include/linux/pmpool.h b/include/linux/pmpool.h
new file mode 100644
index 000000000000..b41f16fa9660
--- /dev/null
+++ b/include/linux/pmpool.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _PMPOOL_H
+#define _PMPOOL_H
+
+struct page;
+
+#if defined(CONFIG_PMPOOL)
+struct page *pmpool_alloc(unsigned long count);
+bool pmpool_release(struct page *pages, unsigned long count);
+#else
+static inline struct page *pmpool_alloc(unsigned long count)
+{
+	return NULL;
+}
+static inline bool pmpool_release(struct page *pages, unsigned long count)
+{
+	return false;
+}
+#endif
+
+#endif /* _PMPOOL_H */
diff --git a/mm/Kconfig b/mm/Kconfig
index 09130434e30d..e7c10094fb10 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -922,6 +922,14 @@ config CMA_AREAS
 
 	  If unsure, leave the default value "7" in UMA and "19" in NUMA.
 
+config PMPOOL
+	bool "Persistent memory pool support"
+	select CMA
+	help
+	  This option adds support for CMA-based persistent memory pool
+	  feature, which provides pages allocation and freeing from a set of
+	  persistent memory ranges, deposited to the memory pool.
+
 config MEM_SOFT_DIRTY
 	bool "Track memory changes"
 	depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY && PROC_FS
diff --git a/mm/Makefile b/mm/Makefile
index 678530a07326..8d3579e58c2c 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -139,3 +139,4 @@ obj-$(CONFIG_IO_MAPPING) += io-mapping.o
 obj-$(CONFIG_HAVE_BOOTMEM_INFO_NODE) += bootmem_info.o
 obj-$(CONFIG_GENERIC_IOREMAP) += ioremap.o
 obj-$(CONFIG_SHRINKER_DEBUG) += shrinker_debug.o
+obj-$(CONFIG_PMPOOL) += pmpool.o
diff --git a/mm/pmpool.c b/mm/pmpool.c
new file mode 100644
index 000000000000..c74f09b99283
--- /dev/null
+++ b/mm/pmpool.c
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#define pr_fmt(fmt) "pmpool: " fmt
+
+#include <linux/bitmap.h>
+#include <linux/cma.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/kexec.h>
+#include <linux/memblock.h>
+#include <linux/mm.h>
+#include <linux/pmpool.h>
+
+#include "cma.h"
+
+struct pmpool {
+	struct resource resource;
+	struct cma *cma;
+};
+
+static struct pmpool *default_pmpool;
+
+bool pmpool_release(struct page *pages, unsigned long count)
+{
+	if (!default_pmpool)
+		return false;
+
+	return cma_release(default_pmpool->cma, pages, count);
+}
+
+struct page *pmpool_alloc(unsigned long count)
+{
+	if (!default_pmpool)
+		return NULL;
+
+	return cma_alloc(default_pmpool->cma, count, 0, true);
+}
+
+static void pmpool_cma_accomodate_bitmap(struct cma *cma)
+{
+	unsigned long bitmap_size;
+
+	bitmap_free(cma->bitmap);
+	cma->bitmap = phys_to_virt(PFN_PHYS(cma->base_pfn));
+
+	bitmap_size = BITS_TO_LONGS(cma_bitmap_maxno(cma));
+	memset(cma->bitmap, 0, bitmap_size);
+	bitmap_set(cma->bitmap, 0, PAGE_ALIGN(bitmap_size) >> PAGE_SHIFT);
+
+	pr_info("CMA bitmap moved to %#llx\n", virt_to_phys(cma->bitmap));
+}
+
+static int __init default_pmpool_fixup(void)
+{
+	if (!default_pmpool)
+		return 0;
+
+	if (insert_resource(&iomem_resource, &default_pmpool->resource))
+		pr_err("failed to insert resource\n");
+
+	pmpool_cma_accomodate_bitmap(default_pmpool->cma);
+	return 0;
+}
+postcore_initcall(default_pmpool_fixup);
+
+static int __init parse_pmpool_opt(char *str)
+{
+	static struct pmpool pmpool = {
+		.resource = {
+			.name  = "Persistent Memory Pool",
+			.flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM,
+			.desc  = IORES_DESC_CXL
+		}
+	};
+	phys_addr_t base, size, end;
+	int err;
+
+	/* Format is pmpool=<base>,<size> */
+	base = memparse(str, &str);
+	size = memparse(str + 1, NULL);
+	end = base + size - 1;
+
+	err = memblock_is_region_reserved(base, size);
+	if (err) {
+		pr_err("memory block overlaps with another one: %d\n", err);
+		return 0;
+	}
+
+	err = memblock_reserve(base, size);
+	if (err) {
+		pr_err("failed to reserve memory block: %d\n", err);
+		return 0;
+	}
+
+	err = cma_init_reserved_mem(base, size, 0, "pmpool", &pmpool.cma);
+	if (err) {
+		pr_err("failed to initialize CMA: %d\n", err);
+		goto free_memblock;
+	}
+
+	pmpool.resource.start = base;
+	pmpool.resource.end = end;
+
+	pr_info("default memory pool is created: %#llx-%#llx\n",
+		base, end);
+
+	default_pmpool = &pmpool;
+
+	return 0;
+
+free_memblock:
+	memblock_phys_free(base, size);
+	return 0;
+}
+early_param("pmpool", parse_pmpool_opt);



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [RFC PATCH v3 3/3] pmpool: Mark reserved range as "kernel reserved" in kexec e820 table
  2023-10-04 22:23 ` Stanislav Kinsburskii
@ 2023-10-04 22:23   ` Stanislav Kinsburskii
  -1 siblings, 0 replies; 13+ messages in thread
From: Stanislav Kinsburskii @ 2023-10-04 22:23 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86, hpa, ebiederm, akpm,
	stanislav.kinsburskii, corbet, linux-kernel, kexec, linux-mm,
	kys, jgowans, wei.liu, arnd, gregkh, graf, pbonzini, bhe,
	dave.hansen, kirill.shutemov

Update the logic to classify the persistent memory pool in the kexec e820
table as "kernel reserved" when its corresponding e820 region type is
"System RAM". Restore the pool when its type is "kernel reserved". This
ensures the persistence of the memory pool across kexec operations.

Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
 mm/pmpool.c |   50 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 47 insertions(+), 3 deletions(-)

diff --git a/mm/pmpool.c b/mm/pmpool.c
index c74f09b99283..1e3a2dffc5d3 100644
--- a/mm/pmpool.c
+++ b/mm/pmpool.c
@@ -11,11 +11,14 @@
 #include <linux/mm.h>
 #include <linux/pmpool.h>
 
+#include <asm/e820/api.h>
+
 #include "cma.h"
 
 struct pmpool {
 	struct resource resource;
 	struct cma *cma;
+	bool exists;
 };
 
 static struct pmpool *default_pmpool;
@@ -50,6 +53,18 @@ static void pmpool_cma_accomodate_bitmap(struct cma *cma)
 	pr_info("CMA bitmap moved to %#llx\n", virt_to_phys(cma->bitmap));
 }
 
+static void pmpool_cma_restore_bitmap(struct cma *cma)
+{
+	u64 base;
+
+	base = PFN_PHYS(cma->base_pfn);
+
+	bitmap_free(cma->bitmap);
+	cma->bitmap = phys_to_virt(base);
+
+	pr_info("CMA bitmap restored to %#llx\n", base);
+}
+
 static int __init default_pmpool_fixup(void)
 {
 	if (!default_pmpool)
@@ -58,7 +73,11 @@ static int __init default_pmpool_fixup(void)
 	if (insert_resource(&iomem_resource, &default_pmpool->resource))
 		pr_err("failed to insert resource\n");
 
-	pmpool_cma_accomodate_bitmap(default_pmpool->cma);
+	if (default_pmpool->exists)
+		pmpool_cma_restore_bitmap(default_pmpool->cma);
+	else
+		pmpool_cma_accomodate_bitmap(default_pmpool->cma);
+
 	return 0;
 }
 postcore_initcall(default_pmpool_fixup);
@@ -73,7 +92,7 @@ static int __init parse_pmpool_opt(char *str)
 		}
 	};
 	phys_addr_t base, size, end;
-	int err;
+	int err, e820_type;
 
 	/* Format is pmpool=<base>,<size> */
 	base = memparse(str, &str);
@@ -92,10 +111,33 @@ static int __init parse_pmpool_opt(char *str)
 		return 0;
 	}
 
+	e820_type = e820__get_entry_type(base, end);
+	switch (e820_type) {
+	case E820_TYPE_RAM:
+		e820__range_update_kexec(base, size, E820_TYPE_RAM,
+					 E820_TYPE_RESERVED_KERN);
+		e820__update_table_kexec();
+		break;
+	case E820_TYPE_RESERVED_KERN:
+		/*
+		 * TODO: there are several assumptions here:
+		 *   1. That the kernel reserved region represents pmpool,
+		 *   2. That the region had the same base and size and
+		 *   3. That the region was properly initialized.
+		 * All these assumptions aren't valid in general case and this
+		 * should be addressed.
+		 */
+		pmpool.exists = true;
+		break;
+	default:
+		pr_err("unsupported e820 type: %d\n", e820_type);
+		goto free_memblock;
+	}
+
 	err = cma_init_reserved_mem(base, size, 0, "pmpool", &pmpool.cma);
 	if (err) {
 		pr_err("failed to initialize CMA: %d\n", err);
-		goto free_memblock;
+		goto remove_e820_kexec_range;
 	}
 
 	pmpool.resource.start = base;
@@ -108,6 +150,8 @@ static int __init parse_pmpool_opt(char *str)
 
 	return 0;
 
+remove_e820_kexec_range:
+	e820__range_remove_kexec(base, size, E820_TYPE_RESERVED_KERN, 1);
 free_memblock:
 	memblock_phys_free(base, size);
 	return 0;




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

* [RFC PATCH v3 3/3] pmpool: Mark reserved range as "kernel reserved" in kexec e820 table
@ 2023-10-04 22:23   ` Stanislav Kinsburskii
  0 siblings, 0 replies; 13+ messages in thread
From: Stanislav Kinsburskii @ 2023-10-04 22:23 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86, hpa, ebiederm, akpm,
	stanislav.kinsburskii, corbet, linux-kernel, kexec, linux-mm,
	kys, jgowans, wei.liu, arnd, gregkh, graf, pbonzini, bhe,
	dave.hansen, kirill.shutemov

Update the logic to classify the persistent memory pool in the kexec e820
table as "kernel reserved" when its corresponding e820 region type is
"System RAM". Restore the pool when its type is "kernel reserved". This
ensures the persistence of the memory pool across kexec operations.

Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
---
 mm/pmpool.c |   50 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 47 insertions(+), 3 deletions(-)

diff --git a/mm/pmpool.c b/mm/pmpool.c
index c74f09b99283..1e3a2dffc5d3 100644
--- a/mm/pmpool.c
+++ b/mm/pmpool.c
@@ -11,11 +11,14 @@
 #include <linux/mm.h>
 #include <linux/pmpool.h>
 
+#include <asm/e820/api.h>
+
 #include "cma.h"
 
 struct pmpool {
 	struct resource resource;
 	struct cma *cma;
+	bool exists;
 };
 
 static struct pmpool *default_pmpool;
@@ -50,6 +53,18 @@ static void pmpool_cma_accomodate_bitmap(struct cma *cma)
 	pr_info("CMA bitmap moved to %#llx\n", virt_to_phys(cma->bitmap));
 }
 
+static void pmpool_cma_restore_bitmap(struct cma *cma)
+{
+	u64 base;
+
+	base = PFN_PHYS(cma->base_pfn);
+
+	bitmap_free(cma->bitmap);
+	cma->bitmap = phys_to_virt(base);
+
+	pr_info("CMA bitmap restored to %#llx\n", base);
+}
+
 static int __init default_pmpool_fixup(void)
 {
 	if (!default_pmpool)
@@ -58,7 +73,11 @@ static int __init default_pmpool_fixup(void)
 	if (insert_resource(&iomem_resource, &default_pmpool->resource))
 		pr_err("failed to insert resource\n");
 
-	pmpool_cma_accomodate_bitmap(default_pmpool->cma);
+	if (default_pmpool->exists)
+		pmpool_cma_restore_bitmap(default_pmpool->cma);
+	else
+		pmpool_cma_accomodate_bitmap(default_pmpool->cma);
+
 	return 0;
 }
 postcore_initcall(default_pmpool_fixup);
@@ -73,7 +92,7 @@ static int __init parse_pmpool_opt(char *str)
 		}
 	};
 	phys_addr_t base, size, end;
-	int err;
+	int err, e820_type;
 
 	/* Format is pmpool=<base>,<size> */
 	base = memparse(str, &str);
@@ -92,10 +111,33 @@ static int __init parse_pmpool_opt(char *str)
 		return 0;
 	}
 
+	e820_type = e820__get_entry_type(base, end);
+	switch (e820_type) {
+	case E820_TYPE_RAM:
+		e820__range_update_kexec(base, size, E820_TYPE_RAM,
+					 E820_TYPE_RESERVED_KERN);
+		e820__update_table_kexec();
+		break;
+	case E820_TYPE_RESERVED_KERN:
+		/*
+		 * TODO: there are several assumptions here:
+		 *   1. That the kernel reserved region represents pmpool,
+		 *   2. That the region had the same base and size and
+		 *   3. That the region was properly initialized.
+		 * All these assumptions aren't valid in general case and this
+		 * should be addressed.
+		 */
+		pmpool.exists = true;
+		break;
+	default:
+		pr_err("unsupported e820 type: %d\n", e820_type);
+		goto free_memblock;
+	}
+
 	err = cma_init_reserved_mem(base, size, 0, "pmpool", &pmpool.cma);
 	if (err) {
 		pr_err("failed to initialize CMA: %d\n", err);
-		goto free_memblock;
+		goto remove_e820_kexec_range;
 	}
 
 	pmpool.resource.start = base;
@@ -108,6 +150,8 @@ static int __init parse_pmpool_opt(char *str)
 
 	return 0;
 
+remove_e820_kexec_range:
+	e820__range_remove_kexec(base, size, E820_TYPE_RESERVED_KERN, 1);
 free_memblock:
 	memblock_phys_free(base, size);
 	return 0;



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [RFC PATCH v3 1/3] x86/boot/e820: Expose kexec range update, remove and table update functions
  2023-10-04 22:23   ` Stanislav Kinsburskii
  (?)
@ 2023-10-05  0:51   ` kernel test robot
  -1 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2023-10-05  0:51 UTC (permalink / raw)
  To: Stanislav Kinsburskii; +Cc: oe-kbuild-all

Hi Stanislav,

[This is a private test report for your RFC patch.]
kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/x86/core]
[also build test WARNING on tip/master linus/master tip/auto-latest v6.6-rc4 next-20231004]
[cannot apply to akpm-mm/mm-everything]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Stanislav-Kinsburskii/x86-boot-e820-Expose-kexec-range-update-remove-and-table-update-functions/20231005-062443
base:   tip/x86/core
patch link:    https://lore.kernel.org/r/169645819587.11424.5389114333710932782.stgit%40skinsburskii.
patch subject: [RFC PATCH v3 1/3] x86/boot/e820: Expose kexec range update, remove and table update functions
config: i386-tinyconfig (https://download.01.org/0day-ci/archive/20231005/202310050834.yzvi1BYv-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231005/202310050834.yzvi1BYv-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310050834.yzvi1BYv-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> arch/x86/kernel/e820.c:540:12: warning: no previous prototype for '__e820__range_remove' [-Wmissing-prototypes]
     540 | u64 __init __e820__range_remove(struct e820_table *table, u64 start, u64 size, enum e820_type old_type, bool check_type)
         |            ^~~~~~~~~~~~~~~~~~~~


vim +/__e820__range_remove +540 arch/x86/kernel/e820.c

   539	
 > 540	u64 __init __e820__range_remove(struct e820_table *table, u64 start, u64 size, enum e820_type old_type, bool check_type)
   541	{
   542		int i;
   543		u64 end;
   544		u64 real_removed_size = 0;
   545	
   546		if (size > (ULLONG_MAX - start))
   547			size = ULLONG_MAX - start;
   548	
   549		end = start + size;
   550		printk(KERN_DEBUG "e820: remove [mem %#010Lx-%#010Lx] ", start, end - 1);
   551		if (check_type)
   552			e820_print_type(old_type);
   553		pr_cont("\n");
   554	
   555		for (i = 0; i < table->nr_entries; i++) {
   556			struct e820_entry *entry = &table->entries[i];
   557			u64 final_start, final_end;
   558			u64 entry_end;
   559	
   560			if (check_type && entry->type != old_type)
   561				continue;
   562	
   563			entry_end = entry->addr + entry->size;
   564	
   565			/* Completely covered? */
   566			if (entry->addr >= start && entry_end <= end) {
   567				real_removed_size += entry->size;
   568				memset(entry, 0, sizeof(*entry));
   569				continue;
   570			}
   571	
   572			/* Is the new range completely covered? */
   573			if (entry->addr < start && entry_end > end) {
   574				e820__range_add(end, entry_end - end, entry->type);
   575				entry->size = start - entry->addr;
   576				real_removed_size += size;
   577				continue;
   578			}
   579	
   580			/* Partially covered: */
   581			final_start = max(start, entry->addr);
   582			final_end = min(end, entry_end);
   583			if (final_start >= final_end)
   584				continue;
   585	
   586			real_removed_size += final_end - final_start;
   587	
   588			/*
   589			 * Left range could be head or tail, so need to update
   590			 * the size first:
   591			 */
   592			entry->size -= final_end - final_start;
   593			if (entry->addr < final_start)
   594				continue;
   595	
   596			entry->addr = final_end;
   597		}
   598		return real_removed_size;
   599	}
   600	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [RFC PATCH v3 1/3] x86/boot/e820: Expose kexec range update, remove and table update functions
  2023-10-04 22:23   ` Stanislav Kinsburskii
  (?)
  (?)
@ 2023-10-05 10:10   ` kernel test robot
  -1 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2023-10-05 10:10 UTC (permalink / raw)
  To: Stanislav Kinsburskii; +Cc: oe-kbuild-all

Hi Stanislav,

[This is a private test report for your RFC patch.]
kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/x86/core]
[also build test WARNING on tip/master linus/master tip/auto-latest v6.6-rc4 next-20231005]
[cannot apply to akpm-mm/mm-everything]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Stanislav-Kinsburskii/x86-boot-e820-Expose-kexec-range-update-remove-and-table-update-functions/20231005-062443
base:   tip/x86/core
patch link:    https://lore.kernel.org/r/169645819587.11424.5389114333710932782.stgit%40skinsburskii.
patch subject: [RFC PATCH v3 1/3] x86/boot/e820: Expose kexec range update, remove and table update functions
config: i386-randconfig-003-20231005 (https://download.01.org/0day-ci/archive/20231005/202310051753.cGqR9NNP-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231005/202310051753.cGqR9NNP-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310051753.cGqR9NNP-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> arch/x86/kernel/e820.c:540:12: warning: no previous declaration for '__e820__range_remove' [-Wmissing-declarations]
    u64 __init __e820__range_remove(struct e820_table *table, u64 start, u64 size, enum e820_type old_type, bool check_type)
               ^~~~~~~~~~~~~~~~~~~~


vim +/__e820__range_remove +540 arch/x86/kernel/e820.c

   539	
 > 540	u64 __init __e820__range_remove(struct e820_table *table, u64 start, u64 size, enum e820_type old_type, bool check_type)
   541	{
   542		int i;
   543		u64 end;
   544		u64 real_removed_size = 0;
   545	
   546		if (size > (ULLONG_MAX - start))
   547			size = ULLONG_MAX - start;
   548	
   549		end = start + size;
   550		printk(KERN_DEBUG "e820: remove [mem %#010Lx-%#010Lx] ", start, end - 1);
   551		if (check_type)
   552			e820_print_type(old_type);
   553		pr_cont("\n");
   554	
   555		for (i = 0; i < table->nr_entries; i++) {
   556			struct e820_entry *entry = &table->entries[i];
   557			u64 final_start, final_end;
   558			u64 entry_end;
   559	
   560			if (check_type && entry->type != old_type)
   561				continue;
   562	
   563			entry_end = entry->addr + entry->size;
   564	
   565			/* Completely covered? */
   566			if (entry->addr >= start && entry_end <= end) {
   567				real_removed_size += entry->size;
   568				memset(entry, 0, sizeof(*entry));
   569				continue;
   570			}
   571	
   572			/* Is the new range completely covered? */
   573			if (entry->addr < start && entry_end > end) {
   574				e820__range_add(end, entry_end - end, entry->type);
   575				entry->size = start - entry->addr;
   576				real_removed_size += size;
   577				continue;
   578			}
   579	
   580			/* Partially covered: */
   581			final_start = max(start, entry->addr);
   582			final_end = min(end, entry_end);
   583			if (final_start >= final_end)
   584				continue;
   585	
   586			real_removed_size += final_end - final_start;
   587	
   588			/*
   589			 * Left range could be head or tail, so need to update
   590			 * the size first:
   591			 */
   592			entry->size -= final_end - final_start;
   593			if (entry->addr < final_start)
   594				continue;
   595	
   596			entry->addr = final_end;
   597		}
   598		return real_removed_size;
   599	}
   600	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [RFC PATCH v3 1/3] x86/boot/e820: Expose kexec range update, remove and table update functions
  2023-10-04 22:23   ` Stanislav Kinsburskii
                     ` (2 preceding siblings ...)
  (?)
@ 2023-10-05 13:52   ` kernel test robot
  -1 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2023-10-05 13:52 UTC (permalink / raw)
  To: Stanislav Kinsburskii; +Cc: oe-kbuild-all

Hi Stanislav,

[This is a private test report for your RFC patch.]
kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/x86/core]
[also build test WARNING on tip/master linus/master tip/auto-latest v6.6-rc4 next-20231005]
[cannot apply to akpm-mm/mm-everything]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Stanislav-Kinsburskii/x86-boot-e820-Expose-kexec-range-update-remove-and-table-update-functions/20231005-062443
base:   tip/x86/core
patch link:    https://lore.kernel.org/r/169645819587.11424.5389114333710932782.stgit%40skinsburskii.
patch subject: [RFC PATCH v3 1/3] x86/boot/e820: Expose kexec range update, remove and table update functions
config: i386-randconfig-061-20231005 (https://download.01.org/0day-ci/archive/20231005/202310052150.9vrauAwJ-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231005/202310052150.9vrauAwJ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310052150.9vrauAwJ-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> arch/x86/kernel/e820.c:540:12: sparse: sparse: symbol '__e820__range_remove' was not declared. Should it be static?

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [RFC PATCH v3 3/3] pmpool: Mark reserved range as "kernel reserved" in kexec e820 table
  2023-10-04 22:23   ` Stanislav Kinsburskii
  (?)
@ 2023-10-05 15:58   ` kernel test robot
  -1 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2023-10-05 15:58 UTC (permalink / raw)
  To: Stanislav Kinsburskii; +Cc: oe-kbuild-all

Hi Stanislav,

[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:

[auto build test ERROR on tip/x86/core]
[also build test ERROR on tip/master linus/master tip/auto-latest v6.6-rc4]
[cannot apply to akpm-mm/mm-everything next-20231005]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Stanislav-Kinsburskii/x86-boot-e820-Expose-kexec-range-update-remove-and-table-update-functions/20231005-062443
base:   tip/x86/core
patch link:    https://lore.kernel.org/r/169645820784.11424.922048380402402210.stgit%40skinsburskii.
patch subject: [RFC PATCH v3 3/3] pmpool: Mark reserved range as "kernel reserved" in kexec e820 table
config: sh-allyesconfig (https://download.01.org/0day-ci/archive/20231005/202310052300.FaQMeNIN-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231005/202310052300.FaQMeNIN-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310052300.FaQMeNIN-lkp@intel.com/

All errors (new ones prefixed by >>):

>> mm/pmpool.c:14:10: fatal error: asm/e820/api.h: No such file or directory
      14 | #include <asm/e820/api.h>
         |          ^~~~~~~~~~~~~~~~
   compilation terminated.

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for CMA
   Depends on [n]: MMU [=n]
   Selected by [y]:
   - PMPOOL [=y]


vim +14 mm/pmpool.c

    13	
  > 14	#include <asm/e820/api.h>
    15	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [RFC PATCH v3 3/3] pmpool: Mark reserved range as "kernel reserved" in kexec e820 table
  2023-10-04 22:23   ` Stanislav Kinsburskii
  (?)
  (?)
@ 2023-11-06 15:04   ` kernel test robot
  -1 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2023-11-06 15:04 UTC (permalink / raw)
  To: Stanislav Kinsburskii; +Cc: llvm, oe-kbuild-all

Hi Stanislav,

[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:

[auto build test ERROR on tip/x86/core]
[also build test ERROR on tip/master linus/master tip/auto-latest v6.6 next-20231106]
[cannot apply to akpm-mm/mm-everything]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Stanislav-Kinsburskii/x86-boot-e820-Expose-kexec-range-update-remove-and-table-update-functions/20231005-062443
base:   tip/x86/core
patch link:    https://lore.kernel.org/r/169645820784.11424.922048380402402210.stgit%40skinsburskii.
patch subject: [RFC PATCH v3 3/3] pmpool: Mark reserved range as "kernel reserved" in kexec e820 table
config: powerpc64-allyesconfig (https://download.01.org/0day-ci/archive/20231106/202311062223.Dqaf29S5-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231106/202311062223.Dqaf29S5-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311062223.Dqaf29S5-lkp@intel.com/

All errors (new ones prefixed by >>):

>> mm/pmpool.c:14:10: fatal error: 'asm/e820/api.h' file not found
      14 | #include <asm/e820/api.h>
         |          ^~~~~~~~~~~~~~~~
   1 error generated.


vim +14 mm/pmpool.c

    13	
  > 14	#include <asm/e820/api.h>
    15	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2023-11-06 15:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-04 22:23 [RFC PATCH v3 0/3] Introduce persistent memory pool Stanislav Kinsburskii
2023-10-04 22:23 ` Stanislav Kinsburskii
2023-10-04 22:23 ` [RFC PATCH v3 1/3] x86/boot/e820: Expose kexec range update, remove and table update functions Stanislav Kinsburskii
2023-10-04 22:23   ` Stanislav Kinsburskii
2023-10-05  0:51   ` kernel test robot
2023-10-05 10:10   ` kernel test robot
2023-10-05 13:52   ` kernel test robot
2023-10-04 22:23 ` [RFC PATCH v3 2/3] pmpool: Introduce persistent memory pool Stanislav Kinsburskii
2023-10-04 22:23   ` Stanislav Kinsburskii
2023-10-04 22:23 ` [RFC PATCH v3 3/3] pmpool: Mark reserved range as "kernel reserved" in kexec e820 table Stanislav Kinsburskii
2023-10-04 22:23   ` Stanislav Kinsburskii
2023-10-05 15:58   ` kernel test robot
2023-11-06 15:04   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.