<div dir="ltr">Thanks Mantas for replying. <div><br></div><div>I have made the below changes. <div><font face="arial, sans-serif"><font color="#242729"><span style="white-space:pre-wrap"><br></span></font></font></div><div><font face="arial, sans-serif"><font color="#242729"><span style="white-space:pre-wrap">Added </span></font></font><font face="monospace">systemd.unified_cgroup_hierarchy=1</font> in <font face="monospace">/etc/default/grub</font> ran <font face="monospace">sudo update-grub</font> and rebooted the node. </div><div><br></div><div><font face="monospace">GRUB_CMDLINE_LINUX="audit=1 rootdelay=180 nousb net.ifnames=0 biosdevname=0 fsck.mode=force fsck.repair=yes ipv6.disable=1 systemd.unified_cgroup_hierarchy=1"</font><br></div><div><br></div><div>Even after making these changes <span style="color:rgb(36,39,41);font-family:monospace;font-size:13px;white-space:pre-wrap">MemorySwapMax </span><span style="color:rgb(36,39,41);font-size:13px;white-space:pre-wrap"><font face="arial, sans-serif">not taking into effect. </font></span></div><div><br></div><div><pre class="gmail-c-mrkdwn__pre" style="box-sizing:inherit;margin-top:4px;margin-bottom:4px;padding:8px;font-size:12px;line-height:1.50001;font-variant-ligatures:none;white-space:pre-wrap;word-break:normal;border-radius:4px;color:rgb(29,28,29);font-family:Monaco,Menlo,Consolas,"Courier New",monospace">support@vrni-platform:~$ cat /proc/cmdline<br style="box-sizing:inherit">BOOT_IMAGE=/vmlinuz-4.15.0-143-generic root=/dev/mapper/vg-root ro audit=1 rootdelay=180 nousb net.ifnames=0 biosdevname=0 fsck.mode=force fsck.repair=yes ipv6.disable=1 systemd.unified_cgroup_hierarchy=1 audit=1</pre><pre class="gmail-c-mrkdwn__pre" style="box-sizing:inherit;margin-top:4px;margin-bottom:4px;padding:8px;font-size:12px;line-height:1.50001;font-variant-ligatures:none;white-space:pre-wrap;word-break:normal;border-radius:4px;color:rgb(29,28,29);font-family:Monaco,Menlo,Consolas,"Courier New",monospace"><pre class="gmail-c-mrkdwn__pre" style="box-sizing:inherit;margin-top:4px;margin-bottom:4px;padding:8px;line-height:1.50001;white-space:pre-wrap;word-break:normal;border-radius:4px;font-family:Monaco,Menlo,Consolas,"Courier New",monospace">support@vrni-platform:~$ findmnt<br style="box-sizing:inherit">TARGET                       SOURCE                       FSTYPE     OPTIONS<br style="box-sizing:inherit">/                            /dev/mapper/vg-root          ext4       rw,relatime,errors=panic,data=ordered<br style="box-sizing:inherit">├─/sys                       sysfs                        sysfs      rw,nosuid,nodev,noexec,relatime<br style="box-sizing:inherit">│ ├─/sys/kernel/security     securityfs                   securityfs rw,nosuid,nodev,noexec,relatime<br style="box-sizing:inherit">│ ├─/sys/fs/cgroup           cgroup                       cgroup2    rw,nosuid,nodev,noexec,relatime,nsdelegate<br style="box-sizing:inherit">│ ├─/sys/fs/pstore           pstore                       pstore     rw,nosuid,nodev,noexec,relatime<br style="box-sizing:inherit">│ ├─/sys/kernel/config       configfs                     configfs   rw,relatime<br style="box-sizing:inherit">│ ├─/sys/fs/fuse/connections fusectl                      fusectl    rw,relatime<br style="box-sizing:inherit">│ └─/sys/kernel/debug        debugfs                      debugfs    rw,relatime<br style="box-sizing:inherit">├─/proc                      proc                         proc       rw,nosuid,nodev,noexec,relatime<br style="box-sizing:inherit">│ └─/proc/sys/fs/binfmt_misc systemd-1                    autofs     rw,relatime,fd=28,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=1935<br style="box-sizing:inherit">├─/dev                       udev                         devtmpfs   rw,nosuid,relatime,size=8182012k,nr_inodes=2045503,mode=755<br style="box-sizing:inherit">│ ├─/dev/pts                 devpts                       devpts     rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000<br style="box-sizing:inherit">│ ├─/dev/shm                 tmpfs                        tmpfs      rw,nosuid,nodev,noexec<br style="box-sizing:inherit">│ ├─/dev/hugepages           hugetlbfs                    hugetlbfs  rw,relatime,pagesize=2M<br style="box-sizing:inherit">│ └─/dev/mqueue              mqueue                       mqueue     rw,relatime<br style="box-sizing:inherit">├─/run                       tmpfs                        tmpfs      rw,nosuid,noexec,relatime,size=1642560k,mode=755<br style="box-sizing:inherit">│ ├─/run/lock                tmpfs                        tmpfs      rw,nosuid,nodev,noexec,relatime,size=5120k<br style="box-sizing:inherit">│ ├─/run/rpc_pipefs          sunrpc                       rpc_pipefs rw,relatime<br style="box-sizing:inherit">│ ├─/run/shm                 none                         tmpfs      rw,nosuid,nodev,noexec,relatime<br style="box-sizing:inherit">│ ├─/run/user/116            tmpfs                        tmpfs      rw,nosuid,nodev,relatime,size=1642556k,mode=700,uid=116,gid=122<br style="box-sizing:inherit">│ ├─/run/user/998            tmpfs                        tmpfs      rw,nosuid,nodev,relatime,size=1642556k,mode=700,uid=998,gid=998<br style="box-sizing:inherit">│ ├─/run/user/118            tmpfs                        tmpfs      rw,nosuid,nodev,relatime,size=1642556k,mode=700,uid=118,gid=124<br style="box-sizing:inherit">│ ├─/run/user/1001           tmpfs                        tmpfs      rw,nosuid,nodev,relatime,size=1642556k,mode=700,uid=1001,gid=1001<br style="box-sizing:inherit">│ └─/run/user/121            tmpfs                        tmpfs      rw,nosuid,nodev,relatime,size=1642556k,mode=700,uid=121,gid=127<br style="box-sizing:inherit">├─/boot                      /dev/sda1                    ext4       rw,relatime,data=ordered<br style="box-sizing:inherit">├─/tmp                       /dev/mapper/vg-tmp           ext4       rw,nosuid,nodev,relatime,data=ordered<br style="box-sizing:inherit">├─/home                      /dev/mapper/vg-home          ext4       rw,nodev,relatime,data=ordered<br style="box-sizing:inherit">└─/var                       /dev/mapper/vg-var           ext4       rw,relatime,errors=panic,data=ordered<br style="box-sizing:inherit">  ├─/var/log                 /dev/mapper/vg-var+log       ext4       rw,relatime,data=ordered<br style="box-sizing:inherit">  │ └─/var/log/audit         /dev/mapper/vg-var+log+audit ext4       rw,relatime,data=ordered<br style="box-sizing:inherit">  └─/var/tmp                 /dev/mapper/vg-tmp           ext4       rw,nosuid,nodev,relatime,data=ordered<br style="box-sizing:inherit">support@vrni-platform:~$</pre></pre></div><div>Any other suggestions?</div></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 5, 2021 at 1:46 AM Mantas Mikulėnas <<a href="mailto:grawity@gmail.com">grawity@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Looks like your Ubuntu version is using the "hybrid" cgroup mode by default. Cgroup v2 is indeed *enabled* in your kernel, but not necessarily *in use* – in the hybrid mode, systemd still mounts all resource controllers (cpu, memory, etc.) in v1 mode and only sets up its own process tracking in the v2 tree. See `findmnt`.</div><div><br></div><div>You could boot with the systemd.unified_cgroup_hierarchy=1 kernel option to switch everything to cgroups v2, but if you're using container software (docker, podman) make sure those are cgroups v2-compatible.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jul 4, 2021 at 10:36 AM Debraj Manna <<a href="mailto:subharaj.manna@gmail.com" target="_blank">subharaj.manna@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi<div><br></div><div><span style="color:rgb(36,39,41);font-family:-apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif;font-size:15px">I am trying to restrict the swap usage of a process using </span><code style="margin:0px;padding:2px 4px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit;white-space:pre-wrap;color:rgb(36,39,41);border-radius:3px">MemorySwapMax</code><span style="color:rgb(36,39,41);font-family:-apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif;font-size:15px"> as mentioned in the </span><a href="http://manpages.ubuntu.com/manpages/bionic/man5/systemd.resource-control.5.html" rel="nofollow noreferrer" style="margin:0px;padding:0px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:-apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif;font-size:15px;vertical-align:baseline;box-sizing:inherit" target="_blank">doc</a><span style="color:rgb(36,39,41);font-family:-apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif;font-size:15px"> with Ubuntu 18.04.</span><br></div><div><span style="color:rgb(36,39,41);font-family:-apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif;font-size:15px"><br></span></div><div><span style="color:rgb(36,39,41);font-family:-apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif;font-size:15px">Environment</span><span style="color:rgb(36,39,41);font-family:-apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif;font-size:15px"><br></span></div><div><span style="color:rgb(36,39,41);font-family:-apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif;font-size:15px">------------</span></div><div><span style="color:rgb(36,39,41);font-family:-apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif;font-size:15px"><br></span></div><div><pre style="margin-top:0px;padding:12px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><code style="margin:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit;border-radius:0px">ubuntu@vrni-platform:/usr/lib/systemd/system$ uname -a
Linux vrni-platform 4.15.0-143-generic #147-Ubuntu SMP Wed Apr 14 16:10:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

ubuntu@vrni-platform:/usr/lib/systemd/system$ systemctl --version
systemd 237
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid</code></pre><pre style="margin-top:0px;padding:12px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><span style="color:rgb(36,39,41);font-family:-apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif;font-size:15px;white-space:normal">My systemd unit file looks like below</span><br></pre><pre style="margin-top:0px;padding:12px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><pre style="font-size:13px;margin-top:0px;padding:12px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><code style="margin:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit;border-radius:0px">[Unit]
Description=My service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=support
MemoryMax=2000M
KillMode=process
MemoryAccounting=true
OOMScoreAdjust=1000
MemorySwapMax=1M
ExecStart=/usr/bin/java -cp /home/support -XX:NativeMemoryTracking=summary -Xmx10000m MemoryConsumer 100 200 1</code></pre><pre style="margin-top:0px;padding:12px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px">MemoryMax<font face="arial, sans-serif"> is working as expected but </font>MemorySwapMax<font face="arial, sans-serif"> seems to be not taking effect and I am seeing the process, </font>MemoryConsumer<font face="arial, sans-serif"> still using swap more than the one specified in </font>MemorySwapMax, </pre><pre style="font-size:13px;margin-top:0px;padding:12px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px">MemorySwapMax d<font face="arial, sans-serif">ocumentation states</font> "This setting is supported only if the unified control group hierarchy is used and disables MemoryLimit=."</pre><pre style="margin-top:0px;padding:12px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><font face="arial, sans-serif">As mentioned <a href="https://unix.stackexchange.com/a/471495/364181" target="_blank">here</a> I can see cgroup v2 enabled on my setup.</font></pre><pre style="font-size:13px;margin-top:0px;padding:12px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><pre style="margin-top:0px;padding:12px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><code style="margin:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit;border-radius:0px">ubuntu@vrni-platform:/tmp/tuk$ sudo mount -t cgroup2 none /tmp/tuk
ubuntu@vrni-platform:/tmp/tuk$ ls -l /tmp/tuk/
total 0
-r--r--r--  1 root root 0 Jul  2 17:13 cgroup.controllers
-rw-r--r--  1 root root 0 Jul  2 17:13 cgroup.max.depth
-rw-r--r--  1 root root 0 Jul  2 17:13 cgroup.max.descendants
-rw-r--r--  1 root root 0 Jun 30 14:42 cgroup.procs
-r--r--r--  1 root root 0 Jul  2 17:13 cgroup.stat
-rw-r--r--  1 root root 0 Jul  2 17:13 cgroup.subtree_control
-rw-r--r--  1 root root 0 Jul  2 17:13 cgroup.threads
drwxr-xr-x  2 root root 0 Jun 30 14:42 init.scope
drwxr-xr-x 87 root root 0 Jul  2 15:05 system.slice
drwxr-xr-x  7 root root 0 Jun 30 15:22 user.slice
ubuntu@vrni-platform:/tmp/debraj$ sudo umount /tmp/tuk</code></pre><pre style="margin-top:0px;padding:12px;border:0px none;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:1.30769;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:5px"><code style="margin:0px;padding:0px;border:0px none;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit;border-radius:0px"><font face="arial, sans-serif">Can someone suggest what configuration I am missing?</font></code></pre></pre></pre></div><div><span style="color:rgb(36,39,41);font-family:-apple-system,system-ui,"Segoe UI","Liberation Sans",sans-serif;font-size:15px"><br></span></div></div>
_______________________________________________<br>
systemd-devel mailing list<br>
<a href="mailto:systemd-devel@lists.freedesktop.org" target="_blank">systemd-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/systemd-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/systemd-devel</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr"><div dir="ltr">Mantas Mikulėnas</div></div>
</blockquote></div>