FreeBSD kernel kern code
kern_event.c File Reference
#include <sys/cdefs.h>
#include "opt_ktrace.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/capability.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/malloc.h>
#include <sys/unistd.h>
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/filio.h>
#include <sys/fcntl.h>
#include <sys/kthread.h>
#include <sys/selinfo.h>
#include <sys/queue.h>
#include <sys/event.h>
#include <sys/eventvar.h>
#include <sys/poll.h>
#include <sys/protosw.h>
#include <sys/sigio.h>
#include <sys/signalvar.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/stat.h>
#include <sys/sysctl.h>
#include <sys/sysproto.h>
#include <sys/syscallsubr.h>
#include <sys/taskqueue.h>
#include <sys/uio.h>
#include <vm/uma.h>
Include dependency graph for kern_event.c:

Go to the source code of this file.

Data Structures

struct  kevent_args
 

Macros

#define KQ_GLOBAL_LOCK(lck, haslck)
 
#define KQ_GLOBAL_UNLOCK(lck, haslck)
 
#define KNOTE_ACTIVATE(kn, islock)
 
#define KQ_LOCK(kq)
 
#define KQ_FLUX_WAKEUP(kq)
 
#define KQ_UNLOCK_FLUX(kq)
 
#define KQ_UNLOCK(kq)
 
#define KQ_OWNED(kq)
 
#define KQ_NOTOWNED(kq)
 
#define KN_LIST_LOCK(kn)
 
#define KN_LIST_UNLOCK(kn)
 
#define KNL_ASSERT_LOCK(knl, islocked)
 
#define KNL_ASSERT_LOCKED(knl)   do {} while(0)
 
#define KNL_ASSERT_UNLOCKED(knl)   do {} while (0)
 
#define KN_HASHSIZE   64 /* XXX should be tunable */
 
#define KN_HASH(val, mask)   (((val) ^ (val >> 8)) & (mask))
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static MALLOC_DEFINE (M_KQUEUE,"kqueue","memory for kqueue system")
 
 MTX_SYSINIT (kq_global,&kq_global,"kqueue order", MTX_DEF)
 
 TASKQUEUE_DEFINE_THREAD (kqueue)
 
static int kevent_copyout (void *arg, struct kevent *kevp, int count)
 
static int kevent_copyin (void *arg, struct kevent *kevp, int count)
 
static int kqueue_register (struct kqueue *kq, struct kevent *kev, struct thread *td, int waitok)
 
static int kqueue_acquire (struct file *fp, struct kqueue **kqp)
 
static void kqueue_release (struct kqueue *kq, int locked)
 
static int kqueue_expand (struct kqueue *kq, struct filterops *fops, uintptr_t ident, int waitok)
 
static void kqueue_task (void *arg, int pending)
 
static int kqueue_scan (struct kqueue *kq, int maxevents, struct kevent_copyops *k_ops, const struct timespec *timeout, struct kevent *keva, struct thread *td)
 
static void kqueue_wakeup (struct kqueue *kq)
 
static struct filterops * kqueue_fo_find (int filt)
 
static void kqueue_fo_release (int filt)
 
static int knote_attach (struct knote *kn, struct kqueue *kq)
 
static void knote_drop (struct knote *kn, struct thread *td)
 
static void knote_enqueue (struct knote *kn)
 
static void knote_dequeue (struct knote *kn)
 
static void knote_init (void)
 
static struct knoteknote_alloc (int waitok)
 
static void knote_free (struct knote *kn)
 
static void filt_kqdetach (struct knote *kn)
 
static int filt_kqueue (struct knote *kn, long hint)
 
static int filt_procattach (struct knote *kn)
 
static void filt_procdetach (struct knote *kn)
 
static int filt_proc (struct knote *kn, long hint)
 
static int filt_fileattach (struct knote *kn)
 
static void filt_timerexpire (void *knx)
 
static int filt_timerattach (struct knote *kn)
 
static void filt_timerdetach (struct knote *kn)
 
static int filt_timer (struct knote *kn, long hint)
 
static int filt_userattach (struct knote *kn)
 
static void filt_userdetach (struct knote *kn)
 
static int filt_user (struct knote *kn, long hint)
 
static void filt_usertouch (struct knote *kn, struct kevent *kev, u_long type)
 
 SYSCTL_INT (_kern, OID_AUTO, kq_calloutmax, CTLFLAG_RW,&kq_calloutmax, 0,"Maximum number of callouts allocated for kqueue")
 
static int filt_nullattach (struct knote *kn)
 
 MTX_SYSINIT (kqueue_filterops,&filterops_lock,"protect sysfilt_ops", MTX_DEF)
 
static int kqueue_kqfilter (struct file *fp, struct knote *kn)
 
void knote_fork (struct knlist *list, int pid)
 
static int timertoticks (intptr_t data)
 
static void filt_userdetach (__unused struct knote *kn)
 
static int filt_user (struct knote *kn, __unused long hint)
 
int sys_kqueue (struct thread *td, struct kqueue_args *uap)
 
int sys_kevent (struct thread *td, struct kevent_args *uap)
 
int kern_kevent (struct thread *td, int fd, int nchanges, int nevents, struct kevent_copyops *k_ops, const struct timespec *timeout)
 
int kqueue_add_filteropts (int filt, struct filterops *filtops)
 
int kqueue_del_filteropts (int filt)
 
static void kqueue_schedtask (struct kqueue *kq)
 
static int kqueue_read (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
static int kqueue_write (struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td)
 
static int kqueue_truncate (struct file *fp, off_t length, struct ucred *active_cred, struct thread *td)
 
static int kqueue_ioctl (struct file *fp, u_long cmd, void *data, struct ucred *active_cred, struct thread *td)
 
static int kqueue_poll (struct file *fp, int events, struct ucred *active_cred, struct thread *td)
 
static int kqueue_stat (struct file *fp, struct stat *st, struct ucred *active_cred, struct thread *td)
 
static int kqueue_close (struct file *fp, struct thread *td)
 
void knote (struct knlist *list, long hint, int lockflags)
 
void knlist_add (struct knlist *knl, struct knote *kn, int islocked)
 
static void knlist_remove_kq (struct knlist *knl, struct knote *kn, int knlislocked, int kqislocked)
 
void knlist_remove (struct knlist *knl, struct knote *kn, int islocked)
 
void knlist_remove_inevent (struct knlist *knl, struct knote *kn)
 
int knlist_empty (struct knlist *knl)
 
 MTX_SYSINIT (knlist_lock,&knlist_lock,"knlist lock for lockless objects", MTX_DEF)
 
static void knlist_mtx_lock (void *arg)
 
static void knlist_mtx_unlock (void *arg)
 
static void knlist_mtx_assert_locked (void *arg)
 
static void knlist_mtx_assert_unlocked (void *arg)
 
void knlist_init (struct knlist *knl, void *lock, void(*kl_lock)(void *), void(*kl_unlock)(void *), void(*kl_assert_locked)(void *), void(*kl_assert_unlocked)(void *))
 
void knlist_init_mtx (struct knlist *knl, struct mtx *lock)
 
void knlist_destroy (struct knlist *knl)
 
void knlist_cleardel (struct knlist *knl, struct thread *td, int islocked, int killkn)
 
void knote_fdclose (struct thread *td, int fd)
 
 SYSINIT (knote, SI_SUB_PSEUDO, SI_ORDER_ANY, knote_init, NULL)
 
int kqfd_register (int fd, struct kevent *kev, struct thread *td, int waitok)
 

Variables

static struct mtx kq_global
 
static fo_rdwr_t kqueue_read
 
static fo_rdwr_t kqueue_write
 
static fo_truncate_t kqueue_truncate
 
static fo_ioctl_t kqueue_ioctl
 
static fo_poll_t kqueue_poll
 
static fo_kqfilter_t kqueue_kqfilter
 
static fo_stat_t kqueue_stat
 
static fo_close_t kqueue_close
 
static struct fileops kqueueops
 
static struct filterops file_filtops
 
static struct filterops kqread_filtops
 
static struct filterops proc_filtops
 
static struct filterops timer_filtops
 
static struct filterops user_filtops
 
static uma_zone_t knote_zone
 
static int kq_ncallouts = 0
 
static int kq_calloutmax = (4 * 1024)
 
struct filterops null_filtops
 
struct filterops sig_filtops
 
struct filterops fs_filtops
 
static struct mtx filterops_lock
 
struct {
   struct filterops *   for_fop
 
   int   for_refcnt
 
sysfilt_ops [EVFILT_SYSCOUNT]
 
static struct mtx knlist_lock
 

Macro Definition Documentation

#define KN_HASH (   val,
  mask 
)    (((val) ^ (val >> 8)) & (mask))

Definition at line 250 of file kern_event.c.

Referenced by knote_attach(), knote_drop(), and kqueue_register().

#define KN_HASHSIZE   64 /* XXX should be tunable */

Definition at line 249 of file kern_event.c.

Referenced by kqueue_expand().

#define KN_LIST_LOCK (   kn)
Value:
do { \
if (kn->kn_knlist != NULL) \
kn->kn_knlist->kl_lock(kn->kn_knlist->kl_lockarg); \
} while (0)

Definition at line 223 of file kern_event.c.

Referenced by kqueue_register(), and kqueue_scan().

#define KN_LIST_UNLOCK (   kn)
Value:
do { \
if (kn->kn_knlist != NULL) \
kn->kn_knlist->kl_unlock(kn->kn_knlist->kl_lockarg); \
} while (0)

Definition at line 227 of file kern_event.c.

Referenced by kqueue_register(), and kqueue_scan().

#define KNL_ASSERT_LOCK (   knl,
  islocked 
)
Value:
do { \
if (islocked) \
} while (0)
#define KNL_ASSERT_LOCKED(knl)
Definition: kern_event.c:245
#define KNL_ASSERT_UNLOCKED(knl)
Definition: kern_event.c:246

Definition at line 231 of file kern_event.c.

Referenced by knlist_add(), knlist_remove_kq(), and knote().

#define KNL_ASSERT_LOCKED (   knl)    do {} while(0)

Definition at line 245 of file kern_event.c.

Referenced by knlist_cleardel(), and knlist_empty().

#define KNL_ASSERT_UNLOCKED (   knl)    do {} while (0)

Definition at line 246 of file kern_event.c.

Referenced by knlist_cleardel().

#define KNOTE_ACTIVATE (   kn,
  islock 
)
Value:
do { \
if ((islock)) \
mtx_assert(&(kn)->kn_kq->kq_lock, MA_OWNED); \
KQ_LOCK((kn)->kn_kq); \
(kn)->kn_status |= KN_ACTIVE; \
if (((kn)->kn_status & (KN_QUEUED | KN_DISABLED)) == 0) \
if (!(islock)) \
KQ_UNLOCK((kn)->kn_kq); \
} while(0)
#define KQ_LOCK(kq)
Definition: kern_event.c:201
static void knote_enqueue(struct knote *kn)
Definition: kern_event.c:2186
#define KQ_UNLOCK(kq)
Definition: kern_event.c:214

Definition at line 190 of file kern_event.c.

Referenced by filt_procattach(), filt_timerexpire(), knote(), knote_fork(), and kqueue_register().

#define KQ_FLUX_WAKEUP (   kq)
Value:
do { \
if (((kq)->kq_state & KQ_FLUXWAIT) == KQ_FLUXWAIT) { \
(kq)->kq_state &= ~KQ_FLUXWAIT; \
wakeup((kq)); \
} \
} while (0)
void wakeup(void *ident)
Definition: kern_synch.c:378

Definition at line 204 of file kern_event.c.

Referenced by kqueue_scan().

#define KQ_GLOBAL_LOCK (   lck,
  haslck 
)
Value:
do { \
if (!haslck) \
mtx_lock(lck); \
haslck = 1; \
} while (0)

Definition at line 78 of file kern_event.c.

Referenced by kqueue_register(), kqueue_scan(), and kqueue_task().

#define KQ_GLOBAL_UNLOCK (   lck,
  haslck 
)
Value:
do { \
if (haslck) \
mtx_unlock(lck); \
haslck = 0; \
} while (0)

Definition at line 83 of file kern_event.c.

Referenced by kqueue_register(), kqueue_scan(), and kqueue_task().

#define KQ_LOCK (   kq)
#define KQ_NOTOWNED (   kq)
Value:
do { \
mtx_assert(&(kq)->kq_lock, MA_NOTOWNED); \
} while (0)

Definition at line 220 of file kern_event.c.

Referenced by knlist_add(), knote_drop(), kqueue_expand(), and kqueue_scan().

#define KQ_OWNED (   kq)
Value:
do { \
mtx_assert(&(kq)->kq_lock, MA_OWNED); \
} while (0)

Definition at line 217 of file kern_event.c.

Referenced by knote_attach(), knote_dequeue(), knote_enqueue(), kqueue_release(), kqueue_scan(), kqueue_schedtask(), and kqueue_wakeup().

#define KQ_UNLOCK (   kq)
#define KQ_UNLOCK_FLUX (   kq)
Value:
do { \
mtx_unlock(&(kq)->kq_lock); \
} while (0)
#define KQ_FLUX_WAKEUP(kq)
Definition: kern_event.c:204

Definition at line 210 of file kern_event.c.

Referenced by knote(), knote_drop(), knote_fdclose(), knote_fork(), kqueue_register(), and kqueue_scan().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static int filt_fileattach ( struct knote kn)
static

Definition at line 296 of file kern_event.c.

static void filt_kqdetach ( struct knote kn)
static

Definition at line 319 of file kern_event.c.

References knlist_remove().

Here is the call graph for this function:

static int filt_kqueue ( struct knote kn,
long  hint 
)
static

Definition at line 328 of file kern_event.c.

static int filt_nullattach ( struct knote kn)
static

Definition at line 253 of file kern_event.c.

static int filt_proc ( struct knote kn,
long  hint 
)
static

Definition at line 409 of file kern_event.c.

References knlist_remove_inevent().

Referenced by filt_procattach().

Here is the call graph for this function:

Here is the caller graph for this function:

static int filt_procattach ( struct knote kn)
static

Definition at line 338 of file kern_event.c.

References filt_proc(), knlist_add(), KNOTE_ACTIVATE, p_cansee(), pfind(), and zpfind().

Here is the call graph for this function:

static void filt_procdetach ( struct knote kn)
static

Definition at line 398 of file kern_event.c.

References knlist_remove().

Here is the call graph for this function:

static int filt_timer ( struct knote kn,
long  hint 
)
static

Definition at line 597 of file kern_event.c.

static int filt_timerattach ( struct knote kn)
static

Definition at line 562 of file kern_event.c.

References callout_init(), filt_timerexpire(), kq_calloutmax, kq_ncallouts, malloc(), and timertoticks().

Here is the call graph for this function:

static void filt_timerdetach ( struct knote kn)
static

Definition at line 585 of file kern_event.c.

References free(), and kq_ncallouts.

Here is the call graph for this function:

static void filt_timerexpire ( void *  knx)
static

Definition at line 536 of file kern_event.c.

References knote(), KNOTE_ACTIVATE, and timertoticks().

Referenced by filt_timerattach().

Here is the call graph for this function:

Here is the caller graph for this function:

static int filt_user ( struct knote kn,
long  hint 
)
static
static int filt_user ( struct knote kn,
__unused long  hint 
)
static

Definition at line 628 of file kern_event.c.

static int filt_userattach ( struct knote kn)
static

Definition at line 604 of file kern_event.c.

static void filt_userdetach ( struct knote kn)
static
static void filt_userdetach ( __unused struct knote kn)
static

Definition at line 619 of file kern_event.c.

static void filt_usertouch ( struct knote kn,
struct kevent *  kev,
u_long  type 
)
static

Definition at line 635 of file kern_event.c.

References panic().

Here is the call graph for this function:

int kern_kevent ( struct thread *  td,
int  fd,
int  nchanges,
int  nevents,
struct kevent_copyops *  k_ops,
const struct timespec *  timeout 
)

Definition at line 823 of file kern_event.c.

References fget(), kqueue_acquire(), kqueue_register(), kqueue_release(), and kqueue_scan().

Referenced by sys_kevent().

Here is the call graph for this function:

Here is the caller graph for this function:

static int kevent_copyin ( void *  arg,
struct kevent *  kevp,
int  count 
)
static

Definition at line 808 of file kern_event.c.

References kevent_args::changelist, and count.

Referenced by sys_kevent().

Here is the caller graph for this function:

static int kevent_copyout ( void *  arg,
struct kevent *  kevp,
int  count 
)
static

Definition at line 790 of file kern_event.c.

References count, and kevent_args::eventlist.

Referenced by sys_kevent().

Here is the caller graph for this function:

void knlist_add ( struct knlist *  knl,
struct knote kn,
int  islocked 
)
void knlist_cleardel ( struct knlist *  knl,
struct thread *  td,
int  islocked,
int  killkn 
)

Definition at line 2023 of file kern_event.c.

References KNL_ASSERT_LOCKED, KNL_ASSERT_UNLOCKED, knlist_remove_kq(), knote(), knote_drop(), KQ_LOCK, and KQ_UNLOCK.

Here is the call graph for this function:

void knlist_destroy ( struct knlist *  knl)

Definition at line 2002 of file kern_event.c.

References printf().

Referenced by destroy_vpollinfo_free(), exit1(), kqueue_close(), mqueue_free(), pipeclose(), ptsdrv_free(), sofree(), and tty_dealloc().

Here is the call graph for this function:

Here is the caller graph for this function:

int knlist_empty ( struct knlist *  knl)

Definition at line 1927 of file kern_event.c.

References KNL_ASSERT_LOCKED.

Referenced by filt_aiodetach(), filt_liodetach(), filt_sordetach(), filt_sowdetach(), kqueue_close(), and kqueue_wakeup().

Here is the caller graph for this function:

void knlist_init ( struct knlist *  knl,
void *  lock,
void(*)(void *)  kl_lock,
void(*)(void *)  kl_unlock,
void(*)(void *)  kl_assert_locked,
void(*)(void *)  kl_assert_unlocked 
)

Definition at line 1964 of file kern_event.c.

References knlist_lock, knlist_mtx_assert_locked(), knlist_mtx_assert_unlocked(), knlist_mtx_lock(), and knlist_mtx_unlock().

Referenced by knlist_init_mtx(), and v_addpollinfo().

Here is the call graph for this function:

Here is the caller graph for this function:

void knlist_init_mtx ( struct knlist *  knl,
struct mtx *  lock 
)

Definition at line 1995 of file kern_event.c.

References knlist_init().

Referenced by aio_aqueue(), do_pipe(), fork1(), kern_lio_listio(), log_drvinit(), mqueue_alloc(), proc0_init(), pts_alloc(), pts_alloc_external(), socreate(), sonewconn(), sys_kqueue(), tty_alloc_mutex(), and vfs_event_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void knlist_mtx_assert_locked ( void *  arg)
static

Definition at line 1952 of file kern_event.c.

Referenced by knlist_init().

Here is the caller graph for this function:

static void knlist_mtx_assert_unlocked ( void *  arg)
static

Definition at line 1958 of file kern_event.c.

Referenced by knlist_init().

Here is the caller graph for this function:

static void knlist_mtx_lock ( void *  arg)
static

Definition at line 1940 of file kern_event.c.

Referenced by knlist_init().

Here is the caller graph for this function:

static void knlist_mtx_unlock ( void *  arg)
static

Definition at line 1946 of file kern_event.c.

Referenced by knlist_init().

Here is the caller graph for this function:

void knlist_remove ( struct knlist *  knl,
struct knote kn,
int  islocked 
)
void knlist_remove_inevent ( struct knlist *  knl,
struct knote kn 
)

Definition at line 1919 of file kern_event.c.

References knlist_remove_kq().

Referenced by filt_proc().

Here is the call graph for this function:

Here is the caller graph for this function:

static void knlist_remove_kq ( struct knlist *  knl,
struct knote kn,
int  knlislocked,
int  kqislocked 
)
static

Definition at line 1884 of file kern_event.c.

References KNL_ASSERT_LOCK, knote(), KQ_LOCK, and KQ_UNLOCK.

Referenced by knlist_cleardel(), knlist_remove(), and knlist_remove_inevent().

Here is the call graph for this function:

Here is the caller graph for this function:

void knote ( struct knlist *  list,
long  hint,
int  lockflags 
)
static struct knote * knote_alloc ( int  waitok)
static

Definition at line 2222 of file kern_event.c.

References knote(), and knote_zone.

Referenced by kqueue_register(), and kqueue_scan().

Here is the call graph for this function:

Here is the caller graph for this function:

static int knote_attach ( struct knote kn,
struct kqueue *  kq 
)
static

Definition at line 2125 of file kern_event.c.

References KN_HASH, and KQ_OWNED.

Referenced by kqueue_register().

Here is the caller graph for this function:

static void knote_dequeue ( struct knote kn)
static

Definition at line 2200 of file kern_event.c.

References KQ_OWNED.

Referenced by knote_drop().

Here is the caller graph for this function:

static void knote_drop ( struct knote kn,
struct thread *  td 
)
static

Definition at line 2153 of file kern_event.c.

References KN_HASH, knote(), knote_dequeue(), knote_free(), KQ_LOCK, KQ_NOTOWNED, KQ_UNLOCK_FLUX, and kqueue_fo_release().

Referenced by knlist_cleardel(), knote_fdclose(), kqueue_close(), kqueue_register(), and kqueue_scan().

Here is the call graph for this function:

Here is the caller graph for this function:

static void knote_enqueue ( struct knote kn)
static

Definition at line 2186 of file kern_event.c.

References KQ_OWNED, and kqueue_wakeup().

Referenced by kqueue_register().

Here is the call graph for this function:

Here is the caller graph for this function:

void knote_fdclose ( struct thread *  td,
int  fd 
)

Definition at line 2084 of file kern_event.c.

References knote(), knote_drop(), KQ_LOCK, KQ_UNLOCK, KQ_UNLOCK_FLUX, and wakeup().

Referenced by do_dup(), fdcloseexec(), kern_close(), and setugidsafety().

Here is the call graph for this function:

Here is the caller graph for this function:

void knote_fork ( struct knlist *  list,
int  pid 
)

Definition at line 452 of file kern_event.c.

References knote(), KNOTE_ACTIVATE, KQ_LOCK, KQ_UNLOCK, KQ_UNLOCK_FLUX, and kqueue_register().

Referenced by do_fork().

Here is the call graph for this function:

Here is the caller graph for this function:

static void knote_free ( struct knote kn)
static

Definition at line 2229 of file kern_event.c.

References knote_zone.

Referenced by knote_drop(), kqueue_register(), and kqueue_scan().

Here is the caller graph for this function:

static void knote_init ( void  )
static

Definition at line 2213 of file kern_event.c.

References knote(), and knote_zone.

Here is the call graph for this function:

int kqfd_register ( int  fd,
struct kevent *  kev,
struct thread *  td,
int  waitok 
)

Definition at line 2239 of file kern_event.c.

References fget(), kqueue_acquire(), kqueue_register(), and kqueue_release().

Referenced by aio_aqueue(), and kern_lio_listio().

Here is the call graph for this function:

Here is the caller graph for this function:

static int kqueue_acquire ( struct file *  fp,
struct kqueue **  kqp 
)
static

Definition at line 1185 of file kern_event.c.

References KQ_LOCK, and KQ_UNLOCK.

Referenced by kern_kevent(), kqfd_register(), kqueue_close(), and kqueue_poll().

Here is the caller graph for this function:

int kqueue_add_filteropts ( int  filt,
struct filterops *  filtops 
)

Definition at line 881 of file kern_event.c.

References filterops_lock, for_fop, null_filtops, printf(), and sysfilt_ops.

Referenced by aio_onceonly().

Here is the call graph for this function:

Here is the caller graph for this function:

static int kqueue_close ( struct file *  fp,
struct thread *  td 
)
static

Definition at line 1670 of file kern_event.c.

References free(), funsetown(), knlist_destroy(), knlist_empty(), knote(), knote_drop(), KQ_LOCK, KQ_UNLOCK, kqueue_acquire(), mtx_destroy(), seldrain(), and selwakeuppri().

Here is the call graph for this function:

int kqueue_del_filteropts ( int  filt)

Definition at line 906 of file kern_event.c.

References filterops_lock, for_fop, for_refcnt, null_filtops, and sysfilt_ops.

Referenced by aio_unload().

Here is the caller graph for this function:

static int kqueue_expand ( struct kqueue *  kq,
struct filterops *  fops,
uintptr_t  ident,
int  waitok 
)
static

Definition at line 1245 of file kern_event.c.

References fd, free(), hashinit(), KN_HASHSIZE, KQ_LOCK, KQ_NOTOWNED, KQ_UNLOCK, and malloc().

Referenced by kqueue_register().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct filterops * kqueue_fo_find ( int  filt)
static

Definition at line 930 of file kern_event.c.

References filterops_lock, for_fop, null_filtops, and sysfilt_ops.

Referenced by kqueue_register().

Here is the caller graph for this function:

static void kqueue_fo_release ( int  filt)
static

Definition at line 946 of file kern_event.c.

References filterops_lock, for_refcnt, and sysfilt_ops.

Referenced by knote_drop(), and kqueue_register().

Here is the caller graph for this function:

static int kqueue_ioctl ( struct file *  fp,
u_long  cmd,
void *  data,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 1577 of file kern_event.c.

References fgetown(), and fsetown().

Here is the call graph for this function:

static int kqueue_kqfilter ( struct file *  fp,
struct knote kn 
)
static

Definition at line 304 of file kern_event.c.

References knlist_add(), and kqread_filtops.

Here is the call graph for this function:

static int kqueue_poll ( struct file *  fp,
int  events,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 1625 of file kern_event.c.

References KQ_LOCK, KQ_UNLOCK, kqueue_acquire(), kqueue_release(), and selrecord().

Here is the call graph for this function:

static int kqueue_read ( struct file *  fp,
struct uio *  uio,
struct ucred *  active_cred,
int  flags,
struct thread *  td 
)
static

Definition at line 1552 of file kern_event.c.

static int kqueue_register ( struct kqueue *  kq,
struct kevent *  kev,
struct thread *  td,
int  waitok 
)
static
static void kqueue_release ( struct kqueue *  kq,
int  locked 
)
static

Definition at line 1208 of file kern_event.c.

References KQ_LOCK, KQ_OWNED, KQ_UNLOCK, and wakeup().

Referenced by kern_kevent(), kqfd_register(), and kqueue_poll().

Here is the call graph for this function:

Here is the caller graph for this function:

static int kqueue_scan ( struct kqueue *  kq,
int  maxevents,
struct kevent_copyops *  k_ops,
const struct timespec *  timeout,
struct kevent *  keva,
struct thread *  td 
)
static

Definition at line 1334 of file kern_event.c.

References count, getmicrouptime(), hz, itimerfix(), KN_LIST_LOCK, KN_LIST_UNLOCK, knote(), knote_alloc(), knote_drop(), knote_free(), KQ_FLUX_WAKEUP, kq_global, KQ_GLOBAL_LOCK, KQ_GLOBAL_UNLOCK, KQ_LOCK, KQ_NOTOWNED, KQ_OWNED, KQ_UNLOCK, KQ_UNLOCK_FLUX, start, timeout(), timevaladd(), timevalsub(), and tvtohz().

Referenced by kern_kevent().

Here is the call graph for this function:

Here is the caller graph for this function:

static void kqueue_schedtask ( struct kqueue *  kq)
static

Definition at line 1222 of file kern_event.c.

References KQ_OWNED, and taskqueue_enqueue().

Referenced by kqueue_wakeup().

Here is the call graph for this function:

Here is the caller graph for this function:

static int kqueue_stat ( struct file *  fp,
struct stat *  st,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 1652 of file kern_event.c.

static void kqueue_task ( void *  arg,
int  pending 
)
static

Definition at line 1308 of file kern_event.c.

References kq_global, KQ_GLOBAL_LOCK, KQ_GLOBAL_UNLOCK, KQ_LOCK, KQ_UNLOCK, and wakeup().

Referenced by sys_kqueue().

Here is the call graph for this function:

Here is the caller graph for this function:

static int kqueue_truncate ( struct file *  fp,
off_t  length,
struct ucred *  active_cred,
struct thread *  td 
)
static

Definition at line 1568 of file kern_event.c.

static void kqueue_wakeup ( struct kqueue *  kq)
static

Definition at line 1777 of file kern_event.c.

References knlist_empty(), KQ_OWNED, kqueue_schedtask(), pgsigio(), selwakeuppri(), and wakeup().

Referenced by knote_enqueue().

Here is the call graph for this function:

Here is the caller graph for this function:

static int kqueue_write ( struct file *  fp,
struct uio *  uio,
struct ucred *  active_cred,
int  flags,
struct thread *  td 
)
static

Definition at line 1560 of file kern_event.c.

static MALLOC_DEFINE ( M_KQUEUE  ,
"kqueue"  ,
"memory for kqueue system"   
)
static
MTX_SYSINIT ( kq_global  ,
kq_global,
"kqueue order"  ,
MTX_DEF   
)
MTX_SYSINIT ( kqueue_filterops  ,
filterops_lock,
"protect sysfilt_ops ,
MTX_DEF   
)
MTX_SYSINIT ( knlist_lock  ,
knlist_lock,
"knlist lock for lockless objects"  ,
MTX_DEF   
)
int sys_kevent ( struct thread *  td,
struct kevent_args uap 
)
int sys_kqueue ( struct thread *  td,
struct kqueue_args *  uap 
)

Definition at line 692 of file kern_event.c.

References falloc(), fd, finit(), knlist_init_mtx(), kqueue_task(), kqueueops, malloc(), and mtx_init().

Here is the call graph for this function:

SYSCTL_INT ( _kern  ,
OID_AUTO  ,
kq_calloutmax  ,
CTLFLAG_RW  ,
kq_calloutmax,
,
"Maximum number of callouts allocated for kqueue"   
)
SYSINIT ( knote  ,
SI_SUB_PSEUDO  ,
SI_ORDER_ANY  ,
knote_init  ,
NULL   
)
TASKQUEUE_DEFINE_THREAD ( kqueue  )
static int timertoticks ( intptr_t  data)
static

Definition at line 523 of file kern_event.c.

References tvtohz().

Referenced by filt_timerattach(), and filt_timerexpire().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

struct filterops file_filtops
static
Initial value:
= {
.f_isfd = 1,
.f_attach = filt_fileattach,
}
static int filt_fileattach(struct knote *kn)
Definition: kern_event.c:296

Definition at line 154 of file kern_event.c.

struct mtx filterops_lock
static
struct filterops* for_fop

Definition at line 275 of file kern_event.c.

Referenced by kqueue_add_filteropts(), kqueue_del_filteropts(), and kqueue_fo_find().

int for_refcnt

Definition at line 276 of file kern_event.c.

Referenced by kqueue_del_filteropts(), and kqueue_fo_release().

struct filterops fs_filtops

Definition at line 4419 of file vfs_subr.c.

struct mtx knlist_lock
static

Definition at line 1933 of file kern_event.c.

Referenced by knlist_init().

uma_zone_t knote_zone
static

Definition at line 183 of file kern_event.c.

Referenced by knote_alloc(), knote_free(), and knote_init().

int kq_calloutmax = (4 * 1024)
static

Definition at line 185 of file kern_event.c.

Referenced by filt_timerattach().

struct mtx kq_global
static

Definition at line 76 of file kern_event.c.

Referenced by kqueue_register(), kqueue_scan(), and kqueue_task().

int kq_ncallouts = 0
static

Definition at line 184 of file kern_event.c.

Referenced by filt_timerattach(), and filt_timerdetach().

struct filterops kqread_filtops
static
Initial value:
= {
.f_isfd = 1,
.f_detach = filt_kqdetach,
.f_event = filt_kqueue,
}
static void filt_kqdetach(struct knote *kn)
Definition: kern_event.c:319
static int filt_kqueue(struct knote *kn, long hint)
Definition: kern_event.c:328

Definition at line 158 of file kern_event.c.

Referenced by kqueue_kqfilter().

fo_close_t kqueue_close
static

Definition at line 115 of file kern_event.c.

fo_ioctl_t kqueue_ioctl
static

Definition at line 111 of file kern_event.c.

fo_kqfilter_t kqueue_kqfilter
static

Definition at line 113 of file kern_event.c.

fo_poll_t kqueue_poll
static

Definition at line 112 of file kern_event.c.

fo_rdwr_t kqueue_read
static

Definition at line 108 of file kern_event.c.

fo_stat_t kqueue_stat
static

Definition at line 114 of file kern_event.c.

fo_truncate_t kqueue_truncate
static

Definition at line 110 of file kern_event.c.

fo_rdwr_t kqueue_write
static

Definition at line 109 of file kern_event.c.

struct fileops kqueueops
static
Initial value:
= {
.fo_read = kqueue_read,
.fo_write = kqueue_write,
.fo_truncate = kqueue_truncate,
.fo_ioctl = kqueue_ioctl,
.fo_poll = kqueue_poll,
.fo_kqfilter = kqueue_kqfilter,
.fo_stat = kqueue_stat,
.fo_close = kqueue_close,
.fo_chmod = invfo_chmod,
.fo_chown = invfo_chown,
}
int invfo_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td)
static fo_stat_t kqueue_stat
Definition: kern_event.c:114
static fo_truncate_t kqueue_truncate
Definition: kern_event.c:110
int invfo_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, struct thread *td)
static fo_kqfilter_t kqueue_kqfilter
Definition: kern_event.c:113
static fo_close_t kqueue_close
Definition: kern_event.c:115
static fo_rdwr_t kqueue_write
Definition: kern_event.c:109
static fo_ioctl_t kqueue_ioctl
Definition: kern_event.c:111
static fo_poll_t kqueue_poll
Definition: kern_event.c:112
static fo_rdwr_t kqueue_read
Definition: kern_event.c:108

Definition at line 117 of file kern_event.c.

Referenced by sys_kqueue().

struct filterops null_filtops
Initial value:
= {
.f_isfd = 0,
.f_attach = filt_nullattach,
}
static int filt_nullattach(struct knote *kn)
Definition: kern_event.c:253

Definition at line 259 of file kern_event.c.

Referenced by kqueue_add_filteropts(), kqueue_del_filteropts(), and kqueue_fo_find().

struct filterops proc_filtops
static
Initial value:
= {
.f_isfd = 0,
.f_attach = filt_procattach,
.f_detach = filt_procdetach,
.f_event = filt_proc,
}
static int filt_proc(struct knote *kn, long hint)
Definition: kern_event.c:409
static int filt_procattach(struct knote *kn)
Definition: kern_event.c:338
static void filt_procdetach(struct knote *kn)
Definition: kern_event.c:398

Definition at line 164 of file kern_event.c.

struct filterops sig_filtops

Definition at line 118 of file kern_sig.c.

struct { ... } sysfilt_ops[EVFILT_SYSCOUNT]
Initial value:
= {
{ &file_filtops },
{ &file_filtops },
{ &null_filtops },
{ &file_filtops },
{ &proc_filtops },
{ &sig_filtops },
{ &null_filtops },
{ &fs_filtops },
{ &null_filtops },
{ &user_filtops },
}
struct filterops fs_filtops
Definition: vfs_subr.c:4419
static struct filterops user_filtops
Definition: kern_event.c:176
static struct filterops timer_filtops
Definition: kern_event.c:170
struct filterops null_filtops
Definition: kern_event.c:259
struct filterops sig_filtops
Definition: kern_sig.c:118
static struct filterops file_filtops
Definition: kern_event.c:154
static struct filterops proc_filtops
Definition: kern_event.c:164

Referenced by kqueue_add_filteropts(), kqueue_del_filteropts(), kqueue_fo_find(), and kqueue_fo_release().

struct filterops timer_filtops
static
Initial value:
= {
.f_isfd = 0,
.f_attach = filt_timerattach,
.f_detach = filt_timerdetach,
.f_event = filt_timer,
}
static int filt_timerattach(struct knote *kn)
Definition: kern_event.c:562
static int filt_timer(struct knote *kn, long hint)
Definition: kern_event.c:597
static void filt_timerdetach(struct knote *kn)
Definition: kern_event.c:585

Definition at line 170 of file kern_event.c.

struct filterops user_filtops
static
Initial value:
= {
.f_attach = filt_userattach,
.f_detach = filt_userdetach,
.f_event = filt_user,
.f_touch = filt_usertouch,
}
static int filt_user(struct knote *kn, long hint)
static int filt_userattach(struct knote *kn)
Definition: kern_event.c:604
static void filt_userdetach(struct knote *kn)
static void filt_usertouch(struct knote *kn, struct kevent *kev, u_long type)
Definition: kern_event.c:635

Definition at line 176 of file kern_event.c.