Page MenuHomeFreeBSD

Remove/Limit whole process swapout
AcceptedPublic

Authored by cneirabustos_gmail.com on Jan 4 2018, 3:04 AM.
Referenced Files
Unknown Object (File)
Feb 15 2024, 1:14 PM
Unknown Object (File)
Feb 9 2024, 5:06 PM
Unknown Object (File)
Feb 2 2024, 5:05 AM
Unknown Object (File)
Dec 20 2023, 5:23 AM
Unknown Object (File)
Dec 16 2023, 2:51 AM
Unknown Object (File)
Dec 13 2023, 4:14 PM
Unknown Object (File)
Nov 23 2023, 11:57 PM
Unknown Object (File)
Nov 23 2023, 9:17 PM

Details

Reviewers
cneirabustos_gmail.com
bcr
Group Reviewers
manpages
Summary

From Brendan Gregg Scale x12 talk.
"Long before Unix supported paging, it used process swapping. While this was ok with the PDP-11/20's 64kB address spaces, it does not work as well today when address spaces can easily be hundreds of GB."
(https://www.illumos.org/issues/6583).

This patch disables the whole process swapping or limits it, by a system configurable setting

vm.proc_swapout_max

This new VM tunable allows limiting the swap out of whole processes, to only processes which resident size (in bytes) are equal or less than value (default value is 64KB)

Test Plan

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

rpokala added inline comments.
vm_glue.c
995 ↗(On Diff #37493)

I think this would read slightly better like this:

"If the pageout daemon didn't free enough pages, or if this process is idle, the system is configured to swap proactively, and the process resident count is less than vm.proc_swapout_max, swap it out."

1009 ↗(On Diff #37493)

This change in indentation seems gratuitous, and also incorrect.

cneirabustos_gmail.com marked 2 inline comments as done.

updated comment as requested.
indentation fixed

This revision is now accepted and ready to land.Jan 4 2018, 1:14 PM

Fixed indentation and typo on comment.

This revision now requires review to proceed.Jan 4 2018, 1:20 PM

For a long time, "swapping out" a process has only made its U area (later, only the kernel stack) pageable. This is a few pages per thread. Therefore, comparing vmspace_resident_count does not seem to make much sense.

For a long time, "swapping out" a process has only made its U area (later, only the kernel stack) pageable. This is a few pages per thread. Therefore, comparing vmspace_resident_count does not seem to make much sense.

Thanks for your feedback. I understand your point that the number of pages being swapped out is not the same for the process RSS.
But I have chosen RSS as users could easily get that metric with TOP(1) and then adjust vm.proc_swapout_max based on their observations.
Do you have another approach to improve/correct this?

It is already possible to disable swapping out kernel stacks via sysctl vm.swap_enabled (which has a wrong description) and configure it via sysctls vm.swap_idle_threshold1 and vm.swap_idle_threshold2. What is the problem you are trying to solve?

Note that a second effect of swapping out is that ps will not attempt to read arguments and environment from the memory of a "swapped out" process. This will make it more likely that the memory containing these will stay paged out.

If your problem is with paging in general, the "laundry" changes to the VM system in FreeBSD 12 may be useful for you. Basically, these changes allow the system to balance better between paging out things (known as "laundering"; usually to swap but could be to files or devices) and discarding cached data (usually from files).

It is already possible to disable swapping out kernel stacks via sysctl vm.swap_enabled (which has a wrong description) and configure it via sysctls vm.swap_idle_threshold1 and vm.swap_idle_threshold2. What is the problem you are trying to solve?

Note that a second effect of swapping out is that ps will not attempt to read arguments and environment from the memory of a "swapped out" process. This will make it more likely that the memory containing these will stay paged out.

If your problem is with paging in general, the "laundry" changes to the VM system in FreeBSD 12 may be useful for you. Basically, these changes allow the system to balance better between paging out things (known as "laundering"; usually to swap but could be to files or devices) and discarding cached data (usually from files).

Thanks a lot, Jilles. I was trying to disable/limiting the swapping out of processes but as you state the vm.swap_enabled and friends already does that, except that they don't filter by RSS. But that enough for me. I think my patch then is just redudant. I'll work on something else.
Thanks again for your help

bcr added a subscriber: bcr.

Is this still open? I'm not sure manpages needs to approve much here. I'm OK with the change from the doc (comment) side.

This revision is now accepted and ready to land.Dec 20 2018, 8:17 PM
In D13759#397131, @bcr wrote:

Is this still open? I'm not sure manpages needs to approve much here. I'm OK with the change from the doc (comment) side.

Hi,

Yes, this is still open. I don't know if this feature is needed or wanted at this point I think most users just disable swap ?, if not this could be handy to filter which processes go to swap.