Changeset View
Standalone View
sys/kern/subr_param.c
Show All 35 Lines | |||||
* @(#)param.c 8.3 (Berkeley) 8/20/94 | * @(#)param.c 8.3 (Berkeley) 8/20/94 | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_param.h" | #include "opt_param.h" | ||||
#include "opt_msgbuf.h" | #include "opt_msgbuf.h" | ||||
#include "opt_maxphys.h" | |||||
#include "opt_maxusers.h" | #include "opt_maxusers.h" | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/buf.h> | #include <sys/buf.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/limits.h> | #include <sys/limits.h> | ||||
#include <sys/msgbuf.h> | #include <sys/msgbuf.h> | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
int maxfiles; /* sys. wide open files limit */ | int maxfiles; /* sys. wide open files limit */ | ||||
int maxfilesperproc; /* per-proc open files limit */ | int maxfilesperproc; /* per-proc open files limit */ | ||||
int msgbufsize; /* size of kernel message buffer */ | int msgbufsize; /* size of kernel message buffer */ | ||||
int nbuf; | int nbuf; | ||||
int bio_transient_maxcnt; | int bio_transient_maxcnt; | ||||
int ngroups_max; /* max # groups per process */ | int ngroups_max; /* max # groups per process */ | ||||
int nswbuf; | int nswbuf; | ||||
pid_t pid_max = PID_MAX; | pid_t pid_max = PID_MAX; | ||||
long maxswzone; /* max swmeta KVA storage */ | u_long maxswzone; /* max swmeta KVA storage */ | ||||
long maxbcache; /* max buffer cache KVA storage */ | u_long maxbcache; /* max buffer cache KVA storage */ | ||||
long maxpipekva; /* Limit on pipe KVA */ | u_long maxpipekva; /* Limit on pipe KVA */ | ||||
u_long maxphys; | |||||
mav: Should we mark those as __read_mostly? | |||||
Done Inline ActionsThe maxphys var is mostly unused after the patch, its consumers are driver initialization code. Also I am not a fan of jealous application of micro-optimizations without proof of importance. kib: The maxphys var is mostly unused after the patch, its consumers are driver initialization code. | |||||
int vm_guest = VM_GUEST_NO; /* Running as virtual machine guest? */ | int vm_guest = VM_GUEST_NO; /* Running as virtual machine guest? */ | ||||
u_long maxtsiz; /* max text size */ | u_long maxtsiz; /* max text size */ | ||||
u_long dfldsiz; /* initial data size limit */ | u_long dfldsiz; /* initial data size limit */ | ||||
u_long maxdsiz; /* max data size */ | u_long maxdsiz; /* max data size */ | ||||
u_long dflssiz; /* initial stack size limit */ | u_long dflssiz; /* initial stack size limit */ | ||||
u_long maxssiz; /* max stack size */ | u_long maxssiz; /* max stack size */ | ||||
u_long sgrowsiz; /* amount to grow stack */ | u_long sgrowsiz; /* amount to grow stack */ | ||||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | #endif | ||||
TUNABLE_INT_FETCH("kern.maxfilesperproc", &maxfilesperproc); | TUNABLE_INT_FETCH("kern.maxfilesperproc", &maxfilesperproc); | ||||
/* | /* | ||||
* Cannot be changed after boot. | * Cannot be changed after boot. | ||||
*/ | */ | ||||
nbuf = NBUF; | nbuf = NBUF; | ||||
TUNABLE_INT_FETCH("kern.nbuf", &nbuf); | TUNABLE_INT_FETCH("kern.nbuf", &nbuf); | ||||
TUNABLE_INT_FETCH("kern.bio_transient_maxcnt", &bio_transient_maxcnt); | TUNABLE_INT_FETCH("kern.bio_transient_maxcnt", &bio_transient_maxcnt); | ||||
maxphys = MAXPHYS; | |||||
TUNABLE_ULONG_FETCH("kern.maxphys", &maxphys); | |||||
/* | /* | ||||
* Physical buffers are pre-allocated buffers (struct buf) that | * Physical buffers are pre-allocated buffers (struct buf) that | ||||
* are used as temporary holders for I/O, such as paging I/O. | * are used as temporary holders for I/O, such as paging I/O. | ||||
*/ | */ | ||||
TUNABLE_INT_FETCH("kern.nswbuf", &nswbuf); | TUNABLE_INT_FETCH("kern.nswbuf", &nswbuf); | ||||
/* | /* | ||||
Done Inline ActionsIs there a minimum that needs to be enforced? imp: Is there a minimum that needs to be enforced? | |||||
Done Inline ActionsI am not sure, perhaps one page is absolutely required, I am not sure how far can we proceed with it. I somewhat dislike even the checks I added, I do not see why users should be not allowed to experiment. The cost of mistake there is low, at worst machine won't boot. It is somewhat costly for a user not having access to console, but such user probably ought to not make experiments like that. kib: I am not sure, perhaps one page is absolutely required, I am not sure how far can we proceed… | |||||
Not Done Inline ActionsI think a basic check of PAGE_SIZE is a reasonable seat-belt. Otherwise some might think that 512b is a reasonable MAXPHYS, or even 0, both of which is think would result in a system unable to do any disk I/O. It's not like this would be checked on every I/O, it's just a boot-time seatbelt. I'm not going to object to it's absence, and I might add it later if it doesn't happen. scottl: I think a basic check of PAGE_SIZE is a reasonable seat-belt. Otherwise some might think that… | |||||
* The default for maxpipekva is min(1/64 of the kernel address space, | * The default for maxpipekva is min(1/64 of the kernel address space, | ||||
* max(1/64 of main memory, 512KB)). See sys_pipe.c for more details. | * max(1/64 of main memory, 512KB)). See sys_pipe.c for more details. | ||||
*/ | */ | ||||
maxpipekva = (physpages / 64) * PAGE_SIZE; | maxpipekva = ptoa(physpages / 64); | ||||
TUNABLE_LONG_FETCH("kern.ipc.maxpipekva", &maxpipekva); | TUNABLE_LONG_FETCH("kern.ipc.maxpipekva", &maxpipekva); | ||||
if (maxpipekva < 512 * 1024) | if (maxpipekva < 512 * 1024) | ||||
maxpipekva = 512 * 1024; | maxpipekva = 512 * 1024; | ||||
if (maxpipekva > (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / 64) | if (maxpipekva > (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / 64) | ||||
maxpipekva = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / | maxpipekva = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / | ||||
64; | 64; | ||||
} | } | ||||
/* | /* | ||||
* Sysctl stringifying handler for kern.vm_guest. | * Sysctl stringifying handler for kern.vm_guest. | ||||
*/ | */ | ||||
static int | static int | ||||
sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS) | sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
return (SYSCTL_OUT_STR(req, vm_guest_sysctl_names[vm_guest])); | return (SYSCTL_OUT_STR(req, vm_guest_sysctl_names[vm_guest])); | ||||
} | } |
Should we mark those as __read_mostly?