FreeBSD kernel kern code
kern_poll.c File Reference
#include <sys/cdefs.h>
#include "opt_device_polling.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
#include <sys/proc.h>
#include <sys/eventhandler.h>
#include <sys/resourcevar.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <net/if.h>
#include <net/netisr.h>
#include <net/vnet.h>
Include dependency graph for kern_poll.c:

Go to the source code of this file.

Data Structures

struct  pollrec
 

Macros

#define MIN_POLL_BURST_MAX   10
 
#define MAX_POLL_BURST_MAX   1000
 
#define POLL_LIST_LEN   128
 

Functions

 __FBSDID ("$BSDSUniX$")
 
void hardclock_device_poll (void)
 
static SYSCTL_NODE (_kern, OID_AUTO, polling, CTLFLAG_RW, 0,"Device polling parameters")
 
 SYSCTL_UINT (_kern_polling, OID_AUTO, burst, CTLFLAG_RD,&poll_burst, 0,"Current polling burst size")
 
static int poll_burst_max_sysctl (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_polling, OID_AUTO, burst_max, CTLTYPE_UINT|CTLFLAG_RW, 0, sizeof(uint32_t), poll_burst_max_sysctl,"I","Max Polling burst size")
 
static int poll_each_burst_sysctl (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_polling, OID_AUTO, each_burst, CTLTYPE_UINT|CTLFLAG_RW, 0, sizeof(uint32_t), poll_each_burst_sysctl,"I","Max size of each burst")
 
 SYSCTL_UINT (_kern_polling, OID_AUTO, idle_poll, CTLFLAG_RW,&poll_in_idle_loop, 0,"Enable device polling in idle loop")
 
static int user_frac_sysctl (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_polling, OID_AUTO, user_frac, CTLTYPE_UINT|CTLFLAG_RW, 0, sizeof(uint32_t), user_frac_sysctl,"I","Desired user fraction of cpu time")
 
static int reg_frac_sysctl (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_polling, OID_AUTO, reg_frac, CTLTYPE_UINT|CTLFLAG_RW, 0, sizeof(uint32_t), reg_frac_sysctl,"I","Every this many cycles check registers")
 
 SYSCTL_UINT (_kern_polling, OID_AUTO, short_ticks, CTLFLAG_RD,&short_ticks, 0,"Hardclock ticks shorter than they should be")
 
 SYSCTL_UINT (_kern_polling, OID_AUTO, lost_polls, CTLFLAG_RD,&lost_polls, 0,"How many times we would have lost a poll tick")
 
 SYSCTL_UINT (_kern_polling, OID_AUTO, pending_polls, CTLFLAG_RD,&pending_polls, 0,"Do we need to poll again")
 
 SYSCTL_INT (_kern_polling, OID_AUTO, residual_burst, CTLFLAG_RD,&residual_burst, 0,"# of residual cycles in burst")
 
 SYSCTL_UINT (_kern_polling, OID_AUTO, handlers, CTLFLAG_RD,&poll_handlers, 0,"Number of registered poll handlers")
 
 SYSCTL_UINT (_kern_polling, OID_AUTO, phase, CTLFLAG_RD,&phase, 0,"Polling phase")
 
 SYSCTL_UINT (_kern_polling, OID_AUTO, suspect, CTLFLAG_RD,&suspect, 0,"suspect event")
 
 SYSCTL_UINT (_kern_polling, OID_AUTO, stalled, CTLFLAG_RD,&stalled, 0,"potential stalls")
 
 SYSCTL_UINT (_kern_polling, OID_AUTO, idlepoll_sleeping, CTLFLAG_RD,&idlepoll_sleeping, 0,"idlepoll is sleeping")
 
static void poll_shutdown (void *arg, int howto)
 
static void init_device_poll (void)
 
 SYSINIT (device_poll, SI_SUB_CLOCKS, SI_ORDER_MIDDLE, init_device_poll, NULL)
 
static void ether_poll (int count)
 
void netisr_pollmore ()
 
void netisr_poll (void)
 
int ether_poll_register (poll_handler_t *h, struct ifnet *ifp)
 
int ether_poll_deregister (struct ifnet *ifp)
 
static void poll_idle (void)
 
 SYSINIT (idlepoll, SI_SUB_KTHREAD_VM, SI_ORDER_ANY, kproc_start,&idlepoll_kp)
 

Variables

static struct mtx poll_mtx
 
static uint32_t poll_burst = 5
 
static uint32_t poll_burst_max = 150
 
static uint32_t poll_each_burst = 5
 
static int netisr_poll_scheduled
 
static int netisr_pollmore_scheduled
 
static int poll_shutting_down
 
static uint32_t poll_in_idle_loop =0
 
static uint32_t user_frac = 50
 
static uint32_t reg_frac_count = 0
 
static uint32_t reg_frac = 20
 
static uint32_t short_ticks
 
static uint32_t lost_polls
 
static uint32_t pending_polls
 
static int residual_burst = 0
 
static uint32_t poll_handlers
 
static uint32_t phase
 
static uint32_t suspect
 
static uint32_t stalled
 
static uint32_t idlepoll_sleeping
 
static struct pollrec pr [POLL_LIST_LEN]
 
static struct timeval poll_start_t
 
static struct proc * idlepoll
 
static struct kproc_desc idlepoll_kp
 

Macro Definition Documentation

#define MAX_POLL_BURST_MAX   1000

Definition at line 95 of file kern_poll.c.

Referenced by poll_burst_max_sysctl().

#define MIN_POLL_BURST_MAX   10

Definition at line 94 of file kern_poll.c.

Referenced by poll_burst_max_sysctl().

#define POLL_LIST_LEN   128

Definition at line 248 of file kern_poll.c.

Referenced by ether_poll_register().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static void ether_poll ( int  count)
static

Definition at line 331 of file kern_poll.c.

References poll_each_burst, poll_handlers, poll_mtx, and pr.

Referenced by poll_idle().

Here is the caller graph for this function:

int ether_poll_deregister ( struct ifnet *  ifp)

Definition at line 509 of file kern_poll.c.

References pollrec::handler, pollrec::ifp, log(), poll_handlers, poll_mtx, and pr.

Here is the call graph for this function:

int ether_poll_register ( poll_handler_t *  h,
struct ifnet *  ifp 
)

Definition at line 462 of file kern_poll.c.

References pollrec::handler, pollrec::ifp, log(), poll_handlers, POLL_LIST_LEN, poll_mtx, pr, and wakeup().

Here is the call graph for this function:

void hardclock_device_poll ( void  )

Definition at line 288 of file kern_poll.c.

References hz, microuptime(), netisr_poll_scheduled, netisr_pollmore_scheduled, and poll_shutting_down.

Referenced by hardclock(), and hardclock_cnt().

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_device_poll ( void  )
static

Definition at line 264 of file kern_poll.c.

References mtx_init(), poll_mtx, and poll_shutdown().

Here is the call graph for this function:

void netisr_poll ( void  )

Definition at line 422 of file kern_poll.c.

References microuptime(), netisr_poll_scheduled, poll_burst, poll_each_burst, poll_handlers, poll_mtx, poll_start_t, and pr.

Here is the call graph for this function:

void netisr_pollmore ( )

Definition at line 365 of file kern_poll.c.

References hz, microuptime(), netisr_poll_scheduled, netisr_pollmore_scheduled, poll_burst, poll_burst_max, poll_mtx, and poll_start_t.

Here is the call graph for this function:

static int poll_burst_max_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 111 of file kern_poll.c.

References MAX_POLL_BURST_MAX, MIN_POLL_BURST_MAX, poll_burst, poll_burst_max, poll_each_burst, poll_mtx, and sysctl_handle_int().

Here is the call graph for this function:

static int poll_each_burst_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 135 of file kern_poll.c.

References poll_burst_max, poll_each_burst, poll_mtx, and sysctl_handle_int().

Here is the call graph for this function:

static void poll_idle ( void  )
static

Definition at line 536 of file kern_poll.c.

References ether_poll(), hz, mi_switch(), poll_each_burst, and rtp_to_pri().

Here is the call graph for this function:

static void poll_shutdown ( void *  arg,
int  howto 
)
static

Definition at line 257 of file kern_poll.c.

References poll_shutting_down.

Referenced by init_device_poll().

Here is the caller graph for this function:

static int reg_frac_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 188 of file kern_poll.c.

References hz, poll_mtx, reg_frac, and sysctl_handle_int().

Here is the call graph for this function:

SYSCTL_INT ( _kern_polling  ,
OID_AUTO  ,
residual_burst  ,
CTLFLAG_RD  ,
residual_burst,
,
"# of residual cycles in burst"   
)
static SYSCTL_NODE ( _kern  ,
OID_AUTO  ,
polling  ,
CTLFLAG_RW  ,
,
"Device polling parameters"   
)
static
SYSCTL_PROC ( _kern_polling  ,
OID_AUTO  ,
burst_max  ,
CTLTYPE_UINT|  CTLFLAG_RW,
,
sizeof(uint32_t)  ,
poll_burst_max_sysctl  ,
"I"  ,
"Max Polling burst size"   
)
SYSCTL_PROC ( _kern_polling  ,
OID_AUTO  ,
each_burst  ,
CTLTYPE_UINT|  CTLFLAG_RW,
,
sizeof(uint32_t)  ,
poll_each_burst_sysctl  ,
"I"  ,
"Max size of each burst"   
)
SYSCTL_PROC ( _kern_polling  ,
OID_AUTO  ,
user_frac  ,
CTLTYPE_UINT|  CTLFLAG_RW,
,
sizeof(uint32_t)  ,
user_frac_sysctl  ,
"I"  ,
"Desired user fraction of cpu time"   
)
SYSCTL_PROC ( _kern_polling  ,
OID_AUTO  ,
reg_frac  ,
CTLTYPE_UINT|  CTLFLAG_RW,
,
sizeof(uint32_t)  ,
reg_frac_sysctl  ,
"I"  ,
"Every this many cycles check registers"   
)
SYSCTL_UINT ( _kern_polling  ,
OID_AUTO  ,
burst  ,
CTLFLAG_RD  ,
poll_burst,
,
"Current polling burst size"   
)
SYSCTL_UINT ( _kern_polling  ,
OID_AUTO  ,
idle_poll  ,
CTLFLAG_RW  ,
poll_in_idle_loop,
,
"Enable device polling in idle loop"   
)
SYSCTL_UINT ( _kern_polling  ,
OID_AUTO  ,
short_ticks  ,
CTLFLAG_RD  ,
short_ticks,
,
"Hardclock ticks shorter than they should be"   
)
SYSCTL_UINT ( _kern_polling  ,
OID_AUTO  ,
lost_polls  ,
CTLFLAG_RD  ,
lost_polls,
,
"How many times we would have lost a poll tick  
)
SYSCTL_UINT ( _kern_polling  ,
OID_AUTO  ,
pending_polls  ,
CTLFLAG_RD  ,
pending_polls,
,
"Do we need to poll again"   
)
SYSCTL_UINT ( _kern_polling  ,
OID_AUTO  ,
handlers  ,
CTLFLAG_RD  ,
poll_handlers,
,
"Number of registered poll handlers"   
)
SYSCTL_UINT ( _kern_polling  ,
OID_AUTO  ,
phase  ,
CTLFLAG_RD  ,
phase,
,
"Polling phase  
)
SYSCTL_UINT ( _kern_polling  ,
OID_AUTO  ,
suspect  ,
CTLFLAG_RD  ,
suspect,
,
"suspect event"   
)
SYSCTL_UINT ( _kern_polling  ,
OID_AUTO  ,
stalled  ,
CTLFLAG_RD  ,
stalled,
,
"potential stalls"   
)
SYSCTL_UINT ( _kern_polling  ,
OID_AUTO  ,
idlepoll_sleeping  ,
CTLFLAG_RD  ,
idlepoll_sleeping,
,
"idlepoll is sleeping"   
)
SYSINIT ( device_poll  ,
SI_SUB_CLOCKS  ,
SI_ORDER_MIDDLE  ,
init_device_poll  ,
NULL   
)
SYSINIT ( idlepoll  ,
SI_SUB_KTHREAD_VM  ,
SI_ORDER_ANY  ,
kproc_start  ,
idlepoll_kp 
)
static int user_frac_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 165 of file kern_poll.c.

References poll_mtx, sysctl_handle_int(), and user_frac.

Here is the call graph for this function:

Variable Documentation

struct proc* idlepoll
static

Definition at line 561 of file kern_poll.c.

struct kproc_desc idlepoll_kp
static
Initial value:
= {
"idlepoll",
}
static void poll_idle(void)
Definition: kern_poll.c:536
static struct proc * idlepoll
Definition: kern_poll.c:561

Definition at line 562 of file kern_poll.c.

uint32_t idlepoll_sleeping
static

Definition at line 243 of file kern_poll.c.

uint32_t lost_polls
static

Definition at line 215 of file kern_poll.c.

int netisr_poll_scheduled
static

Definition at line 107 of file kern_poll.c.

Referenced by hardclock_device_poll(), netisr_poll(), and netisr_pollmore().

int netisr_pollmore_scheduled
static

Definition at line 108 of file kern_poll.c.

Referenced by hardclock_device_poll(), and netisr_pollmore().

uint32_t pending_polls
static

Definition at line 219 of file kern_poll.c.

uint32_t phase
static

Definition at line 231 of file kern_poll.c.

uint32_t poll_burst = 5
static

Definition at line 97 of file kern_poll.c.

Referenced by netisr_poll(), netisr_pollmore(), and poll_burst_max_sysctl().

uint32_t poll_burst_max = 150
static

Definition at line 98 of file kern_poll.c.

Referenced by netisr_pollmore(), poll_burst_max_sysctl(), and poll_each_burst_sysctl().

uint32_t poll_each_burst = 5
static
uint32_t poll_handlers
static

Definition at line 227 of file kern_poll.c.

Referenced by ether_poll(), ether_poll_deregister(), ether_poll_register(), and netisr_poll().

uint32_t poll_in_idle_loop =0
static

Definition at line 160 of file kern_poll.c.

int poll_shutting_down
static

Definition at line 109 of file kern_poll.c.

Referenced by hardclock_device_poll(), and poll_shutdown().

struct timeval poll_start_t
static

Definition at line 362 of file kern_poll.c.

Referenced by netisr_poll(), and netisr_pollmore().

uint32_t reg_frac = 20
static

Definition at line 187 of file kern_poll.c.

Referenced by reg_frac_sysctl().

uint32_t reg_frac_count = 0
static

Definition at line 186 of file kern_poll.c.

int residual_burst = 0
static

Definition at line 223 of file kern_poll.c.

uint32_t short_ticks
static

Definition at line 211 of file kern_poll.c.

uint32_t stalled
static

Definition at line 239 of file kern_poll.c.

uint32_t suspect
static

Definition at line 235 of file kern_poll.c.

uint32_t user_frac = 50
static

Definition at line 164 of file kern_poll.c.

Referenced by user_frac_sysctl().