Skip to contentSkip to conversation

when and where does ep_poll_callback be called ?

DISCUSSION horseriver 3 participants 4 messages Jan 14, 2013 – Mar 13, 2013

Subsystems (3)
lore
Share & tools
lore

horseriver

author
#0 lore raw

hi:

I'm studying the epoll module , I can not find ep_poll_callback be called somewhere .

thanks!

#1 lore raw
Quoted 4 lines · horseriver

hi:

I'm studying the epoll module , I can not find ep_poll_callback be called somewhere .

It's right there in fs/eventpoll.c:

/*
* This is the callback that is used to add our wait queue to the
* target file wakeup lists.
*/
static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
poll_table *pt)

{
	struct epitem *epi = ep_item_from_epqueue(pt);
	struct eppoll_entry *pwq;

	if (epi->nwait >= 0 && (pwq = kmem_cache_alloc(pwq_cache, GFP_KERNEL))) {
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
		init_waitqueue_func_entry(&pwq->wait, ep_poll_callback);
		pwq->whead = whead;
		pwq->base = epi;
		add_wait_queue(whead, &pwq->wait);
		list_add_tail(&pwq->llink, &epi->pwqlist);
		epi->nwait++;
Signature · 1 line
~Randy
author
#2 lore raw
Quoted 16 lines · Randy Dunlap
Quoted 4 lines · horseriver

hi:

I'm studying the epoll module , I can not find ep_poll_callback be called somewhere .

It's right there in fs/eventpoll.c:

/*
* This is the callback that is used to add our wait queue to the
* target file wakeup lists.
*/
static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
poll_table *pt)

Quoted 6 lines
{
	struct epitem *epi = ep_item_from_epqueue(pt);
	struct eppoll_entry *pwq;

	if (epi->nwait >= 0 && (pwq = kmem_cache_alloc(pwq_cache, GFP_KERNEL))) {
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
		init_waitqueue_func_entry(&pwq->wait, ep_poll_callback);

Thanks!

I know this is setting the callbak function into watqueue . But not the called place .

I want to know the code which calls ep_poll_callback .

Perhaps , it is called at tcp layer when a datagram is reached . but I have not find that key code .

Quoted 10 lines
		pwq->whead = whead;
		pwq->base = epi;
		add_wait_queue(whead, &pwq->wait);
		list_add_tail(&pwq->llink, &epi->pwqlist);
		epi->nwait++;
Signature · 1 line
~Randy
#3 lore raw
In reply to horseriver
Quoted 6 lines · horseriver

hi:

I'm studying the epoll module , I can not find ep_poll_callback be called somewhere .

Thats more a lkml question.

But you can figure it yourself :

fs/eventpoll.c +1 -0
index 9fec183..c6e7490 100644
@@ -928,6 +928,7 @@ static int ep_poll_callback(wait_queue_t *wait, unsigned mode, int sync, void *k
 	struct epitem *epi = ep_item_from_wait(wait);
 	struct eventpoll *ep = epi->ep;
 
+	WARN_ON_ONCE(1);
 	if ((unsigned long)key & POLLFREE) {
 		ep_pwq_from_wait(wait)->whead = NULL;
 		/*