diff mbox series

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

Message ID 20230810053958.14992-2-yangx.jy@fujitsu.com
State New, archived
Headers show
Series [NDCTL,1/2] daxctl: Don't check param.no_movable when param.no_online is set | expand

Commit Message

Xiao Yang Aug. 10, 2023, 5:39 a.m. UTC
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.

Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
---
 daxctl/device.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Dan Williams Jan. 17, 2024, 12:25 a.m. UTC | #1
Xiao Yang wrote:
> 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.

> 
> Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
> ---
>  daxctl/device.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/daxctl/device.c b/daxctl/device.c
> index ba31eb6..dfa7f79 100644
> --- a/daxctl/device.c
> +++ b/daxctl/device.c
> @@ -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;

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.
diff mbox series

Patch

diff --git a/daxctl/device.c b/daxctl/device.c
index ba31eb6..dfa7f79 100644
--- a/daxctl/device.c
+++ b/daxctl/device.c
@@ -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);
 }