Re: [PATCH] poll: Avoid extra wakeups in select/poll

From: Ingo Molnar
Date: Wed Apr 29 2009 - 05:17:50 EST



* Eric Dumazet <dada1@xxxxxxxxxxxxx> wrote:

> @@ -418,8 +429,16 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
> if (file) {
> f_op = file->f_op;
> mask = DEFAULT_POLLMASK;
> - if (f_op && f_op->poll)
> + if (f_op && f_op->poll) {
> + if (wait) {
> + wait->key = POLLEX_SET;
> + if (in & bit)
> + wait->key |= POLLIN_SET;
> + if (out & bit)
> + wait->key |= POLLOUT_SET;
> + }
> mask = (*f_op->poll)(file, retval ? NULL : wait);
> + }
> fput_light(file, fput_needed);
> if ((mask & POLLIN_SET) && (in & bit)) {
> res_in |= bit;

Please factor this whole 'if (file)' branch out into a helper.
Typical indentation levels go from 1 to 3 tabs - 4 should be avoided
if possible and 5 is pretty excessive already. This goes to eight.

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/