make length of inactive queue tunable by sysctl. (vm.inactivepct)

This commit is contained in:
yamt 2005-12-21 12:19:04 +00:00
parent fcae6339ea
commit 4fce5d6f5e
4 changed files with 69 additions and 11 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_extern.h,v 1.107 2005/11/29 22:52:03 yamt Exp $ */
/* $NetBSD: uvm_extern.h,v 1.108 2005/12/21 12:19:04 yamt Exp $ */
/*
*
@ -247,6 +247,19 @@ struct vm_map;
struct vm_page;
struct vmtotal;
/*
* uvm_pctparam: parameter to be shown as percentage to user.
*/
#define UVM_PCTPARAM_SHIFT 8
#define UVM_PCTPARAM_SCALE (1 << UVM_PCTPARAM_SHIFT)
#define UVM_PCTPARAM_APPLY(pct, x) \
(((x) * (pct)->pct_scaled) >> UVM_PCTPARAM_SHIFT)
struct uvm_pctparam {
int pct_pct; /* percent [0, 100] */
int pct_scaled;
};
/*
* uvmexp: global data structures that are exported to parts of the kernel
* other than the vm system.
@ -298,6 +311,8 @@ struct uvmexp {
int anonmaxpct; /* max percent anon pages */
int execmaxpct; /* max percent executable pages */
int filemaxpct; /* max percent file pages */
struct uvm_pctparam inactivepct; /* length of inactive queue
(pct of the whole queue) */
/* swap */
int nswapdev; /* number of configured swap devices in system */
@ -306,9 +321,6 @@ struct uvmexp {
int swpginuse; /* number of swap pages in use */
int swpgonly; /* number of swap pages in use, not also in RAM */
int nswget; /* number of times fault calls uvm_swap_get() */
int unused1; /* used to be nanon */
int unused2; /* used to be nanonneeded */
int unused3; /* used to be nfreeanon */
/* stat counters */
int faults; /* page fault count */
@ -636,6 +648,7 @@ void uvmspace_unshare(struct lwp *);
void uvm_meter(void);
int uvm_sysctl(int *, u_int, void *, size_t *,
void *, size_t, struct proc *);
void uvm_pctparam_set(struct uvm_pctparam *, int);
/* uvm_mmap.c */
int uvm_mmap(struct vm_map *, vaddr_t *, vsize_t,

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_meter.c,v 1.37 2005/12/11 12:25:29 christos Exp $ */
/* $NetBSD: uvm_meter.c,v 1.38 2005/12/21 12:19:04 yamt Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_meter.c,v 1.37 2005/12/11 12:25:29 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_meter.c,v 1.38 2005/12/21 12:19:04 yamt Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -299,6 +299,34 @@ sysctl_vm_updateminmax(SYSCTLFN_ARGS)
return (0);
}
/*
* sysctl helper routine for uvm_pctparam.
*/
static int
sysctl_uvmpctparam(SYSCTLFN_ARGS)
{
int t, error;
struct sysctlnode node;
struct uvm_pctparam *pct;
pct = rnode->sysctl_data;
t = pct->pct_pct;
node = *rnode;
node.sysctl_data = &t;
t = *(int*)rnode->sysctl_data;
error = sysctl_lookup(SYSCTLFN_CALL(&node));
if (error || newp == NULL)
return error;
if (t < 0 || t > 100)
return EINVAL;
uvm_pctparam_set(pct, t);
return (0);
}
/*
* uvm_sysctl: sysctl hook into UVM system.
*/
@ -407,6 +435,13 @@ SYSCTL_SETUP(sysctl_vm_setup, "sysctl vm subtree setup")
SYSCTL_DESCR("Whether try to zero pages in idle loop"),
NULL, 0, &vm_page_zero_enable, 0,
CTL_VM, CTL_CREATE, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
CTLTYPE_INT, "inactivepct",
SYSCTL_DESCR("Percentage of inactive queue of"
"the entire (active + inactive) queue"),
sysctl_uvmpctparam, 0, &uvmexp.inactivepct, 0,
CTL_VM, CTL_CREATE, CTL_EOL);
}
/*
@ -496,3 +531,11 @@ uvm_total(struct vmtotal *totalp)
totalp->t_rmshr = 0; /* XXX */
totalp->t_armshr = 0; /* XXX */
}
void
uvm_pctparam_set(struct uvm_pctparam *pct, int val)
{
pct->pct_pct = val;
pct->pct_scaled = val * UVM_PCTPARAM_SCALE / 100;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_page.c,v 1.107 2005/12/11 12:25:29 christos Exp $ */
/* $NetBSD: uvm_page.c,v 1.108 2005/12/21 12:19:04 yamt Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.107 2005/12/11 12:25:29 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.108 2005/12/21 12:19:04 yamt Exp $");
#include "opt_uvmhist.h"
@ -433,6 +433,7 @@ uvm_page_init(vaddr_t *kvm_startp, vaddr_t *kvm_endp)
uvmexp.anonmax = uvmexp.anonmaxpct * 256 / 100;
uvmexp.filemax = uvmexp.filemaxpct * 256 / 100;
uvmexp.execmax = uvmexp.execmaxpct * 256 / 100;
uvm_pctparam_set(&uvmexp.inactivepct, 33);
/*
* determine if we should zero pages in the idle loop.

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_pdaemon.c,v 1.69 2005/11/29 15:45:28 yamt Exp $ */
/* $NetBSD: uvm_pdaemon.c,v 1.70 2005/12/21 12:19:04 yamt Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_pdaemon.c,v 1.69 2005/11/29 15:45:28 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_pdaemon.c,v 1.70 2005/12/21 12:19:04 yamt Exp $");
#include "opt_uvmhist.h"
#include "opt_readahead.h"
@ -245,7 +245,8 @@ uvm_pageout(void *arg)
uvmpd_tune();
}
uvmexp.inactarg = (uvmexp.active + uvmexp.inactive) / 3;
uvmexp.inactarg = UVM_PCTPARAM_APPLY(&uvmexp.inactivepct,
uvmexp.active + uvmexp.inactive);
if (uvmexp.inactarg <= uvmexp.freetarg) {
uvmexp.inactarg = uvmexp.freetarg + 1;
}