From Fedora Project Wiki
mNo edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
* 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. | * Boot the system and log in as a regular user. | ||
* So as not to trigger the memory pressure 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> | |||
sudo mkdir /etc/systemd/system/user@.service.d/ | |||
printf "[Service]\nManagedOOMMemoryPressure=auto" | sudo tee /etc/systemd/system/user@.service.d/99-test.conf | |||
sudo systemctl daemon-reload | |||
</pre> | |||
|actions= | |actions= | ||
Line 18: | Line 24: | ||
systemd-run --user -r --unit systoomd_swap_test tail /dev/zero | systemd-run --user -r --unit systoomd_swap_test tail /dev/zero | ||
</pre> | </pre> | ||
* | * Make sure to clean up the override and reset the test unit after verifying the results: | ||
<pre> | <pre> | ||
sudo rm /etc/systemd/system/user@service.d/99-test.conf | |||
sudo systemctl daemon-reload | |||
systemctl --user reset-failed systoomd_swap_test.service | systemctl --user reset-failed systoomd_swap_test.service | ||
</pre> | </pre> |
Revision as of 08:57, 17 March 2021
Description
This test case tests that systemd-oomd kills the largest swap consumer when swap used is greater 90% (or whatever limit was defined by 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).
- Boot the system and log in as a regular user.
- So as not to trigger the memory pressure 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 mkdir /etc/systemd/system/user@.service.d/ printf "[Service]\nManagedOOMMemoryPressure=auto" | sudo tee /etc/systemd/system/user@.service.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 "/" is listed as a path under "Swap Monitored CGroups" along with the current swap usage. - Now run the test:
systemd-run --user -r --unit systoomd_swap_test tail /dev/zero
- Make sure to clean up the override and reset the test unit after verifying the results:
sudo rm /etc/systemd/system/user@service.d/99-test.conf sudo systemctl daemon-reload systemctl --user reset-failed systoomd_swap_test.service
Expected 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 output ofsystemctl --user status systoomd_swap_test
should say the unit is killed (with no mention of oom-kill). - Swap used should be below 90% (use
free -h
)