public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* {sys_,/dev/}epoll waiting timeout
@ 2003-01-22  6:55 Lennert Buytenhek
  2003-01-22  8:03 ` Jamie Lokier
  0 siblings, 1 reply; 24+ messages in thread
From: Lennert Buytenhek @ 2003-01-22  6:55 UTC (permalink / raw)
  To: Davide Libenzi; +Cc: linux-kernel

Hi!

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 ]

	etc.

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
kernel/time.c:sys_nanosleep.

Will you accept a patch to do this?


cheers,
Lennert

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2003-01-28 22:00 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-22  6:55 {sys_,/dev/}epoll waiting timeout Lennert Buytenhek
2003-01-22  8:03 ` Jamie Lokier
2003-01-22 12:46   ` Ed Tomlinson
2003-01-22 13:20     ` Jamie Lokier
2003-01-22 19:14       ` Randy.Dunlap
2003-01-22 19:34         ` Jamie Lokier
2003-01-22 19:32           ` Randy.Dunlap
2003-01-23 14:07   ` Davide Libenzi
2003-01-23 15:43     ` Jamie Lokier
2003-01-23 17:27       ` Mark Mielke
2003-01-23 18:28         ` Jamie Lokier
2003-01-23 20:40           ` Mark Mielke
2003-01-23 22:18             ` Jamie Lokier
2003-01-24 14:41               ` Andreas Schwab
2003-01-25  1:08               ` Davide Libenzi
2003-01-27 21:27               ` bug in select() (was Re: {sys_,/dev/}epoll waiting timeout) Bill Rugolsky Jr.
2003-01-27 22:52                 ` Davide Libenzi
2003-01-28  9:45                   ` Jamie Lokier
2003-01-28 10:52                     ` Mark Mielke
2003-01-28 21:39                       ` Jamie Lokier
2003-01-28 22:15                     ` Davide Libenzi
2003-01-28 19:42   ` {sys_,/dev/}epoll waiting timeout Randy.Dunlap
2003-01-28 21:36     ` Jamie Lokier
2003-01-28 21:44       ` David Mosberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox