diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 9bcc460e8bfe..95695483a622 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -42,7 +42,31 @@
#include "internal.h"
#include "shuffle.h"
-static bool memmap_on_memory_enabled;
+/*
+ * memory_hotplug.memmap_on_memory parameter
+ */
+static bool memmap_on_memory_enabled __ro_after_init;
+
+static int memmap_on_memory_show(char *buffer, const struct kernel_param *kp)
+{
+ return sprintf(buffer, "%s\n",
+ memmap_on_memory_enabled ? "on" : "off");
+}
+
+static __meminit int memmap_on_memory_store(const char *val,
+ const struct kernel_param *kp)
+{
+ /*
+ * Fail silently in case we cannot enable it due to platform constraints.
+ * User can always check whether it is enabled or not via /sys/module.
+ */
+ if (!IS_ENABLED(CONFIG_ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE))
+ return 0;
+
+ return param_set_bool(val, kp);
+}
+module_param_call(memmap_on_memory, memmap_on_memory_store,
+ memmap_on_memory_show, &memmap_on_memory_enabled, 0400);
Why are other users not allowed to read?
Might want to add a MODULE_PARM_DESC().
As we fail silently already, I'd keep it simple and use a
module_param(memmap_on_memory, bool, 0444);
moving the IS_ENABLED(CONFIG_ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE) into the
runtime check.
Apart from that LGTM.
--
Thanks,
David / dhildenb