Skip to contentSkip to conversation

daxctl: Don't check param.no_movable when param.no_online is set

PATCH In review Xiao Yang 2 participants 6 messages Aug 10, 2023 – Jan 17, 2024 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/2 daxctl: Don't check param.no_movable when param.no_online is set

param.no_movable is used to online memory in ZONE_NORMAL but param.no_online is used to not online memory. So it's unnecessary to check param.no_movable when param.no_online is set.

---
 daxctl/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
daxctl/device.c +1 -1
index 360ae8b..ba31eb6 100644
@@ -711,7 +711,7 @@ static int reconfig_mode_system_ram(struct daxctl_dev *dev)
 	const char *devname = daxctl_dev_get_devname(dev);
 	int rc, skip_enable = 0;
 
-	if (param.no_online || !param.no_movable) {
+	if (param.no_online) {
 		if (!param.force && daxctl_dev_will_auto_online_memory(dev)) {
 			fprintf(stderr,
 				"%s: error: kernel policy will auto-online memory, aborting\n",
Signature · 1 line
2.40.1
author
#1 lore raw

PATCH 2/2 daxctl: Force to offline memory by param.force

Try to make daxctl reconfigure-device with system-ram mode offline memory when both param.no_online and param.force are set but daxctl_dev_will_auto_online_memory returns true.

---
 daxctl/device.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
daxctl/device.c +7 -2
index ba31eb6..dfa7f79 100644
@@ -83,7 +83,7 @@ OPT_STRING('m', "mode", &param.mode, "mode", "mode to switch the device to"), \
 OPT_BOOLEAN('N', "no-online", &param.no_online, \
 	"don't auto-online memory sections"), \
 OPT_BOOLEAN('f', "force", &param.force, \
-		"attempt to offline memory sections before reconfiguration"), \
+		"attempt to offline memory sections for reconfiguration"), \
 OPT_BOOLEAN('C', "check-config", &param.check_config, \
 		"use config files to determine parameters for the operation")
 
@@ -734,8 +734,13 @@ static int reconfig_mode_system_ram(struct daxctl_dev *dev)
 			return rc;
 	}
 
-	if (param.no_online)
+	if (param.no_online) {
+		if (param.force && daxctl_dev_will_auto_online_memory(dev)) {
+			rc = dev_offline_memory(dev);
+			return rc;
+		}
 		return 0;
+	}
 
 	return dev_online_memory(dev);
 }
Signature · 1 line
2.40.1
#2 lore raw

RE: [NDCTL PATCH 2/2] daxctl: Force to offline memory by param.force

Quoted 3 lines · Xiao Yang

Try to make daxctl reconfigure-device with system-ram mode offline memory when both param.no_online and param.force are set but daxctl_dev_will_auto_online_memory returns true.

So is the goal here to try to save some steps in the case where the kernel already onlined the device?

It should probably emit a warning that the memory was onlined automatically so the admin can consider changing the default kernel policy. Otherwise, it may be too late to undo the onlining at this point.

Quoted 20 lines
---
 daxctl/device.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
daxctl/device.c +1 -1
index ba31eb6..dfa7f79 100644
@@ -83,7 +83,7 @@ OPT_STRING('m', "mode", &param.mode, "mode", "mode to switch the device to"), \
 OPT_BOOLEAN('N', "no-online", &param.no_online, \
 	"don't auto-online memory sections"), \
 OPT_BOOLEAN('f', "force", &param.force, \
-		"attempt to offline memory sections before reconfiguration"), \
+		"attempt to offline memory sections for reconfiguration"), \
 OPT_BOOLEAN('C', "check-config", &param.check_config, \
 		"use config files to determine parameters for the operation")
 

daxctl/device.c static int reconfig_mode_system_ram(struct daxctl_dev *dev) · line 740

Quoted 8 lines
daxctl/device.c +4 -1
@@ -734,8 +734,13 @@ static int reconfig_mode_system_ram(struct daxctl_dev *dev)
 			return rc;
 	}
 
-	if (param.no_online)
+	if (param.no_online) {
+		if (param.force && daxctl_dev_will_auto_online_memory(dev)) {
+			rc = dev_offline_memory(dev);
+			return rc;

It is not clear that this is an error that should fail the reconfigure-device, because the reconfiguration succeeded. The fact that the kernel policy forced the memory online is the administrators fault for setting conflicting policy. This is why I think a warning is appropriate because the administrator is confused if they are letting kernel an daxctl policy conflict.

#3 lore raw
In reply to Xiao Yang

Ping

-----Original Message-----
From: Xiao Yang <[email protected]>
Sent: 2023年8月10日 13:40
To: [email protected]; [email protected]
Cc: [email protected]; Yang, Xiao/杨 晓 <[email protected]>
Subject: [NDCTL PATCH 1/2] daxctl: Don't check param.no_movable when param.no_online is set

param.no_movable is used to online memory in ZONE_NORMAL but param.no_online is used to not online memory. So it's unnecessary to check param.no_movable when param.no_online is set.

---
 daxctl/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
daxctl/device.c +1 -1
@@ -711,7 +711,7 @@ static int reconfig_mode_system_ram(struct daxctl_dev *dev)
 	const char *devname = daxctl_dev_get_devname(dev);
 	int rc, skip_enable = 0;
 
-	if (param.no_online || !param.no_movable) {
+	if (param.no_online) {
 		if (!param.force && daxctl_dev_will_auto_online_memory(dev)) {
 			fprintf(stderr,
 				"%s: error: kernel policy will auto-online memory, aborting\n",

--
2.40.1

author
#4 lore raw

Hi All,

Ping, is there any feedback on this patchset?

Best Regards,
Xiao Yang

Quoted 31 lines · Xiao/杨 晓

Ping

-----Original Message-----
From: Xiao Yang <[email protected]>
Sent: 2023年8月10日 13:40
To: [email protected]; [email protected]
Cc: [email protected]; Yang, Xiao/杨 晓 <[email protected]>
Subject: [NDCTL PATCH 1/2] daxctl: Don't check param.no_movable when param.no_online is set

param.no_movable is used to online memory in ZONE_NORMAL but param.no_online is used to not online memory. So it's unnecessary to check param.no_movable when param.no_online is set.

---
  daxctl/device.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
daxctl/device.c +1 -2
@@ -711,7 +711,7 @@ static int reconfig_mode_system_ram(struct daxctl_dev *dev)
  	const char *devname = daxctl_dev_get_devname(dev);
  	int rc, skip_enable = 0;
 
-	if (param.no_online || !param.no_movable) {
+	if (param.no_online) {
  		if (!param.force && daxctl_dev_will_auto_online_memory(dev)) {
  			fprintf(stderr,
  				"%s: error: kernel policy will auto-online memory, aborting\n",
--

2.40.1

#5 lore raw
In reply to Xiao Yang

Hey, apologies for the delay here, and appreciate the pings.

Quoted 14 lines · Xiao Yang

param.no_movable is used to online memory in ZONE_NORMAL but param.no_online is used to not online memory. So it's unnecessary to check param.no_movable when param.no_online is set.

---
 daxctl/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
daxctl/device.c +0 -0
index 360ae8b..ba31eb6 100644

daxctl/device.c static int reconfig_mode_system_ram(struct daxctl_dev *dev) · line 714

Quoted 5 lines
daxctl/device.c +1 -1
@@ -711,7 +711,7 @@ static int reconfig_mode_system_ram(struct daxctl_dev *dev)
 	const char *devname = daxctl_dev_get_devname(dev);
 	int rc, skip_enable = 0;
 
-	if (param.no_online || !param.no_movable) {
+	if (param.no_online) {

I agree that if daxctl is not going to online the memory then it does not matter what no_movable is set to. However, part of what is happening here is to communicate when daxctl options collide with kernel policy.

I.e. consider the case where no_movable is set and the kernel policy is set to online_movable, then daxctl should communicate:

"error: kernel policy will auto-online memory, aborting"

Maybe the fix here is to split the no-online vs "online or online_movable" kernel policy, and the no-movable vs "online_movable" kernel policy.