Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_mbuf.c
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
int nmbufs; /* limits number of mbufs */ | int nmbufs; /* limits number of mbufs */ | ||||
int nmbclusters; /* limits number of mbuf clusters */ | int nmbclusters; /* limits number of mbuf clusters */ | ||||
int nmbjumbop; /* limits number of page size jumbo clusters */ | int nmbjumbop; /* limits number of page size jumbo clusters */ | ||||
int nmbjumbo9; /* limits number of 9k jumbo clusters */ | int nmbjumbo9; /* limits number of 9k jumbo clusters */ | ||||
int nmbjumbo16; /* limits number of 16k jumbo clusters */ | int nmbjumbo16; /* limits number of 16k jumbo clusters */ | ||||
bool mb_use_ext_pgs = true; /* use M_EXTPG mbufs for sendfile & TLS */ | bool mb_use_ext_pgs = false; /* use M_EXTPG mbufs for sendfile & TLS */ | ||||
SYSCTL_BOOL(_kern_ipc, OID_AUTO, mb_use_ext_pgs, CTLFLAG_RWTUN, | |||||
static int | |||||
sysctl_mb_use_ext_pgs(SYSCTL_HANDLER_ARGS) | |||||
{ | |||||
int error, extpg; | |||||
extpg = mb_use_ext_pgs; | |||||
error = sysctl_handle_int(oidp, &extpg, 0, req); | |||||
if (error == 0 && req->newptr != NULL) { | |||||
if (extpg != 0 && !PMAP_HAS_DMAP) | |||||
error = EOPNOTSUPP; | |||||
else | |||||
mb_use_ext_pgs = extpg != 0; | |||||
} | |||||
return (error); | |||||
} | |||||
SYSCTL_PROC(_kern_ipc, OID_AUTO, mb_use_ext_pgs, CTLTYPE_INT | CTLFLAG_RW, | |||||
&mb_use_ext_pgs, 0, | &mb_use_ext_pgs, 0, | ||||
sysctl_mb_use_ext_pgs, "IU", | |||||
"Use unmapped mbufs for sendfile(2) and TLS offload"); | "Use unmapped mbufs for sendfile(2) and TLS offload"); | ||||
static quad_t maxmbufmem; /* overall real memory limit for all mbufs */ | static quad_t maxmbufmem; /* overall real memory limit for all mbufs */ | ||||
SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxmbufmem, 0, | SYSCTL_QUAD(_kern_ipc, OID_AUTO, maxmbufmem, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxmbufmem, 0, | ||||
"Maximum real memory allocatable to various mbuf types"); | "Maximum real memory allocatable to various mbuf types"); | ||||
static counter_u64_t snd_tag_count; | static counter_u64_t snd_tag_count; | ||||
SYSCTL_COUNTER_U64(_kern_ipc, OID_AUTO, num_snd_tags, CTLFLAG_RW, | SYSCTL_COUNTER_U64(_kern_ipc, OID_AUTO, num_snd_tags, CTLFLAG_RW, | ||||
&snd_tag_count, "# of active mbuf send tags"); | &snd_tag_count, "# of active mbuf send tags"); | ||||
/* | /* | ||||
* tunable_mbinit() has to be run before any mbuf allocations are done. | * tunable_mbinit() has to be run before any mbuf allocations are done. | ||||
*/ | */ | ||||
static void | static void | ||||
tunable_mbinit(void *dummy) | tunable_mbinit(void *dummy) | ||||
{ | { | ||||
quad_t realmem; | quad_t realmem; | ||||
int extpg; | |||||
/* | /* | ||||
* The default limit for all mbuf related memory is 1/2 of all | * The default limit for all mbuf related memory is 1/2 of all | ||||
* available kernel memory (physical or kmem). | * available kernel memory (physical or kmem). | ||||
* At most it can be 3/4 of available kernel memory. | * At most it can be 3/4 of available kernel memory. | ||||
*/ | */ | ||||
realmem = qmin((quad_t)physmem * PAGE_SIZE, vm_kmem_size); | realmem = qmin((quad_t)physmem * PAGE_SIZE, vm_kmem_size); | ||||
maxmbufmem = realmem / 2; | maxmbufmem = realmem / 2; | ||||
Show All 20 Lines | tunable_mbinit(void *dummy) | ||||
/* | /* | ||||
* We need at least as many mbufs as we have clusters of | * We need at least as many mbufs as we have clusters of | ||||
* the various types added together. | * the various types added together. | ||||
*/ | */ | ||||
TUNABLE_INT_FETCH("kern.ipc.nmbufs", &nmbufs); | TUNABLE_INT_FETCH("kern.ipc.nmbufs", &nmbufs); | ||||
if (nmbufs < nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16) | if (nmbufs < nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16) | ||||
nmbufs = lmax(maxmbufmem / MSIZE / 5, | nmbufs = lmax(maxmbufmem / MSIZE / 5, | ||||
nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16); | nmbclusters + nmbjumbop + nmbjumbo9 + nmbjumbo16); | ||||
/* | |||||
* Unmapped mbufs can only safely be used on platforms with a direct | |||||
* map. | |||||
*/ | |||||
if (PMAP_HAS_DMAP) { | |||||
extpg = mb_use_ext_pgs; | |||||
jhb: So this permits an override if you set the tunable to 1/true, yes? | |||||
Done Inline ActionsOops. It was actually my intent to ignore the tunable value if !PMAP_HAS_DMAP. That is, the policy is not meant to be overridable. markj: Oops. It was actually my intent to ignore the tunable value if !PMAP_HAS_DMAP. That is, the… | |||||
TUNABLE_INT_FETCH("kern.ipc.mb_use_ext_pgs", &extpg); | |||||
mb_use_ext_pgs = extpg != 0; | |||||
} | |||||
} | } | ||||
SYSINIT(tunable_mbinit, SI_SUB_KMEM, SI_ORDER_MIDDLE, tunable_mbinit, NULL); | SYSINIT(tunable_mbinit, SI_SUB_KMEM, SI_ORDER_MIDDLE, tunable_mbinit, NULL); | ||||
static int | static int | ||||
sysctl_nmbclusters(SYSCTL_HANDLER_ARGS) | sysctl_nmbclusters(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
int error, newnmbclusters; | int error, newnmbclusters; | ||||
▲ Show 20 Lines • Show All 1,526 Lines • Show Last 20 Lines |
So this permits an override if you set the tunable to 1/true, yes?