From 4f8260e700b5765d95a10d02fa5cccd633ac0954 Mon Sep 17 00:00:00 2001 From: kib Date: Sun, 9 Jan 2011 12:50:44 +0000 Subject: [PATCH] Move repeated MAXSLP definition from machine/vmparam.h to sys/vmmeter.h. Update the outdated comments describing MAXSLP and the process selection algorithm for swap out. Comments wording and reviewed by: alc --- bin/ps/print.c | 1 + sys/amd64/include/vmparam.h | 11 ----------- sys/arm/include/vmparam.h | 1 - sys/i386/include/vmparam.h | 12 ------------ sys/ia64/include/vmparam.h | 11 ----------- sys/mips/include/vmparam.h | 11 ----------- sys/powerpc/include/vmparam.h | 11 ----------- sys/sparc64/include/vmparam.h | 11 ----------- sys/sun4v/include/vmparam.h | 11 ----------- sys/sys/vmmeter.h | 6 ++++++ sys/vm/vm_glue.c | 16 +++++++--------- sys/vm/vm_meter.c | 2 -- 12 files changed, 14 insertions(+), 90 deletions(-) diff --git a/bin/ps/print.c b/bin/ps/print.c index cc33cddfd8c..5aa27c0b597 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h index 88d68b9d3ab..38a621485ce 100644 --- a/sys/amd64/include/vmparam.h +++ b/sys/amd64/include/vmparam.h @@ -69,17 +69,6 @@ #define SGROWSIZ (128UL*1024) /* amount to grow stack */ #endif -/* - * The time for a process to be blocked before being very swappable. - * This is a number of seconds which the system takes as being a non-trivial - * amount of real time. You probably shouldn't change this; - * it is used in subtle ways (fractions and multiples of it are, that is, like - * half of a ``long time'', almost a long time, etc.) - * It is related to human patience and other factors which don't really - * change over time. - */ -#define MAXSLP 20 - /* * We provide a machine specific single page allocator through the use * of the direct mapped segment. This uses 2MB pages for reduced diff --git a/sys/arm/include/vmparam.h b/sys/arm/include/vmparam.h index 23b0f864c24..c608daa8423 100644 --- a/sys/arm/include/vmparam.h +++ b/sys/arm/include/vmparam.h @@ -146,7 +146,6 @@ #define DFLSSIZ (2*1024*1024) #define MAXSSIZ (8*1024*1024) #define SGROWSIZ (128*1024) -#define MAXSLP 20 #ifdef ARM_USE_SMALL_ALLOC #define UMA_MD_SMALL_ALLOC diff --git a/sys/i386/include/vmparam.h b/sys/i386/include/vmparam.h index 2b159b64abe..e9448101e01 100644 --- a/sys/i386/include/vmparam.h +++ b/sys/i386/include/vmparam.h @@ -63,18 +63,6 @@ #define SGROWSIZ (128UL*1024) /* amount to grow stack */ #endif -/* - * The time for a process to be blocked before being very swappable. - * This is a number of seconds which the system takes as being a non-trivial - * amount of real time. You probably shouldn't change this; - * it is used in subtle ways (fractions and multiples of it are, that is, like - * half of a ``long time'', almost a long time, etc.) - * It is related to human patience and other factors which don't really - * change over time. - */ -#define MAXSLP 20 - - /* * The physical address space is densely populated. */ diff --git a/sys/ia64/include/vmparam.h b/sys/ia64/include/vmparam.h index a827e01379b..edf5710fcd8 100644 --- a/sys/ia64/include/vmparam.h +++ b/sys/ia64/include/vmparam.h @@ -69,17 +69,6 @@ #define SGROWSIZ (128UL*1024) /* amount to grow stack */ #endif -/* - * The time for a process to be blocked before being very swappable. - * This is a number of seconds which the system takes as being a non-trivial - * amount of real time. You probably shouldn't change this; - * it is used in subtle ways (fractions and multiples of it are, that is, like - * half of a ``long time'', almost a long time, etc.) - * It is related to human patience and other factors which don't really - * change over time. - */ -#define MAXSLP 20 - /* * We need region 7 virtual addresses for pagetables. */ diff --git a/sys/mips/include/vmparam.h b/sys/mips/include/vmparam.h index 212a0c36881..ef01601dd4e 100644 --- a/sys/mips/include/vmparam.h +++ b/sys/mips/include/vmparam.h @@ -69,17 +69,6 @@ #define SGROWSIZ (128UL*1024) /* amount to grow stack */ #endif -/* - * The time for a process to be blocked before being very swappable. - * This is a number of seconds which the system takes as being a non-trivial - * amount of real time. You probably shouldn't change this; - * it is used in subtle ways (fractions and multiples of it are, that is, like - * half of a ``long time'', almost a long time, etc.) - * It is related to human patience and other factors which don't really - * change over time. - */ -#define MAXSLP 20 - /* * Mach derived constants */ diff --git a/sys/powerpc/include/vmparam.h b/sys/powerpc/include/vmparam.h index d98aea52d78..b92ce704342 100644 --- a/sys/powerpc/include/vmparam.h +++ b/sys/powerpc/include/vmparam.h @@ -57,17 +57,6 @@ #define MAXSSIZ (64*1024*1024) /* max stack size */ #endif -/* - * The time for a process to be blocked before being very swappable. - * This is a number of seconds which the system takes as being a non-trivial - * amount of real time. You probably shouldn't change this; - * it is used in subtle ways (fractions and multiples of it are, that is, like - * half of a ``long time'', almost a long time, etc.) - * It is related to human patience and other factors which don't really - * change over time. - */ -#define MAXSLP 20 - /* * Would like to have MAX addresses = 0, but this doesn't (currently) work */ diff --git a/sys/sparc64/include/vmparam.h b/sys/sparc64/include/vmparam.h index 26caab3cada..fc581b36ae9 100644 --- a/sys/sparc64/include/vmparam.h +++ b/sys/sparc64/include/vmparam.h @@ -65,17 +65,6 @@ #define SGROWSIZ (128*1024) /* amount to grow stack */ #endif -/* - * The time for a process to be blocked before being very swappable. - * This is a number of seconds which the system takes as being a non-trivial - * amount of real time. You probably shouldn't change this; - * it is used in subtle ways (fractions and multiples of it are, that is, like - * half of a ``long time'', almost a long time, etc.) - * It is related to human patience and other factors which don't really - * change over time. - */ -#define MAXSLP 20 - /* * The physical address space is sparsely populated. */ diff --git a/sys/sun4v/include/vmparam.h b/sys/sun4v/include/vmparam.h index f4b24b5d2c9..ce016515cfb 100644 --- a/sys/sun4v/include/vmparam.h +++ b/sys/sun4v/include/vmparam.h @@ -65,17 +65,6 @@ #define SGROWSIZ (128*1024) /* amount to grow stack */ #endif -/* - * The time for a process to be blocked before being very swappable. - * This is a number of seconds which the system takes as being a non-trivial - * amount of real time. You probably shouldn't change this; - * it is used in subtle ways (fractions and multiples of it are, that is, like - * half of a ``long time'', almost a long time, etc.) - * It is related to human patience and other factors which don't really - * change over time. - */ -#define MAXSLP 20 - /* * The physical address space is densely populated. */ diff --git a/sys/sys/vmmeter.h b/sys/sys/vmmeter.h index 9d74611a50a..99531a6c84a 100644 --- a/sys/sys/vmmeter.h +++ b/sys/sys/vmmeter.h @@ -33,6 +33,12 @@ #ifndef _SYS_VMMETER_H_ #define _SYS_VMMETER_H_ +/* + * This value is used by ps(1) to change sleep state flag from 'S' to + * 'I' and by the sched process to set the alarm clock. + */ +#define MAXSLP 20 + /* * System wide statistics counters. * Locking: diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index 0b9d92a1df1..69576d54fb3 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -94,8 +94,6 @@ __FBSDID("$FreeBSD$"); #include #include -extern int maxslp; - /* * System initialization * @@ -770,7 +768,7 @@ scheduler(dummy) * Nothing to do, back to sleep. */ if ((p = pp) == NULL) { - tsleep(&proc0, PVM, "sched", maxslp * hz / 2); + tsleep(&proc0, PVM, "sched", MAXSLP * hz / 2); goto loop; } PROC_LOCK(p); @@ -819,12 +817,12 @@ SYSCTL_INT(_vm, OID_AUTO, swap_idle_threshold2, CTLFLAG_RW, &swap_idle_threshold2, 0, "Time before a process will be swapped out"); /* - * Swapout is driven by the pageout daemon. Very simple, we find eligible - * procs and swap out their stacks. We try to always "swap" at least one - * process in case we need the room for a swapin. - * If any procs have been sleeping/stopped for at least maxslp seconds, - * they are swapped. Else, we swap the longest-sleeping or stopped process, - * if any, otherwise the longest-resident process. + * First, if any processes have been sleeping or stopped for at least + * "swap_idle_threshold1" seconds, they are swapped out. If, however, + * no such processes exist, then the longest-sleeping or stopped + * process is swapped out. Finally, and only as a last resort, if + * there are no sleeping or stopped processes, the longest-resident + * process is swapped out. */ void swapout_procs(action) diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c index 269de514926..fb098ead1c0 100644 --- a/sys/vm/vm_meter.c +++ b/sys/vm/vm_meter.c @@ -54,8 +54,6 @@ __FBSDID("$FreeBSD$"); struct vmmeter cnt; -int maxslp = MAXSLP; - SYSCTL_UINT(_vm, VM_V_FREE_MIN, v_free_min, CTLFLAG_RW, &cnt.v_free_min, 0, ""); SYSCTL_UINT(_vm, VM_V_FREE_TARGET, v_free_target, -- 2.45.0