Cgroups v2 is enabled in almalinux 9.1 with kernel 5.14.0-70.22.1.el9_0.x86_64 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
Every value is getting enforced for the user when I test them by running some commands from the user's terminal. But they don't 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 processes of that user no matter how they start? Do I have to add some service file in /etc/systemd/user? Please help.