Jeff
Jeff Cloud Systems Architect
1 min read / TL;DR

SystemD-LoginD High CPU Usage

SystemD-LoginD High CPU Usage

I recently repurposed a Dell Latitude Laptop to run my Plex Server. I wiped the laptop, updated the drivers and installed Ubuntu 20.04 along with the latest Plex software. Shortly thereafter, I noticed that 4K video was stuttering and the CPU usage of the laptop was at 100%.

Running a top command showed systemd-logind using 70-85% CPU and systemd-journal using ~20%.

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
  731 root      20   0   16964   8292   7228 R  78.7   0.1  30:11.28 systemd-logind
  260 root      19  -1  444580 288656 287028 S  18.6   1.8   5:56.19 systemd-journal

Let's check the logs

journalctl -u systemd-logind

And I see a million and 5 of these errors.

  systemd-logind[729]: Suspending...
  systemd-logind[729]: Unit suspend.target is masked, refusing operation.
  systemd-logind[729]: Failed to execute suspend operation: Permission denied

Turns out that I didn't disable sleep and hibernation on my laptop prior to closing the lid and putting it on my rack.

The fix is simple.

First, you should backup your /etc/systemd/logind.conf file.

cp /etc/systemd/logind.conf /etc/systemd/logind.conf.bak
cat <<EOF | tee -a /etc/systemd/logind.conf
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
EOF

Then restart the service

systemctl restart systemd-logind