HomeFreeBSD

linux: make timerfd_settime(2) set expirations count to zero

Description

linux: make timerfd_settime(2) set expirations count to zero

On Linux, read(2) from a timerfd file descriptor returns an unsigned
8-byte integer (uint64_t) containing the number of expirations
that have occurred, if the timer has already expired one or more
times since its settings were last modified using timerfd_settime(),
or since the last successful read(2). That's to say, once we do
a read or call timerfd_settime(), timer fd's expiration count should
be zero. Some Linux applications create timerfd and add it to epoll
with LT mode, when event comes, they do timerfd_settime instead
of read to stop event source from trigger. On FreeBSD,
timerfd_settime(2) didn't set the count to zero, which caused high
CPU utilization.

PR: 252820
Submitted by: ankohuu_outlook.com (Shunchao Hu)
Differential Revision: https://reviews.freebsd.org/D28231

(cherry picked from commit ae71b794cbed19e5e25effc3438720ad452ab87c)

Details

Provenance
ankohuu_outlook.comAuthored on Feb 3 2021, 4:51 PM
dchaginCommitted on Mar 21 2021, 7:03 AM
Differential Revision
D28231: linux_timerfd_settime set expirations count to zero
Parents
rG2c31ae65cd92: Merge tcsh 6.22.03-ceccc7f
Branches
Unknown
Tags
Unknown