Print this page
8634 epoll fails to wake on certain edge-triggered conditions
8635 epoll should not emit POLLNVAL
8636 recursive epoll should emit EPOLLRDNORM
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man9e/chpoll.9e.man.txt
          +++ new/usr/src/man/man9e/chpoll.9e.man.txt
↓ open down ↓ 99 lines elided ↑ open up ↑
 100  100         the polling discipline itself. The following rules must be followed
 101  101         when implementing the polling discipline:
 102  102  
 103  103             1.     Implement the following algorithm when the chpoll() entry
 104  104                    point is called:
 105  105  
 106  106                      if (specified_events_are_satisfied_now) {
 107  107                            *reventsp = satisfied_events & events;
 108  108                      } else {
 109  109                            *reventsp = 0;
 110      -                          if (!anyyet)
 111      -                                *phpp = &my_local_pollhead_structure;
 112  110                      }
      111 +                    if ((*reventsp == 0 && !anyyet) || (events & POLLET))
      112 +                          *phpp = &my_local_pollhead_structure;
 113  113                      return (0);
 114  114  
      115 +                  Note: Prior to the integration of epoll(5), which included
      116 +                  edge-triggering via the POLLET flag, standard chpoll
      117 +                  mechanisms would only provide a pollhead in phpp if there
      118 +                  were no matching events.  Edge-triggered polling requires
      119 +                  that pollwakeup() always be called for a resource, so if
      120 +                  POLLET is set in the events of interest, the chpoll method
      121 +                  must yield a pollhead and prepare to issue pollwakeup()
      122 +                  calls on it.
 115  123  
      124 +                  Drivers which are not wired up to make pollwakeup() calls on
      125 +                  a pollhead when their status changes should emit one from
      126 +                  their chpoll routine.  This will exclude the resource from
      127 +                  caching by pollers, since it cannot alert them to new events
      128 +                  without pollwakeup() notification.
      129 +
      130 +
 116  131             2.     Allocate an instance of the pollhead structure. This
 117  132                    instance may be tied to the per-minor data structure defined
 118  133                    by the driver. The pollhead structure should be treated as a
 119  134                    "black box" by the driver. Initialize the pollhead structure
 120  135                    by filling it with zeroes. The size of this structure is
 121  136                    guaranteed to remain the same across releases.
 122  137  
 123  138             3.     Call the pollwakeup() function with events listed above
 124  139                    whenever pollable events which the driver should monitor
 125  140                    occur. This function can be called with multiple events at
↓ open down ↓ 31 lines elided ↑ open up ↑
 157  172  
 158  173                    This step is necessary to inform other kernel subsystems
 159  174                    that the memory associated with the pollhead is about to be
 160  175                    deallocated by the close(9E) entry point.
 161  176  
 162  177  
 163  178  RETURN VALUES
 164  179         chpoll() should return 0 for success, or the appropriate error number.
 165  180  
 166  181  SEE ALSO
 167      -       poll(2), nochpoll(9F), pollwakeup(9F)
      182 +       poll(2), epoll(5), nochpoll(9F), pollwakeup(9F)
 168  183  
 169  184  
 170  185         Writing Device Drivers
 171  186  
 172  187  
 173  188  
 174      -                                  May 7, 2008                       CHPOLL(9E)
      189 +                               January 18, 2017                     CHPOLL(9E)
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX