Cannot change MemoryKSM in systemd units
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
systemd (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Noble |
Fix Released
|
Medium
|
Nick Rosbrook |
Bug Description
[Impact]
Units with MemoryKSM=yes setting will fail to start with an "Invalid argument" error. This makes the setting unusable on Noble.
[Test Plan]
On Noble, start a systemd service with MemoryKSM=yes:
$ systemd-run -u test-memory-
On an affected system, this will fail immediately. Inspecting the journal will show why, e.g.:
$ journalctl -u test-memory-
Oct 17 10:37:20 six (sleep)[1494131]: test-memory-
Oct 17 10:37:20 six systemd[1]: Started test-memory-
Oct 17 10:37:20 six systemd[1]: test-memory-
Oct 17 10:37:20 six systemd[1]: test-memory-
On a patched system, the unit should start/exit normally.
[Where problems could occur]
This patch simply adds missing arguments to the prctl call for PR_SET_
[Other information]
The patch is from upstream: https:/
[Original Description]
In one of my working unit (service), I try to toggle the MemoryKSM boolean setting.
Using any of:
MemoryKSM=yes
MemoryKSM=on
MemoryKSM=true
MemoryKSM=1
Results in:
Sep 19 16:16:56 systemd[1]: Started XXX.service - XXX service.
Sep 19 16:16:56 (e_server)[4487]: XXX.service: Failed to set KSM: Invalid argument
Sep 19 16:16:56 systemd[1]: XXX.service: Main process exited, code=exited, status=245/KSM
Sep 19 16:16:56 systemd[1]: XXX.service: Failed with result 'exit-code'.
The following lines allow the service to start:
MemoryKSM="yes"
MemoryKSM="on"
MemoryKSM="true"
MemoryKSM="1"
but still, MemoryKSM stays off:
# systemctl show XXX.service | grep MemoryKSM
MemoryKSM=no
KSM is activated in my running kernel:
# cat /boot/config-
CONFIG_KSM=y
Using prctl (libc6 2.39-0ubuntu8.3) to toggle KSM inside a running process also works. I can read and set the memory_merge switch.
ProblemType: Bug
DistroRelease: Ubuntu 24.04
Package: systemd 255.4-1ubuntu8.4
ProcVersionSign
Uname: Linux 6.8.0-45-generic x86_64
ApportVersion: 2.28.1-0ubuntu3.1
Architecture: amd64
CasperMD5CheckR
CloudArchitecture: x86_64
CloudBuildName: server
CloudID: openstack
CloudName: openstack
CloudPlatform: openstack
CloudSerial: 20240612
CloudSubPlatform: metadata (http://
Date: Thu Sep 19 16:06:51 2024
Lsusb:
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd QEMU Tablet
Bus 001 Device 003: ID 0627:0001 Adomax Technology Co., Ltd QEMU Tablet
Lsusb-t:
/: Bus 001.Port 001: Dev 001, Class=root_hub, Driver=uhci_hcd/2p, 12M
|__ Port 001: Dev 002, If 0, Class=Human Interface Device, Driver=usbhid, 12M
|__ Port 002: Dev 003, If 0, Class=Human Interface Device, Driver=usbhid, 12M
MachineType: OpenStack Foundation OpenStack Nova
ProcKernelCmdLine: BOOT_IMAGE=
SourcePackage: systemd
UpgradeStatus: No upgrade log present (probably fresh install)
dmi.bios.date: 02/06/2015
dmi.bios.release: 0.0
dmi.bios.vendor: EFI Development Kit II / OVMF
dmi.bios.version: 0.0.0
dmi.chassis.type: 1
dmi.chassis.vendor: QEMU
dmi.chassis.
dmi.modalias: dmi:bvnEFIDevel
dmi.product.family: Virtual Machine
dmi.product.name: OpenStack Nova
dmi.product.
dmi.sys.vendor: OpenStack Foundation
description: | updated |
Changed in systemd (Ubuntu Noble): | |
milestone: | none → ubuntu-24.04.2 |
Thanks for reporting this. I can reproduce as well. It appears this was fixed upstream in https:/ /github. com/systemd/ systemd/ pull/31683.
It should already be fixed in Oraculr, but we will backport this to Noble.