Page MenuHomeFreeBSD

Prevent some parallel swap-ins.
ClosedPublic

Authored by kib on Aug 6 2018, 9:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 9 2024, 10:22 AM
Unknown Object (File)
Feb 9 2024, 10:22 AM
Unknown Object (File)
Feb 9 2024, 10:21 AM
Unknown Object (File)
Dec 22 2023, 9:31 PM
Unknown Object (File)
Nov 14 2023, 12:46 AM
Unknown Object (File)
Nov 10 2023, 2:00 AM
Unknown Object (File)
Nov 8 2023, 1:57 AM
Unknown Object (File)
Nov 6 2023, 5:45 PM
Subscribers

Details

Summary

If faultin() was called outside swapper (from PHOLD()), do not allow swapper to initiate additional swap-ins.

Swapper' initiated swap-ins are serialized because they are synchronous and executed in the context of the thread0. With the added limitation, we only allow parallel swap-ins from PHOLD(), which is up to PHOLD() users to manage, usually they do not need to.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/vm/vm_swapout.c
733 ↗(On Diff #46359)

Why wait until after the loop is completed?

sys/vm/vm_swapout.c
733 ↗(On Diff #46359)

To catch all WKILLED processes.

This revision is now accepted and ready to land.Aug 7 2018, 2:36 PM
This revision now requires review to proceed.Aug 7 2018, 5:36 PM

I was imagining that we would be even more restrictive about swapins. If a swapin was performed in the last interval by another process besides the swapper, the swapper would wait until the next interval. And, the swapper itself would only perform one non-wkilled swapin per interval. Maybe if there is a second eligible process for swapin, we reduce the sleep time. Here is part of what I was thinking

Index: vm/vm_swapout.c
===================================================================
--- vm/vm_swapout.c     (revision 337342)
+++ vm/vm_swapout.c     (working copy)
@@ -661,7 +661,7 @@ faultin(struct proc *p)
  */
 
 static struct proc *
-swapper_selector(void)
+swapper_selector(bool wkilled_only)
 {
        struct proc *p, *res;
        struct thread *td;
@@ -672,7 +672,8 @@ static struct proc *
                return (NULL);
        res = NULL;
        ppri = INT_MIN;
-       min_flag = vm_page_count_min();
+       if (vm_page_count_min())
+               wkilled_only = true;
        FOREACH_PROC_IN_SYSTEM(p) {
                PROC_LOCK(p);
                if (p->p_state == PRS_NEW || (p->p_flag & (P_SWAPPINGOUT |
@@ -690,7 +691,7 @@ static struct proc *
                         */
                        return (p);
                }
-               if (min_flag) {
+               if (wkilled_only) {
                        PROC_UNLOCK(p);
                        continue;
                }
@@ -733,7 +734,7 @@ swapper(void)
 
        for (;;) {
                sx_slock(&allproc_lock);
-               p = swapper_selector();
+               p = swapper_selector(p != NULL);
                sx_sunlock(&allproc_lock);
 
                if (p == NULL) {

Also, I find it odd that we go to the trouble of remembering the rss of the swapped out process, but don't consider that value when selecting a process to swap in, even though the comments suggest that we do. :-) We might use the rss value to determine if we have sufficient memory to bring in more than one process per interval.

Only allow one swap-in from swapper for SWAPIN_INTERVAL of non-wkilled process, and only when there were no other swap-ins.
Centralize the limiting logic into swapper_wkilled_only().

markj added inline comments.
sys/vm/vm_swapout.c
162 ↗(On Diff #46440)

I would s/Current/Pending/.

762 ↗(On Diff #46440)

The initialization doesn't seem to be needed.

This revision is now accepted and ready to land.Aug 10 2018, 4:11 PM
kib marked 2 inline comments as done.

Mark' notes.

This revision now requires review to proceed.Aug 10 2018, 4:51 PM
This revision is now accepted and ready to land.Aug 10 2018, 5:20 PM
This revision was automatically updated to reflect the committed changes.