a9339c
From c50b7bcbebcfebfce3a7e7fb77f88f4b590fb2b5 Mon Sep 17 00:00:00 2001
a9339c
From: Michal Sekletar <msekleta@redhat.com>
a9339c
Date: Thu, 16 Aug 2018 09:31:51 +0000
a9339c
Subject: [PATCH] rules: implement new memory hotplug policy
a9339c
a9339c
Our new policy is based on following motivations (assumptions),
a9339c
  * we want to allow the system to use hotplugged memory
a9339c
  * we want memory ballon inflation to work as expected in VMs (going for small
a9339c
  to big in terms of memory footprint)
a9339c
  * we want to allow memory hotplug and memory hot-unplug on high-end
a9339c
  enterprise server (we assume that node0 will have sufficient memory
a9339c
  resources and marking all memory as movable shouldn't be a problem)
a9339c
a9339c
Policy:
a9339c
  * nevert online memory on s390 (on both physical and z/VM)
a9339c
  * mark memory as "online_movable" on physical machines
a9339c
  * mark memory as "online" in VMs
a9339c
a9339c
If you have the feeling that all this is very wrong and we shouldn't
a9339c
encode complex policies in udev rules you are absolutely right. However,
a9339c
for now, we don't have any better place where to put it. In ideal world
a9339c
we would have a user-space daemon that would be able to configure the
a9339c
system wrt. to currently present HW and user-defined policy.
a9339c
a9339c
Resolves: #1614686
a9339c
---
a9339c
 rules/40-redhat.rules | 9 ++++++++-
a9339c
 1 file changed, 8 insertions(+), 1 deletion(-)
a9339c
a9339c
diff --git a/rules/40-redhat.rules b/rules/40-redhat.rules
a9339c
index 34a1df9c4..1b10e173d 100644
a9339c
--- a/rules/40-redhat.rules
a9339c
+++ b/rules/40-redhat.rules
a9339c
@@ -4,7 +4,14 @@
a9339c
 SUBSYSTEM=="cpu", ACTION=="add", TEST=="online", ATTR{online}=="0", ATTR{online}="1"
a9339c
 
a9339c
 # Memory hotadd request
a9339c
-SUBSYSTEM=="memory", ACTION=="add", PROGRAM="/bin/uname -p", RESULT!="s390*", ATTR{state}=="offline", ATTR{state}="online"
a9339c
+SUBSYSTEM!="memory", ACTION!="add", GOTO="memory_hotplug_end"
a9339c
+PROGRAM="/bin/uname -p", RESULT=="s390*", GOTO="memory_hotplug_end"
a9339c
+
a9339c
+ENV{.state}="online"
a9339c
+PROGRAM="/bin/systemd-detect-virt", RESULT=="none", ENV{.state}="online_movable"
a9339c
+ATTR{state}=="offline", ATTR{state}="$env{.state}"
a9339c
+
a9339c
+LABEL="memory_hotplug_end"
a9339c
 
a9339c
 # reload sysctl.conf / sysctl.conf.d settings when the bridge module is loaded
a9339c
 ACTION=="add", SUBSYSTEM=="module", KERNEL=="bridge", RUN+="/usr/lib/systemd/systemd-sysctl --prefix=/proc/sys/net/bridge"