eventfd: support delayed wakeup for non-semaphore eventfd to reduce cpu utilization
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Hillf Danton
On 16 Apr 2023 19:31:55 +0800 Wen Yang <[email protected]>
Quoted 10 lines
For the NON SEMAPHORE eventfd, if it's counter has a nonzero value, then a read(2) returns 8 bytes containing that value, and the counter's value is reset to zero. Therefore, in the NON SEMAPHORE scenario, N
event_writesvs ONEevent_readis possible.However, the current implementation wakes up the read thread immediately in
eventfd_writeso that the cpu utilization increases unnecessarily.By adding a configurable delay after
eventfd_write, these unnecessary wakeup operations are avoided, thereby reducing cpu utilization.
Quoted 10 lines
If the EPOLLOUT wakeup in
eventfd_read()breaks, feel free to specify it in the commit message after updating the comment below.
/*
* Every time that a write(2) is performed on an eventfd, the
* value of the__u64being written is added to "count" and a
* wakeup is performed on "wqh". A read(2) will return the "count"
* value to userspace, and will reset "count" to zero. The kernel
* sideeventfd_signal()also, adds to the "count" counter and
* issue a wakeup.
*/
Thanks
We will modify it according to your suggestion and then send v2 later.
--
Best wishes,
Wen