*参照元 [#l24a4776] #backlinks *説明 [#y7ba5e4f] -パス: [[linux-4.4.1/kernel/sched/wait.c]] -FIXME: これは何? --説明 **引数 [#r305c8ce] -wait_queue_head_t *q -- --[[linux-4.4.1/wait_queue_head_t]] -unsigned int mode -- -int nr_exclusive -- -int wake_flags -- -void *key -- **返り値 [#r8eaf1a9] -なし **参考 [#xe1404d5] -curr->func の初期化は下記の関数で行われることが多い。 --[[linux-4.4.1/init_waitqueue_func_entry()]] -例えば 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); -各 wakeup 関数へのリンク --[[linux-4.4.1/virqfd_wakeup()]] --[[linux-4.4.1/sync_fence_wake_up_wq()]] --[[linux-4.4.1/vhost_poll_wakeup()]] --[[linux-4.4.1/memcg_event_wake()]] --[[linux-4.4.1/unix_dgram_peer_wake_relay()]] --[[linux-4.4.1/p9_pollwake()]] --[[linux-4.4.1/pollwake()]] --[[linux-4.4.1/cachefiles_read_waiter()]] --[[linux-4.4.1/ep_poll_callback()]] --[[linux-4.4.1/userfaultfd_wake_function()]] --[[linux-4.4.1/child_wait_callback()]] --[[linux-4.4.1/irqfd_wakeup()]] *実装 [#k060cac0] /* * 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; - --[[linux-4.4.1/wait_queue_t]] list_for_each_entry_safe(curr, next, &q->task_list, task_list) { - --[[linux-4.4.1/list_for_each_entry_safe()]] unsigned flags = curr->flags; if (curr->func(curr, mode, wake_flags, key) && (flags & WQ_FLAG_EXCLUSIVE) && !--nr_exclusive) break; - -func の初期化は下記の関数で行われることが多い。 --[[linux-4.4.1/init_waitqueue_func_entry()]] --例えば poll の場合、__pollwait でこの関数が呼ばれる。 --func には pollwake 関数が指定されている。 } } *コメント [#bb9f1f30]