Cgroups v2 is enabled in almalinux 9.1 with 5.14.0-70.22.1.el9_0.x86_64 kernel and systemd 250 (250-12.el9_1.3).
Content of /etc/systemd/system/user-1002.slice.d/override.conf:
[Unit]
Description=User Slice for UID 1002
[Slice]
CPUAccounting=1
MemoryAccounting=1
IOAccounting=1
TasksAccounting=1
CPUQuota=70%
MemoryMax=1G
MemoryHigh=1G
IOReadBandwidthMax=/ 1G
IOWriteBandwidthMax=/ 1G
IOReadIOPSMax=/ 1000
IOWriteIOPSMax=/ 1000
TasksMax=200
[Install]
WantedBy=multi-user.target
Description=User Slice for UID 1002
[Slice]
CPUAccounting=1
MemoryAccounting=1
IOAccounting=1
TasksAccounting=1
CPUQuota=70%
MemoryMax=1G
MemoryHigh=1G
IOReadBandwidthMax=/ 1G
IOWriteBandwidthMax=/ 1G
IOReadIOPSMax=/ 1000
IOWriteIOPSMax=/ 1000
TasksMax=200
[Install]
WantedBy=multi-user.target
I execute systemctl daemon-reload after saving the slice file.
Every value is getting enforced for the user when I test them by running some commands from the user's terminal.
But they dont work after I run the same commands from the root's terminal after doing su to that user.
They also dont work when a user's process is started from a php script using putenv('user_uid');.
How do I make them work for all the user's processes no matter how they start?
Do I have add some service file in /etc/systemd/user? Please help.