Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_poll.c
Show All 12 Lines | |||||
if (poll_burst > poll_burst_max) | if (poll_burst > poll_burst_max) | ||||
poll_burst = poll_burst_max; | poll_burst = poll_burst_max; | ||||
if (poll_each_burst > poll_burst_max) | if (poll_each_burst > poll_burst_max) | ||||
poll_each_burst = MIN_POLL_BURST_MAX; | poll_each_burst = MIN_POLL_BURST_MAX; | ||||
mtx_unlock(&poll_mtx); | mtx_unlock(&poll_mtx); | ||||
return (0); | return (0); | ||||
} | } | ||||
SYSCTL_PROC(_kern_polling, OID_AUTO, burst_max, CTLTYPE_UINT | CTLFLAG_RW, | SYSCTL_PROC(_kern_polling, OID_AUTO, burst_max, | ||||
0, sizeof(uint32_t), poll_burst_max_sysctl, "I", "Max Polling burst size"); | CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, | ||||
0, sizeof(uint32_t), poll_burst_max_sysctl, "I", | |||||
"Max Polling burst size"); | |||||
static int poll_each_burst_sysctl(SYSCTL_HANDLER_ARGS) | static int poll_each_burst_sysctl(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
uint32_t val = poll_each_burst; | uint32_t val = poll_each_burst; | ||||
int error; | int error; | ||||
error = sysctl_handle_int(oidp, &val, 0, req); | error = sysctl_handle_int(oidp, &val, 0, req); | ||||
if (error || !req->newptr ) | if (error || !req->newptr ) | ||||
return (error); | return (error); | ||||
if (val < 1) | if (val < 1) | ||||
return (EINVAL); | return (EINVAL); | ||||
mtx_lock(&poll_mtx); | mtx_lock(&poll_mtx); | ||||
if (val > poll_burst_max) { | if (val > poll_burst_max) { | ||||
mtx_unlock(&poll_mtx); | mtx_unlock(&poll_mtx); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
poll_each_burst = val; | poll_each_burst = val; | ||||
mtx_unlock(&poll_mtx); | mtx_unlock(&poll_mtx); | ||||
return (0); | return (0); | ||||
} | } | ||||
SYSCTL_PROC(_kern_polling, OID_AUTO, each_burst, CTLTYPE_UINT | CTLFLAG_RW, | SYSCTL_PROC(_kern_polling, OID_AUTO, each_burst, | ||||
0, sizeof(uint32_t), poll_each_burst_sysctl, "I", | CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, | ||||
"Max size of each burst"); | 0, sizeof(uint32_t), poll_each_burst_sysctl, "I", | ||||
"Max size of each burst"); | |||||
static uint32_t poll_in_idle_loop=0; /* do we poll in idle loop ? */ | static uint32_t poll_in_idle_loop=0; /* do we poll in idle loop ? */ | ||||
SYSCTL_UINT(_kern_polling, OID_AUTO, idle_poll, CTLFLAG_RW, | SYSCTL_UINT(_kern_polling, OID_AUTO, idle_poll, CTLFLAG_RW, | ||||
&poll_in_idle_loop, 0, "Enable device polling in idle loop"); | &poll_in_idle_loop, 0, "Enable device polling in idle loop"); | ||||
static uint32_t user_frac = 50; | static uint32_t user_frac = 50; | ||||
static int user_frac_sysctl(SYSCTL_HANDLER_ARGS) | static int user_frac_sysctl(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
uint32_t val = user_frac; | uint32_t val = user_frac; | ||||
int error; | int error; | ||||
error = sysctl_handle_int(oidp, &val, 0, req); | error = sysctl_handle_int(oidp, &val, 0, req); | ||||
if (error || !req->newptr ) | if (error || !req->newptr ) | ||||
return (error); | return (error); | ||||
if (val > 99) | if (val > 99) | ||||
return (EINVAL); | return (EINVAL); | ||||
mtx_lock(&poll_mtx); | mtx_lock(&poll_mtx); | ||||
user_frac = val; | user_frac = val; | ||||
mtx_unlock(&poll_mtx); | mtx_unlock(&poll_mtx); | ||||
return (0); | return (0); | ||||
} | } | ||||
SYSCTL_PROC(_kern_polling, OID_AUTO, user_frac, CTLTYPE_UINT | CTLFLAG_RW, | SYSCTL_PROC(_kern_polling, OID_AUTO, user_frac, | ||||
0, sizeof(uint32_t), user_frac_sysctl, "I", | CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, | ||||
"Desired user fraction of cpu time"); | 0, sizeof(uint32_t), user_frac_sysctl, "I", | ||||
"Desired user fraction of cpu time"); | |||||
static uint32_t reg_frac_count = 0; | static uint32_t reg_frac_count = 0; | ||||
static uint32_t reg_frac = 20 ; | static uint32_t reg_frac = 20 ; | ||||
static int reg_frac_sysctl(SYSCTL_HANDLER_ARGS) | static int reg_frac_sysctl(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
uint32_t val = reg_frac; | uint32_t val = reg_frac; | ||||
int error; | int error; | ||||
error = sysctl_handle_int(oidp, &val, 0, req); | error = sysctl_handle_int(oidp, &val, 0, req); | ||||
if (error || !req->newptr ) | if (error || !req->newptr ) | ||||
return (error); | return (error); | ||||
if (val < 1 || val > hz) | if (val < 1 || val > hz) | ||||
return (EINVAL); | return (EINVAL); | ||||
mtx_lock(&poll_mtx); | mtx_lock(&poll_mtx); | ||||
reg_frac = val; | reg_frac = val; | ||||
if (reg_frac_count >= reg_frac) | if (reg_frac_count >= reg_frac) | ||||
reg_frac_count = 0; | reg_frac_count = 0; | ||||
mtx_unlock(&poll_mtx); | mtx_unlock(&poll_mtx); | ||||
return (0); | return (0); | ||||
} | } | ||||
SYSCTL_PROC(_kern_polling, OID_AUTO, reg_frac, CTLTYPE_UINT | CTLFLAG_RW, | SYSCTL_PROC(_kern_polling, OID_AUTO, reg_frac, | ||||
0, sizeof(uint32_t), reg_frac_sysctl, "I", | CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, | ||||
"Every this many cycles check registers"); | 0, sizeof(uint32_t), reg_frac_sysctl, "I", | ||||
"Every this many cycles check registers"); | |||||
static uint32_t short_ticks; | static uint32_t short_ticks; | ||||
SYSCTL_UINT(_kern_polling, OID_AUTO, short_ticks, CTLFLAG_RD, | SYSCTL_UINT(_kern_polling, OID_AUTO, short_ticks, CTLFLAG_RD, | ||||
&short_ticks, 0, "Hardclock ticks shorter than they should be"); | &short_ticks, 0, "Hardclock ticks shorter than they should be"); | ||||
static uint32_t lost_polls; | static uint32_t lost_polls; | ||||
SYSCTL_UINT(_kern_polling, OID_AUTO, lost_polls, CTLFLAG_RD, | SYSCTL_UINT(_kern_polling, OID_AUTO, lost_polls, CTLFLAG_RD, | ||||
&lost_polls, 0, "How many times we would have lost a poll tick"); | &lost_polls, 0, "How many times we would have lost a poll tick"); | ||||
Show All 12 Lines |