Re: [PATCH v3 4/5] s390/mm: implement MEM_PREPARE_ONLINE/MEM_FINISH_OFFLINE notifiers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27.11.23 09:20, Sumanth Korikkar wrote:
MEM_PREPARE_ONLINE memory notifier makes memory block physical
accessible via sclp assign command. The notifier ensures self-contained
memory maps are accessible and hence enabling the "memmap on memory" on
s390.

MEM_FINISH_OFFLINE memory notifier shifts the memory block to an
inaccessible state via sclp unassign command.

Implementation considerations:
* When MHP_MEMMAP_ON_MEMORY is disabled, the system retains the old
   behavior. This means the memory map is allocated from default memory.
* If MACHINE_HAS_EDAT1 is unavailable, MHP_MEMMAP_ON_MEMORY is
   automatically disabled. This ensures that vmemmap pagetables do not
   consume additional memory from the default memory allocator.
* The MEM_GOING_ONLINE notifier has been modified to perform no
   operation, as MEM_PREPARE_ONLINE already executes the sclp assign
   command.
* The MEM_CANCEL_ONLINE/MEM_OFFLINE notifier now performs no operation, as
   MEM_FINISH_OFFLINE already executes the sclp unassign command.

Reviewed-by: Gerald Schaefer <gerald.schaefer@xxxxxxxxxxxxx>
Signed-off-by: Sumanth Korikkar <sumanthk@xxxxxxxxxxxxx>
---
  drivers/s390/char/sclp_cmd.c | 28 ++++++++++++++++++++++------
  1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/s390/char/sclp_cmd.c b/drivers/s390/char/sclp_cmd.c
index 355e63e44e95..30b829e4c052 100644
--- a/drivers/s390/char/sclp_cmd.c
+++ b/drivers/s390/char/sclp_cmd.c
@@ -18,6 +18,7 @@
  #include <linux/mm.h>
  #include <linux/mmzone.h>
  #include <linux/memory.h>
+#include <linux/memory_hotplug.h>
  #include <linux/module.h>
  #include <asm/ctlreg.h>
  #include <asm/chpid.h>
@@ -26,6 +27,7 @@
  #include <asm/sclp.h>
  #include <asm/numa.h>
  #include <asm/facility.h>
+#include <asm/page-states.h>
#include "sclp.h" @@ -319,6 +321,7 @@ static bool contains_standby_increment(unsigned long start, unsigned long end)
  static int sclp_mem_notifier(struct notifier_block *nb,
  			     unsigned long action, void *data)
  {
+	struct memory_block *memory_block;
  	unsigned long start, size;
  	struct memory_notify *arg;
  	unsigned char id;
@@ -340,18 +343,29 @@ static int sclp_mem_notifier(struct notifier_block *nb,
  		if (contains_standby_increment(start, start + size))
  			rc = -EPERM;
  		break;
-	case MEM_GOING_ONLINE:
+	case MEM_PREPARE_ONLINE:
+		memory_block = find_memory_block(pfn_to_section_nr(arg->start_pfn));
+		if (!memory_block) {
+			rc = -EINVAL;
+			goto out;
+		}
  		rc = sclp_mem_change_state(start, size, 1);
+		if (rc || !memory_block->altmap)
+			goto out;
+		/*
+		 * Set CMMA state to nodat here, since the struct page memory
+		 * at the beginning of the memory block will not go through the
+		 * buddy allocator later.
+		 */
+		__arch_set_page_nodat((void *)__va(start), memory_block->altmap->free);

Looking up the memory block and grabbing the altmap from there is a bit unfortunate.

Why can't we do that when adding the altmap? Will the hypervisor scream at us?

... would we want to communicate any altmap start+size via the memory notifier instead?

--
Cheers,

David / dhildenb





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux