参照元†
- wait_queue_head_t *q
- unsigned int mode
- int nr_exclusive
- int wake_flags
- void *key
返り値†
- curr->func の初期化は下記の関数で行われることが多い。
- 例えば poll の場合、__pollwait でこの関数が呼ばれ、func には pollwake 関数を指定している。
$ grep -r init_waitqueue_func_entry
drivers/vfio/virqfd.c: init_waitqueue_func_entry(&virqfd->wait, virqfd_wakeup);
drivers/staging/android/sync.c: init_waitqueue_func_entry(&waiter->work, sync_fence_wake_up_wq);
drivers/vhost/vhost.c: init_waitqueue_func_entry(&poll->wait, vhost_poll_wakeup);
mm/memcontrol.c: init_waitqueue_func_entry(&event->wait, memcg_event_wake);
net/unix/af_unix.c: init_waitqueue_func_entry(&u->peer_wake, unix_dgram_peer_wake_relay);
net/9p/trans_fd.c: init_waitqueue_func_entry(&pwait->wait, p9_pollwake);
fs/select.c: init_waitqueue_func_entry(&entry->wait, pollwake);
fs/cachefiles/rdwr.c: init_waitqueue_func_entry(&monitor->monitor, cachefiles_read_waiter);
fs/cachefiles/rdwr.c: init_waitqueue_func_entry(&monitor->monitor,
fs/eventpoll.c: init_waitqueue_func_entry(&pwq->wait, ep_poll_callback);
fs/userfaultfd.c: init_waitqueue_func_entry(&uwq.wq, userfaultfd_wake_function);
kernel/exit.c: init_waitqueue_func_entry(&wo->child_wait, child_wait_callback);
virt/kvm/eventfd.c: init_waitqueue_func_entry(&irqfd->wait, irqfd_wakeup);
include/linux/wait.h:init_waitqueue_func_entry(wait_queue_t *q, wait_queue_func_t func)
$ grep -r -b1 init_waitqueue_func_entry fs/cachefiles/rdwr.c
6617-
6618: init_waitqueue_func_entry(&monitor->monitor, cachefiles_read_waiter);
6689-
--
12906- monitor->op = fscache_get_retrieval(op);
12950: init_waitqueue_func_entry(&monitor->monitor,
12998- cachefiles_read_waiter);
/*
* The core wakeup function. Non-exclusive wakeups (nr_exclusive == 0) just
* wake everything up. If it's an exclusive wakeup (nr_exclusive == small +ve
* number) then we wake all the non-exclusive tasks and one exclusive task.
*
* There are circumstances in which we can try to wake a task which has already
* started to run but is not in state TASK_RUNNING. try_to_wake_up() returns
* zero in this (rare) case, and we handle it by continuing to scan the queue.
*/
static void __wake_up_common(wait_queue_head_t *q, unsigned int mode,
int nr_exclusive, int wake_flags, void *key)
{
wait_queue_t *curr, *next;
list_for_each_entry_safe(curr, next, &q->task_list, task_list) {
unsigned flags = curr->flags;
if (curr->func(curr, mode, wake_flags, key) &&
(flags & WQ_FLAG_EXCLUSIVE) && !--nr_exclusive)
break;
- func の初期化は下記の関数で行われることが多い。
}
}
コメント†