Skip to contentSkip to conversation

epoll: add a reschedule point in ep_free()

PATCH In review Eric Dumazet 2 participants 2 messages Aug 17, 2013 – Aug 27, 2013 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 epoll: add a reschedule point in ep_free()

From: Eric Dumazet <[email protected]>

ep_free() might iterate on a huge set of epitems and hold cpu too long. Add two cond_resched() in order to yield cpu to other tasks. This is safe as we only hold mutexes in this function.

Cc Al Viro <[email protected]>
Cc Theodore Ts'o <[email protected]>

---
Google-Bug-Id: 8940884

 fs/eventpoll.c |    2 ++
 1 file changed, 2 insertions(+)
fs/eventpoll.c +2 -0
index 9ad17b15..4ff595d 100644
@@ -740,6 +740,7 @@ static void ep_free(struct eventpoll *ep)
 		epi = rb_entry(rbp, struct epitem, rbn);
 
 		ep_unregister_pollwait(ep, epi);
+		cond_resched();
 	}
 
 	/*
@@ -754,6 +755,7 @@ static void ep_free(struct eventpoll *ep)
 	while ((rbp = rb_first(&ep->rbr)) != NULL) {
 		epi = rb_entry(rbp, struct epitem, rbn);
 		ep_remove(ep, epi);
+		cond_resched();
 	}
 	mutex_unlock(&ep->mtx);
 
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Eric Dumazet

From: Eric Dumazet <[email protected]>

ep_free() might iterate on a huge set of epitems and hold cpu too long. Add two cond_resched() in order to yield cpu to other tasks. This is safe as we only hold mutexes in this function.

Cc Al Viro <[email protected]>
Cc Theodore Ts'o <[email protected]>

Seems reasonable. This isn't a remotely hot path and f_op->release runs in a workqueue nowadays (right?).