systemd-oomd and zram-config services: "Swap is currently not detected; memory pressure usage will be degraded"

Bug #1978738 reported by fprietog
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Invalid
Undecided
Unassigned
Jammy
Invalid
Undecided
Unassigned
zram-config (Ubuntu)
Fix Released
Low
Unassigned
Jammy
Triaged
Low
Unassigned

Bug Description

Problem summary:
----------------
I've installed the zram-config package. By default it creates a zram swap device with half the physical memory size of the system. For instance, in an 8GB RAM system:

# swapon
NAME TYPE SIZE USED PRIO
/dev/zram0 partition 3,8G 1M 5

#zramctl
NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle 3,8G 496K 74,9K 376K 4 [SWAP]

The problem is that when systemd-oomd.service is started during boot it doesn't detect that zram swap device because zram-config.service is started later. So when systemd-oomd.service was started the zram device didn't exists yet. This is the message shown during boot:

systemd-oomd[587]: Swap is currently not detected; memory pressure usage will be degraded

If you restart systemd-oomd.service after boot it's correctly started because zram-config.service was previously loaded and zram device exists. So I think it's just a matter of dependencies during boot process; it's necessary to make zram-config.service be started before systemd-oomd.service (or to make systemd-oomd.service be restarted when zram-config.service is started).

Aditional info:
---------------
# lsb_release -rd
Description: Ubuntu 22.04 LTS
Release: 22.04

# apt-cache policy systemd-oomd
systemd-oomd:
  Instalados: 249.11-0ubuntu3.1
  Candidato: 249.11-0ubuntu3.1
  Tabla de versión:
 *** 249.11-0ubuntu3.1 500
        500 http://ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 Packages
        100 /var/lib/dpkg/status
     249.11-0ubuntu3 500
        500 http://ports.ubuntu.com/ubuntu-ports jammy/main arm64 Packages

# apt-cache policy zram-config
zram-config:
  Instalados: 0.7build1
  Candidato: 0.7build1
  Tabla de versión:
 *** 0.7build1 500
        500 http://ports.ubuntu.com/ubuntu-ports jammy/universe arm64 Packages
        100 /var/lib/dpkg/status

Revision history for this message
fprietog (fprietog) wrote :

As a workaround you can include in the "[Service]" section of the file "/etc/systemd/system/multi-user.target.wants/zram-config.service" this line:

ExecStartPost=/usr/bin/systemctl restart systemd-oomd.service

It causes systemd-oomd.service to be restarted after zram-config.service start.

Revision history for this message
Lukas Märdian (slyon) wrote :

Thank you for reporting this. I think this should be fixed inside the zram-config.service.

Would you mind removing your "ExecStartPost=" line from the zram-config.service and test adding a
"Before=systemd-oomd.service" line instead? This should fix the dependency ordering IMO.

Changed in systemd (Ubuntu):
status: New → Invalid
Changed in zram-config (Ubuntu):
status: New → Triaged
importance: Undecided → Low
Revision history for this message
fprietog (fprietog) wrote (last edit ):

Just tested removing my "ExecStartPost=" line from the "[Service]" section and adding "Before=systemd-oomd.service" to the "[Unit]" section. It works as you said; now systemd-oomd starts after zram-config so problem is solved.

Revision history for this message
Lukas Märdian (slyon) wrote :

Thank you for the confirmation! I uploaded a fix into Kinetic: https://launchpad.net/ubuntu/+source/zram-config/0.8

Changed in zram-config (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
fprietog (fprietog) wrote :

Just installed the new 0.8 version (in Jammy) and works as expected. Thank you!

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package zram-config - 0.8

---------------
zram-config (0.8) kinetic; urgency=medium

  * d/zram-config.service: Increase systemd-oomd compatibility (LP: #1978738)
    + Add "Before=systemd-oomd.service" dependency to the service unit, to
      make sd-oomd detect the zram device.

 -- Lukas Märdian <email address hidden> Wed, 22 Jun 2022 14:36:59 +0200

Changed in zram-config (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Mantas Kriaučiūnas (mantas) wrote :

@eugenesan
Is this bug fixed in your version of zram-config - https://git.launchpad.net/~eugenesan/+git/zram-config ?

Revision history for this message
Eugene San (eugenesan) wrote :

@mantas
Thanks for letting me know about the bug/fix.
Looks like my version was not affected due to slightly different systemd config.
Nevertheless, I've added the fix (just in case) and pushed it to lp:~eugenesan/+git/zram-config
PPA was updated as well.

Revision history for this message
Oibaf (oibaf) wrote :

@eugenesan

Is there a plan to merge your update version into the official Ubuntu package?

Revision history for this message
William Wilson (jawn-smith) wrote :

@Oibaf, this bug is fixed in the Ubuntu package in kinetic.

Lukas Märdian (slyon)
Changed in systemd (Ubuntu Jammy):
status: New → Invalid
Changed in zram-config (Ubuntu Jammy):
status: New → Triaged
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers