linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/3] mm/memory_hotplug: Interface to add driver-managed system ram
@ 2020-05-04 19:02 David Hildenbrand
  2020-05-04 19:02 ` [PATCH v3 1/3] mm/memory_hotplug: Introduce add_memory_device_managed() David Hildenbrand
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: David Hildenbrand @ 2020-05-04 19:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, linux-nvdimm, kexec, Vishal Verma, Dave Jiang,
	Pavel Tatashin, David Hildenbrand, Andrew Morton, Baoquan He,
	Dan Williams, Dave Hansen, Eric Biederman, Michal Hocko,
	Pankaj Gupta, Wei Yang

Third time is the charm? Let's see ... :)

This is the follow up of [1]:
 [PATCH v1 0/3] mm/memory_hotplug: Make virtio-mem play nicely with
 kexec-tools
and [2]:
 [PATCH v2 0/3] mm/memory_hotplug: Allow to not create firmware memmap
 entries

kexec (via kexec_load()) can currently not properly handle memory added via
dax/kmem, and will have similar issues with virtio-mem. kexec-tools will
currently add all memory to the fixed-up initial firmware memmap. In case
of dax/kmem, this means that - in contrast to a proper reboot - how that
persistent memory will be used can no longer be configured by the kexec'd
kernel. In case of virtio-mem it will be harmful, because that memory
might contain inaccessible pieces that require coordination with hypervisor
first.

In both cases, we want to let the driver in the kexec'd kernel handle
detecting and adding the memory, like during an ordinary reboot.
Introduce add_memory_driver_managed(). More on the samentics are in patch
#1.

In the future, we might want to make this behavior configurable for
dax/kmem- either by configuring it in the kernel (which would then also
allow to configure kexec_file_load()) or in kexec-tools by also adding
"System RAM (kmem)" memory from /proc/iomem to the fixed-up initial
firmware memmap.

More on the motivation can be found in [1] and [2].

v2 -> v3:
- Don't use flags for add_memory() and friends, provide
  add_memory_driver_managed() instead.
- Flag memory resources via IORESOURCE_MEM_DRIVER_MANAGED and handle them
  in kexec.
- Name memory resources "System RAM ($DRIVER)", visible via /proc/iomem
- Added more details to the patch descriptions, especially regarding the
  history of /sys/firmware/memmap
- Add a comment to the device-dax change. Dropped Dave's Ack as the

v1 -> v2:
- Don't change the resource name
- Rename the flag to MHP_NO_FIRMWARE_MEMMAP to reflect what it is doing
- Rephrase subjects/descriptions
- Use the flag for dax/kmem

[1] https://lkml.kernel.org/r/20200429160803.109056-1-david@redhat.com
[2] https://lkml.kernel.org/r/20200430102908.10107-1-david@redhat.com

David Hildenbrand (3):
  mm/memory_hotplug: Introduce add_memory_device_managed()
  kexec_file: Don't place kexec images on IORESOURCE_MEM_DRIVER_MANAGED
  device-dax: Add memory via add_memory_driver_managed()

 drivers/dax/kmem.c             |  8 ++++-
 include/linux/ioport.h         |  1 +
 include/linux/memory_hotplug.h |  2 ++
 kernel/kexec_file.c            |  5 +++
 mm/memory_hotplug.c            | 62 +++++++++++++++++++++++++++++++---
 5 files changed, 73 insertions(+), 5 deletions(-)

-- 
2.25.3



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

* [PATCH v3 1/3] mm/memory_hotplug: Introduce add_memory_device_managed()
  2020-05-04 19:02 [PATCH v3 0/3] mm/memory_hotplug: Interface to add driver-managed system ram David Hildenbrand
@ 2020-05-04 19:02 ` David Hildenbrand
  2020-05-06 13:57   ` Pankaj Gupta
  2020-05-06 14:19   ` David Hildenbrand
  2020-05-04 19:02 ` [PATCH v3 2/3] kexec_file: Don't place kexec images on IORESOURCE_MEM_DRIVER_MANAGED David Hildenbrand
  2020-05-04 19:02 ` [PATCH v3 3/3] device-dax: Add memory via add_memory_driver_managed() David Hildenbrand
  2 siblings, 2 replies; 7+ messages in thread
From: David Hildenbrand @ 2020-05-04 19:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, linux-nvdimm, kexec, Vishal Verma, Dave Jiang,
	Pavel Tatashin, David Hildenbrand, Andrew Morton, Michal Hocko,
	Pankaj Gupta, Wei Yang, Baoquan He, Dave Hansen, Eric Biederman,
	Dan Williams

Some device drivers rely on memory they managed to not get added to the
initial (firmware) memmap as system RAM - so it's not used as initial
system RAM by the kernel and the driver is under control. While this is the
case during cold boot and after a reboot, kexec is not aware of that and
might add such memory to the initial (firmware) memmap of the kexec kernel.
We need ways to teach kernel and userspace that this system ram is
different.

For example, dax/kmem allows to decide at runtime if persistent memory is
to be used as system ram. Another future user is virtio-mem, which has to
coordinate with its hypervisor to deal with inaccessible parts within
memory resources.

We want to let users in the kernel (esp. kexec) but also user space
(esp. kexec-tools) know that this memory has different semantics and
needs to be handled differently:
1. Don't create entries in /sys/firmware/memmap/
2. Name the memory resource "System RAM ($DRIVER)" (exposed via
   /proc/iomem) ($DRIVER might be "kmem", "virtio_mem").
3. Flag the memory resource IORESOURCE_MEM_DRIVER_MANAGED

/sys/firmware/memmap/ [1] represents the "raw firmware-provided memory map"
because "on most architectures that firmware-provided memory map is
modified afterwards by the kernel itself". The primary user is kexec on
x86-64. Since commit d96ae5309165 ("memory-hotplug: create
/sys/firmware/memmap entry for new memory"), we add all hotplugged
memory to that firmware memmap - which makes perfect sense for traditional
memory hotplug on x86-64, where real HW will also add hotplugged DIMMs to
the firmware memmap. We replicate what the "raw firmware-provided memory
map" looks like after hot(un)plug.

To keep things simple, let the user provide the full resource name
instead of only the driver name - this way, we don't have to manually
allocate/craft strings for memory resources. Also use the resource
name to make decisions, to avoid passing additional flags. In case the
name isn't "System RAM", it's special.

We don't have to worry about firmware_map_remove() on the removal path. If
there is no entry, it will simply return with -EINVAL.

We'll adapt dax/kmem in a follow-up patch.

[1] https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-firmware-memmap

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 include/linux/ioport.h         |  1 +
 include/linux/memory_hotplug.h |  2 ++
 mm/memory_hotplug.c            | 62 +++++++++++++++++++++++++++++++---
 3 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index a9b9170b5dd2..cc9a5b4593ca 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -103,6 +103,7 @@ struct resource {
 #define IORESOURCE_MEM_32BIT		(3<<3)
 #define IORESOURCE_MEM_SHADOWABLE	(1<<5)	/* dup: IORESOURCE_SHADOWABLE */
 #define IORESOURCE_MEM_EXPANSIONROM	(1<<6)
+#define IORESOURCE_MEM_DRIVER_MANAGED	(1<<7)
 
 /* PnP I/O specific bits (IORESOURCE_BITS) */
 #define IORESOURCE_IO_16BIT_ADDR	(1<<0)
diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 7dca9cd6076b..fee7fab5d706 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -342,6 +342,8 @@ extern void __ref free_area_init_core_hotplug(int nid);
 extern int __add_memory(int nid, u64 start, u64 size);
 extern int add_memory(int nid, u64 start, u64 size);
 extern int add_memory_resource(int nid, struct resource *resource);
+extern int add_memory_driver_managed(int nid, u64 start, u64 size,
+				     const char *resource_name);
 extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
 		unsigned long nr_pages, struct vmem_altmap *altmap);
 extern void remove_pfn_range_from_zone(struct zone *zone,
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index ad54349a2550..c4d5c45820d0 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -98,11 +98,14 @@ void mem_hotplug_done(void)
 u64 max_mem_size = U64_MAX;
 
 /* add this memory to iomem resource */
-static struct resource *register_memory_resource(u64 start, u64 size)
+static struct resource *register_memory_resource(u64 start, u64 size,
+						 const char *resource_name)
 {
 	struct resource *res;
 	unsigned long flags =  IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
-	char *resource_name = "System RAM";
+
+	if (strcmp(resource_name, "System RAM"))
+		flags |= IORESOURCE_MEM_DRIVER_MANAGED;
 
 	/*
 	 * Make sure value parsed from 'mem=' only restricts memory adding
@@ -1057,7 +1060,8 @@ int __ref add_memory_resource(int nid, struct resource *res)
 	BUG_ON(ret);
 
 	/* create new memmap entry */
-	firmware_map_add_hotplug(start, start + size, "System RAM");
+	if (!strcmp(res->name, "System RAM"))
+		firmware_map_add_hotplug(start, start + size, "System RAM");
 
 	/* device_online() will take the lock when calling online_pages() */
 	mem_hotplug_done();
@@ -1083,7 +1087,7 @@ int __ref __add_memory(int nid, u64 start, u64 size)
 	struct resource *res;
 	int ret;
 
-	res = register_memory_resource(start, size);
+	res = register_memory_resource(start, size, "System RAM");
 	if (IS_ERR(res))
 		return PTR_ERR(res);
 
@@ -1105,6 +1109,56 @@ int add_memory(int nid, u64 start, u64 size)
 }
 EXPORT_SYMBOL_GPL(add_memory);
 
+/*
+ * Add special, driver-managed memory to the system as system RAM. Such
+ * memory is not exposed via the raw firmware-provided memmap as system
+ * RAM, instead, it is detected and added by a driver - during cold boot,
+ * after a reboot, and after kexec.
+ *
+ * Reasons why this memory should not be used for the initial memmap of a
+ * kexec kernel or for placing kexec images:
+ * - The booting kernel is in charge of determining how this memory will be
+ *   used (e.g., use persistent memory as system RAM)
+ * - Coordination with a hypervisor is required before this memory
+ *   can be used (e.g., inaccessible parts).
+ *
+ * For this memory, no entries in /sys/firmware/memmap ("raw firmware-provided
+ * memory map") are created. Also, the created memory resource is flagged
+ * with IORESOURCE_MEM_DRIVER_MANAGED, so in-kernel users can special-case
+ * this memory as well (esp., not place kexec images onto it).
+ *
+ * The resource_name (visible via /proc/iomem) has to have the format
+ * "System RAM ($DRIVER)".
+ */
+int add_memory_driver_managed(int nid, u64 start, u64 size,
+			      const char *resource_name)
+{
+	struct resource *res;
+	int rc;
+
+	if (!resource_name ||
+	    strstr(resource_name, "System RAM (") != resource_name ||
+	    resource_name[strlen(resource_name) - 1] != ')')
+		return -EINVAL;
+
+	lock_device_hotplug();
+
+	res = register_memory_resource(start, size, resource_name);
+	if (IS_ERR(res)) {
+		rc = PTR_ERR(res);
+		goto out_unlock;
+	}
+
+	rc = add_memory_resource(nid, res);
+	if (rc < 0)
+		release_memory_resource(res);
+
+out_unlock:
+	unlock_device_hotplug();
+	return rc;
+}
+EXPORT_SYMBOL_GPL(add_memory_driver_managed);
+
 #ifdef CONFIG_MEMORY_HOTREMOVE
 /*
  * Confirm all pages in a range [start, end) belong to the same zone (skipping
-- 
2.25.3



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

* [PATCH v3 2/3] kexec_file: Don't place kexec images on IORESOURCE_MEM_DRIVER_MANAGED
  2020-05-04 19:02 [PATCH v3 0/3] mm/memory_hotplug: Interface to add driver-managed system ram David Hildenbrand
  2020-05-04 19:02 ` [PATCH v3 1/3] mm/memory_hotplug: Introduce add_memory_device_managed() David Hildenbrand
@ 2020-05-04 19:02 ` David Hildenbrand
  2020-05-04 19:02 ` [PATCH v3 3/3] device-dax: Add memory via add_memory_driver_managed() David Hildenbrand
  2 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2020-05-04 19:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, linux-nvdimm, kexec, Vishal Verma, Dave Jiang,
	Pavel Tatashin, David Hildenbrand, Andrew Morton, Michal Hocko,
	Pankaj Gupta, Wei Yang, Baoquan He, Dave Hansen, Eric Biederman,
	Dan Williams

Memory flagged with IORESOURCE_MEM_DRIVER_MANAGED is special - it won't be
part of the initial memmap of the kexec kernel and not all memory might be
accessible. Don't place any kexec images onto it.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 kernel/kexec_file.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
index faa74d5f6941..bb05fd52de85 100644
--- a/kernel/kexec_file.c
+++ b/kernel/kexec_file.c
@@ -540,6 +540,11 @@ static int locate_mem_hole_callback(struct resource *res, void *arg)
 	unsigned long sz = end - start + 1;
 
 	/* Returning 0 will take to next memory range */
+
+	/* Don't use memory that will be detected and handled by a driver. */
+	if (res->flags & IORESOURCE_MEM_DRIVER_MANAGED)
+		return 0;
+
 	if (sz < kbuf->memsz)
 		return 0;
 
-- 
2.25.3



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

* [PATCH v3 3/3] device-dax: Add memory via add_memory_driver_managed()
  2020-05-04 19:02 [PATCH v3 0/3] mm/memory_hotplug: Interface to add driver-managed system ram David Hildenbrand
  2020-05-04 19:02 ` [PATCH v3 1/3] mm/memory_hotplug: Introduce add_memory_device_managed() David Hildenbrand
  2020-05-04 19:02 ` [PATCH v3 2/3] kexec_file: Don't place kexec images on IORESOURCE_MEM_DRIVER_MANAGED David Hildenbrand
@ 2020-05-04 19:02 ` David Hildenbrand
  2020-05-06 13:55   ` Pankaj Gupta
  2 siblings, 1 reply; 7+ messages in thread
From: David Hildenbrand @ 2020-05-04 19:02 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, linux-nvdimm, kexec, Vishal Verma, Dave Jiang,
	Pavel Tatashin, David Hildenbrand, Andrew Morton, Michal Hocko,
	Pankaj Gupta, Wei Yang, Baoquan He, Dave Hansen, Eric Biederman,
	Dan Williams

Currently, when adding memory, we create entries in /sys/firmware/memmap/
as "System RAM". This will lead to kexec-tools to add that memory to the
fixed-up initial memmap for a kexec kernel (loaded via kexec_load()). The
memory will be considered initial System RAM by the kexec'd kernel and
can no longer be reconfigured. This is not what happens during a real
reboot.

Let's add our memory via add_memory_driver_managed() now, so we won't
create entries in /sys/firmware/memmap/ and indicate the memory as
"System RAM (kmem)" in /proc/iomem. This allows everybody (especially
kexec-tools) to identify that this memory is special and has to be treated
differently than ordinary (hotplugged) System RAM.

Before configuring the namespace:
	[root@localhost ~]# cat /proc/iomem
	...
	140000000-33fffffff : Persistent Memory
	  140000000-33fffffff : namespace0.0
	3280000000-32ffffffff : PCI Bus 0000:00

After configuring the namespace:
	[root@localhost ~]# cat /proc/iomem
	...
	140000000-33fffffff : Persistent Memory
	  140000000-1481fffff : namespace0.0
	  148200000-33fffffff : dax0.0
	3280000000-32ffffffff : PCI Bus 0000:00

After loading kmem before this change:
	[root@localhost ~]# cat /proc/iomem
	...
	140000000-33fffffff : Persistent Memory
	  140000000-1481fffff : namespace0.0
	  150000000-33fffffff : dax0.0
	    150000000-33fffffff : System RAM
	3280000000-32ffffffff : PCI Bus 0000:00

After loading kmem after this change:
	[root@localhost ~]# cat /proc/iomem
	...
	140000000-33fffffff : Persistent Memory
	  140000000-1481fffff : namespace0.0
	  150000000-33fffffff : dax0.0
	    150000000-33fffffff : System RAM (kmem)
	3280000000-32ffffffff : PCI Bus 0000:00

After a proper reboot:
	[root@localhost ~]# cat /proc/iomem
	...
	140000000-33fffffff : Persistent Memory
	  140000000-1481fffff : namespace0.0
	  148200000-33fffffff : dax0.0
	3280000000-32ffffffff : PCI Bus 0000:00

Within the kexec kernel before this change:
	[root@localhost ~]# cat /proc/iomem
	...
	140000000-33fffffff : Persistent Memory
	  140000000-1481fffff : namespace0.0
	  150000000-33fffffff : System RAM
	3280000000-32ffffffff : PCI Bus 0000:00

Within the kexec kernel after this change:
	[root@localhost ~]# cat /proc/iomem
	...
	140000000-33fffffff : Persistent Memory
	  140000000-1481fffff : namespace0.0
	  148200000-33fffffff : dax0.0
	3280000000-32ffffffff : PCI Bus 0000:00

/sys/firmware/memmap/ before this change:
	0000000000000000-000000000009fc00 (System RAM)
	000000000009fc00-00000000000a0000 (Reserved)
	00000000000f0000-0000000000100000 (Reserved)
	0000000000100000-00000000bffdf000 (System RAM)
	00000000bffdf000-00000000c0000000 (Reserved)
	00000000feffc000-00000000ff000000 (Reserved)
	00000000fffc0000-0000000100000000 (Reserved)
	0000000100000000-0000000140000000 (System RAM)
	0000000150000000-0000000340000000 (System RAM)

/sys/firmware/memmap/ after a proper reboot:
	0000000000000000-000000000009fc00 (System RAM)
	000000000009fc00-00000000000a0000 (Reserved)
	00000000000f0000-0000000000100000 (Reserved)
	0000000000100000-00000000bffdf000 (System RAM)
	00000000bffdf000-00000000c0000000 (Reserved)
	00000000feffc000-00000000ff000000 (Reserved)
	00000000fffc0000-0000000100000000 (Reserved)
	0000000100000000-0000000140000000 (System RAM)

/sys/firmware/memmap/ after this change:
	0000000000000000-000000000009fc00 (System RAM)
	000000000009fc00-00000000000a0000 (Reserved)
	00000000000f0000-0000000000100000 (Reserved)
	0000000000100000-00000000bffdf000 (System RAM)
	00000000bffdf000-00000000c0000000 (Reserved)
	00000000feffc000-00000000ff000000 (Reserved)
	00000000fffc0000-0000000100000000 (Reserved)
	0000000100000000-0000000140000000 (System RAM)

kexec-tools already seem to basically ignore any System RAM that's not
on top level when searching for areas to place kexec images - but also
for determining crash areas to dump via kdump. Changing the resource name
won't have an impact.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 drivers/dax/kmem.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
index 3d0a7e702c94..5a645a24e359 100644
--- a/drivers/dax/kmem.c
+++ b/drivers/dax/kmem.c
@@ -65,7 +65,13 @@ int dev_dax_kmem_probe(struct device *dev)
 	new_res->flags = IORESOURCE_SYSTEM_RAM;
 	new_res->name = dev_name(dev);
 
-	rc = add_memory(numa_node, new_res->start, resource_size(new_res));
+	/*
+	 * Ensure that future kexec'd kernels will not treat this as RAM
+	 * automatically.
+	 */
+	rc = add_memory_driver_managed(numa_node, new_res->start,
+				       resource_size(new_res),
+				       "System RAM (kmem)");
 	if (rc) {
 		release_resource(new_res);
 		kfree(new_res);
-- 
2.25.3



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

* Re: [PATCH v3 3/3] device-dax: Add memory via add_memory_driver_managed()
  2020-05-04 19:02 ` [PATCH v3 3/3] device-dax: Add memory via add_memory_driver_managed() David Hildenbrand
@ 2020-05-06 13:55   ` Pankaj Gupta
  0 siblings, 0 replies; 7+ messages in thread
From: Pankaj Gupta @ 2020-05-06 13:55 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: LKML, Linux MM, linux-nvdimm, kexec, Vishal Verma, Dave Jiang,
	Pavel Tatashin, Andrew Morton, Michal Hocko, Wei Yang,
	Baoquan He, Dave Hansen, Eric Biederman, Dan Williams

> Currently, when adding memory, we create entries in /sys/firmware/memmap/
> as "System RAM". This will lead to kexec-tools to add that memory to the
> fixed-up initial memmap for a kexec kernel (loaded via kexec_load()). The
> memory will be considered initial System RAM by the kexec'd kernel and
> can no longer be reconfigured. This is not what happens during a real
> reboot.
>
> Let's add our memory via add_memory_driver_managed() now, so we won't
> create entries in /sys/firmware/memmap/ and indicate the memory as
> "System RAM (kmem)" in /proc/iomem. This allows everybody (especially
> kexec-tools) to identify that this memory is special and has to be treated
> differently than ordinary (hotplugged) System RAM.
>
> Before configuring the namespace:
>         [root@localhost ~]# cat /proc/iomem
>         ...
>         140000000-33fffffff : Persistent Memory
>           140000000-33fffffff : namespace0.0
>         3280000000-32ffffffff : PCI Bus 0000:00
>
> After configuring the namespace:
>         [root@localhost ~]# cat /proc/iomem
>         ...
>         140000000-33fffffff : Persistent Memory
>           140000000-1481fffff : namespace0.0
>           148200000-33fffffff : dax0.0
>         3280000000-32ffffffff : PCI Bus 0000:00
>
> After loading kmem before this change:
>         [root@localhost ~]# cat /proc/iomem
>         ...
>         140000000-33fffffff : Persistent Memory
>           140000000-1481fffff : namespace0.0
>           150000000-33fffffff : dax0.0
>             150000000-33fffffff : System RAM
>         3280000000-32ffffffff : PCI Bus 0000:00
>
> After loading kmem after this change:
>         [root@localhost ~]# cat /proc/iomem
>         ...
>         140000000-33fffffff : Persistent Memory
>           140000000-1481fffff : namespace0.0
>           150000000-33fffffff : dax0.0
>             150000000-33fffffff : System RAM (kmem)
>         3280000000-32ffffffff : PCI Bus 0000:00
>
> After a proper reboot:
>         [root@localhost ~]# cat /proc/iomem
>         ...
>         140000000-33fffffff : Persistent Memory
>           140000000-1481fffff : namespace0.0
>           148200000-33fffffff : dax0.0
>         3280000000-32ffffffff : PCI Bus 0000:00
>
> Within the kexec kernel before this change:
>         [root@localhost ~]# cat /proc/iomem
>         ...
>         140000000-33fffffff : Persistent Memory
>           140000000-1481fffff : namespace0.0
>           150000000-33fffffff : System RAM
>         3280000000-32ffffffff : PCI Bus 0000:00
>
> Within the kexec kernel after this change:
>         [root@localhost ~]# cat /proc/iomem
>         ...
>         140000000-33fffffff : Persistent Memory
>           140000000-1481fffff : namespace0.0
>           148200000-33fffffff : dax0.0
>         3280000000-32ffffffff : PCI Bus 0000:00
>
> /sys/firmware/memmap/ before this change:
>         0000000000000000-000000000009fc00 (System RAM)
>         000000000009fc00-00000000000a0000 (Reserved)
>         00000000000f0000-0000000000100000 (Reserved)
>         0000000000100000-00000000bffdf000 (System RAM)
>         00000000bffdf000-00000000c0000000 (Reserved)
>         00000000feffc000-00000000ff000000 (Reserved)
>         00000000fffc0000-0000000100000000 (Reserved)
>         0000000100000000-0000000140000000 (System RAM)
>         0000000150000000-0000000340000000 (System RAM)
>
> /sys/firmware/memmap/ after a proper reboot:
>         0000000000000000-000000000009fc00 (System RAM)
>         000000000009fc00-00000000000a0000 (Reserved)
>         00000000000f0000-0000000000100000 (Reserved)
>         0000000000100000-00000000bffdf000 (System RAM)
>         00000000bffdf000-00000000c0000000 (Reserved)
>         00000000feffc000-00000000ff000000 (Reserved)
>         00000000fffc0000-0000000100000000 (Reserved)
>         0000000100000000-0000000140000000 (System RAM)
>
> /sys/firmware/memmap/ after this change:
>         0000000000000000-000000000009fc00 (System RAM)
>         000000000009fc00-00000000000a0000 (Reserved)
>         00000000000f0000-0000000000100000 (Reserved)
>         0000000000100000-00000000bffdf000 (System RAM)
>         00000000bffdf000-00000000c0000000 (Reserved)
>         00000000feffc000-00000000ff000000 (Reserved)
>         00000000fffc0000-0000000100000000 (Reserved)
>         0000000100000000-0000000140000000 (System RAM)
>
> kexec-tools already seem to basically ignore any System RAM that's not
> on top level when searching for areas to place kexec images - but also
> for determining crash areas to dump via kdump. Changing the resource name
> won't have an impact.
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
> Cc: Wei Yang <richard.weiyang@gmail.com>
> Cc: Baoquan He <bhe@redhat.com>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Eric Biederman <ebiederm@xmission.com>
> Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  drivers/dax/kmem.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c
> index 3d0a7e702c94..5a645a24e359 100644
> --- a/drivers/dax/kmem.c
> +++ b/drivers/dax/kmem.c
> @@ -65,7 +65,13 @@ int dev_dax_kmem_probe(struct device *dev)
>         new_res->flags = IORESOURCE_SYSTEM_RAM;
>         new_res->name = dev_name(dev);
>
> -       rc = add_memory(numa_node, new_res->start, resource_size(new_res));
> +       /*
> +        * Ensure that future kexec'd kernels will not treat this as RAM
> +        * automatically.
> +        */
> +       rc = add_memory_driver_managed(numa_node, new_res->start,
> +                                      resource_size(new_res),
> +                                      "System RAM (kmem)");
>         if (rc) {
>                 release_resource(new_res);
>                 kfree(new_res);
> --

Acked-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>

> 2.25.3
>


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

* Re: [PATCH v3 1/3] mm/memory_hotplug: Introduce add_memory_device_managed()
  2020-05-04 19:02 ` [PATCH v3 1/3] mm/memory_hotplug: Introduce add_memory_device_managed() David Hildenbrand
@ 2020-05-06 13:57   ` Pankaj Gupta
  2020-05-06 14:19   ` David Hildenbrand
  1 sibling, 0 replies; 7+ messages in thread
From: Pankaj Gupta @ 2020-05-06 13:57 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: LKML, Linux MM, linux-nvdimm, kexec, Vishal Verma, Dave Jiang,
	Pavel Tatashin, Andrew Morton, Michal Hocko, Wei Yang,
	Baoquan He, Dave Hansen, Eric Biederman, Dan Williams

Looks good to me.

Acked-by: Pankaj Gupta <pankaj.gupta.linux@gmail.com>


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

* Re: [PATCH v3 1/3] mm/memory_hotplug: Introduce add_memory_device_managed()
  2020-05-04 19:02 ` [PATCH v3 1/3] mm/memory_hotplug: Introduce add_memory_device_managed() David Hildenbrand
  2020-05-06 13:57   ` Pankaj Gupta
@ 2020-05-06 14:19   ` David Hildenbrand
  1 sibling, 0 replies; 7+ messages in thread
From: David Hildenbrand @ 2020-05-06 14:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, linux-nvdimm, kexec, Vishal Verma, Dave Jiang,
	Pavel Tatashin, Andrew Morton, Michal Hocko, Pankaj Gupta,
	Wei Yang, Baoquan He, Dave Hansen, Eric Biederman, Dan Williams

Typo in $SUBJECT, should be "add_memory_driver_managed" ...

-- 
Thanks,

David / dhildenb



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

end of thread, other threads:[~2020-05-06 14:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-04 19:02 [PATCH v3 0/3] mm/memory_hotplug: Interface to add driver-managed system ram David Hildenbrand
2020-05-04 19:02 ` [PATCH v3 1/3] mm/memory_hotplug: Introduce add_memory_device_managed() David Hildenbrand
2020-05-06 13:57   ` Pankaj Gupta
2020-05-06 14:19   ` David Hildenbrand
2020-05-04 19:02 ` [PATCH v3 2/3] kexec_file: Don't place kexec images on IORESOURCE_MEM_DRIVER_MANAGED David Hildenbrand
2020-05-04 19:02 ` [PATCH v3 3/3] device-dax: Add memory via add_memory_driver_managed() David Hildenbrand
2020-05-06 13:55   ` Pankaj Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).