Skip to contentSkip to conversation

epoll_wait.2: Clarify that the timeout is measured against CLOCK_MONOTONIC

PATCH In review Mike Crowe 2 participants 2 messages Sep 15, 2016 – Sep 20, 2016 1 message not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore

Mike Crowe

author
#0 lore raw

PATCH 1/1 epoll_wait.2: Clarify that the timeout is measured against CLOCK_MONOTONIC

The existing page left the choice of clock as ambiguous. My reading of the kernel implementation is that CLOCK_MONOTONIC is always used since ep_poll calls schedule_hrtimeout_range, which calls schedule_hrtimeout_range_clock passing CLOCK_MONOTONIC.

References:
http://lxr.free-electrons.com/source/fs/eventpoll.c?v=4.7#L1614
http://lxr.free-electrons.com/source/kernel/time/hrtimer.c?v=4.7#L1785

The "measured against" terminology was borrowed from nanosleep.2.

I've checked all the way back to Linux v2.6.12 where the calculation was done using jiffies so I think that this has effectively always been true.

---
 man2/epoll_wait.2 | 3 +++
 1 file changed, 3 insertions(+)
man2/epoll_wait.2 +3 -0
index 9637906..48bb281 100644
@@ -55,6 +55,9 @@ The
 argument specifies the number of milliseconds that
 .BR epoll_wait ()
 will block.
+Time is measured against the
+.B CLOCK_MONOTONIC
+clock.
 The call will block until either:
 .IP * 3
 a file descriptor delivers an event;
Signature · 6 lines
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to a message not in the archive
Quoted 5 lines · Mike Crowe

The existing page left the choice of clock as ambiguous. My reading of the kernel implementation is that CLOCK_MONOTONIC is always used since ep_poll calls schedule_hrtimeout_range, which calls schedule_hrtimeout_range_clock passing CLOCK_MONOTONIC.

Quoted 8 lines

References:
http://lxr.free-electrons.com/source/fs/eventpoll.c?v=4.7#L1614
http://lxr.free-electrons.com/source/kernel/time/hrtimer.c?v=4.7#L1785

The "measured against" terminology was borrowed from nanosleep.2.

I've checked all the way back to Linux v2.6.12 where the calculation was done using jiffies so I think that this has effectively always been true.

Thanks, Mike. I've applied this patch.

Cheers,

Michael

Quoted 20 lines
---
 man2/epoll_wait.2 | 3 +++
 1 file changed, 3 insertions(+)
man2/epoll_wait.2 +3 -0
index 9637906..48bb281 100644
@@ -55,6 +55,9 @@ The
 argument specifies the number of milliseconds that
 .BR epoll_wait ()
 will block.
+Time is measured against the
+.B CLOCK_MONOTONIC
+clock.
 The call will block until either:
 .IP * 3
 a file descriptor delivers an event;
Signature · 7 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html