Project

General

Profile

Feature #12902

epoll should nominally support EPOLLEXCLUSIVE

Added by Patrick Mooney 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Category:
kernel
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

As of version 4.5, Linux as supported the EPOLLEXCLUSIVE flag on events. The man page describes it as such:

Sets an exclusive wakeup mode for the epoll file descriptor that is being attached to the target file descriptor, fd. When a wakeup event occurs and multiple epoll file descriptors are attached to the same target file using EPOLLEXCLUSIVE, one or more of the epoll file descriptors will receive an event with epoll_wait(2). The default in this scenario (when EPOLLEXCLUSIVE is not set) is for all epoll file descriptors to receive an event. EPOLLEXCLUSIVE is thus useful for avoiding thundering herd problems in certain scenarios.

If the same file descriptor is in multiple epoll instances, some with the EPOLLEXCLUSIVE flag, and others without, then events will be provided to all epoll instances that did not specify EPOLLEXCLUSIVE, and at least one of the epoll instances that did specify EPOLLEXCLUSIVE.

That final sentence gives us an escape hatch, since it seems that implementing EPOLLEXCLUSIVE as a no-op would still be correct within the semantics.

Until someone is compelled to implement the full functionality, we should at least provide the same header definition and error handling . (Later parts of the man page describe extra input verification with EPOLLEXCLUSIVE set.)

History

#1

Updated by Patrick Mooney 3 months ago

  • Description updated (diff)
#2

Updated by Patrick Mooney 3 months ago

Prior to integration of the change, a run of the latest epoll-test-suite (which passes this test on modern Linux) shows errors:

test_exclusive  0       TWARN: EPOLLEXCLUSIVE not defined
test_exclusive  0       TPASS
test_exclusive  1       TPASS
test_exclusive  2       TFAIL: 0 != -1
test_exclusive  3       TFAIL: 0 != 22
test_exclusive  4       TPASS
test_exclusive  5       TPASS
test_exclusive  6       TPASS
test_exclusive  7       TPASS

#3

Updated by Patrick Mooney 3 months ago

With the proposed fix, the test runs clean:

test_exclusive  0       TPASS
test_exclusive  1       TPASS
test_exclusive  2       TPASS
test_exclusive  3       TPASS
test_exclusive  4       TPASS
test_exclusive  5       TPASS
test_exclusive  6       TPASS
test_exclusive  7       TPASS

#4

Updated by Electric Monk 3 months ago

  • Gerrit CR set to 766
#5

Updated by Patrick Mooney 3 months ago

It should be noted that there were no regressions in any of the other epoll tests when checking the proposed fix.

#6

Updated by Electric Monk 3 months ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit 66373fa702508a0a41753138f0b10f985c7e058d

commit  66373fa702508a0a41753138f0b10f985c7e058d
Author: Patrick Mooney <pmooney@pfmooney.com>
Date:   2020-07-08T15:06:27.000Z

    12902 epoll should nominally support EPOLLEXCLUSIVE
    Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
    Reviewed by: Mike Zeller <mike.zeller@joyent.com>
    Approved by: Dan McDonald <danmcd@joyent.com>

Also available in: Atom PDF