[lkml]   [2003]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject{sys_,/dev/}epoll waiting timeout

Both /dev/epoll EP_POLL and sys_epoll_wait, when converting the passed
timeout value in msec to jiffies, round down instead of up. This
occasionally causes these functions to return without any active fd's
before the given timeout period has passed.

This can cause fun situations like these:
epoll_wait(epfd, events, maxevents, timeout_until_next_timer_expiry)
[ returns too early ]

gettimeofday(&now, NULL)
[ notice that the first timer has not yet expired, do nothing ]

epoll_wait(epfd, events, maxevents, random_small_value_less_than_jiffy)
[ returns immediately ]

gettimeofday(&now, NULL)
[ notice that first timer still didn't expire yet, do nothing ]


Effectively causing busy-wait loops of on average half a jiffy.

nanosleep(2) always rounds timeout values up (I think it is required to do
so by some specification which says that this call should sleep _at_least_
the given amount of time), and this approach to me makes sense for
{sys_,/dev/}epoll also. See <linux/time.h>:timespec_to_jiffies and

Will you accept a patch to do this?

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:32    [W:0.088 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site