From Fedora Project Wiki

(Created page with "{{QA/Test_Case |description=This test case tests that systemd-oomd will kill a cgroup with the most pgscans when memory pressure on user@$UID.service exceeds 10% (or whatever...")
 
No edit summary
Line 3: Line 3:


|setup=
|setup=
# This test case should be performed on either bare-metal or virtual machines.
* This test case should be performed on either bare-metal or virtual machines.
# Check that you are running systemd 248~rc1 or higher with `systemctl --version`.
* Check that you are running systemd 248~rc1 or higher with `systemctl --version`.
# Ensure the systemd-oomd-defaults package is installed (included with Fedora 34).
* Ensure the systemd-oomd-defaults package is installed (included with Fedora 34).
# Boot the system and log in as a regular user.
* You will also need to install `stress-ng`.
# So as not to trigger the swap policy for systemd-oomd, create an override with the following commands (remove this file and `systemctl daemon-reload` to restore the settings):
* Boot the system and log in as a regular user.
* So as not to trigger the swap policy for systemd-oomd, create an override with the following commands (don't forget to remove this file and `systemctl daemon-reload` to restore the settings afterwards):
<pre>
<pre>
sudo printf "[Slice]/nManagedOOMSwap=auto" > /etc/systemd/system/-.slice.d/99-test.conf
sudo printf "[Slice]/nManagedOOMSwap=auto" > /etc/systemd/system/-.slice.d/99-test.conf
Line 14: Line 15:


|actions=
|actions=
# Check that systemd-oomd is running:
* Check that systemd-oomd is running:
<pre>
<pre>
systemctl status systemd-oomd
systemctl status systemd-oomd
</pre>
</pre>
# Check that the systemd-oomd-defaults policy was applied by running `oomctl` and verifying that "/" is listed as a path under "Swap Monitored CGroups" along with the current swap usage.
* Check that the systemd-oomd-defaults policy was applied by running `oomctl` and verifying that "/user.slice/user-$UID.slice/user@$UID.service/" is listed as a path under "Memory Pressure Monitored CGroups" along with some stats. "Swap Monitored CGroups" should show no paths since we put in an override.
# Now run the test:
* Now run the test:
<pre>
<pre>
systemd-run --user tail /dev/zero
systemd-run --user --unit -r systoomd_mempressure_test /usr/bin/stress-ng --brk 1 --stack 1 --bigheap 1 -t 90s
</pre>
* Make sure to clean up the override and reset the test unit when you're done:
<pre>
sudo rm /etc/systemd/system/-.slice.d/
sudo systemctl daemon-reload
systemctl --user reset-failed systoomd_mempressure_test
</pre>
</pre>
|results=
|results=
# systemd-oomd will have killed the unit started above. You can verify by checking for log lines that say something about "swap used <...> is more than 90%" and "systemd-oomd killed <...> process(es)" with `journalctl`.
* The system becomes unresponsive during the test but should respond again once `stress-ng` is killed.
# Swap used should be below 90% (use `free -h`)
* systemd-oomd will have killed systoomd_mempressure_test.service after about 10 seconds. `stress-ng` will timeout after 90 seconds, so if the the command runs to timeout, it means systemd-oomd did not kill it. You can verify by checking for log lines that say something about "Memory pressure for <...> and there was reclaim activity" and "systemd-oomd killed <...> process(es)" with `journalctl`.
}}
}}

Revision as of 11:21, 11 March 2021

Description

This test case tests that systemd-oomd will kill a cgroup with the most pgscans when memory pressure on user@$UID.service exceeds 10% (or whatever was defined in systemd-oomd-defaults).

Setup

  • This test case should be performed on either bare-metal or virtual machines.
  • Check that you are running systemd 248~rc1 or higher with systemctl --version.
  • Ensure the systemd-oomd-defaults package is installed (included with Fedora 34).
  • You will also need to install stress-ng.
  • Boot the system and log in as a regular user.
  • So as not to trigger the swap policy for systemd-oomd, create an override with the following commands (don't forget to remove this file and systemctl daemon-reload to restore the settings afterwards):
sudo printf "[Slice]/nManagedOOMSwap=auto" > /etc/systemd/system/-.slice.d/99-test.conf
sudo systemctl daemon-reload

How to test

  • Check that systemd-oomd is running:
systemctl status systemd-oomd
  • Check that the systemd-oomd-defaults policy was applied by running oomctl and verifying that "/user.slice/user-$UID.slice/user@$UID.service/" is listed as a path under "Memory Pressure Monitored CGroups" along with some stats. "Swap Monitored CGroups" should show no paths since we put in an override.
  • Now run the test:
systemd-run --user --unit -r systoomd_mempressure_test /usr/bin/stress-ng --brk 1 --stack 1 --bigheap 1 -t 90s
  • Make sure to clean up the override and reset the test unit when you're done:
sudo rm /etc/systemd/system/-.slice.d/
sudo systemctl daemon-reload
systemctl --user reset-failed systoomd_mempressure_test

Expected Results

  • The system becomes unresponsive during the test but should respond again once stress-ng is killed.
  • systemd-oomd will have killed systoomd_mempressure_test.service after about 10 seconds. stress-ng will timeout after 90 seconds, so if the the command runs to timeout, it means systemd-oomd did not kill it. You can verify by checking for log lines that say something about "Memory pressure for <...> and there was reclaim activity" and "systemd-oomd killed <...> process(es)" with journalctl.