[tor-bugs] #23711 [Core Tor/Tor]: sched: KIST writes to kernel and get a "wants to write" notification right after

Tor Bug Tracker & Wiki blackhole at torproject.org
Fri Sep 29 16:14:02 UTC 2017

#23711: sched: KIST writes to kernel and get a "wants to write" notification right
     Reporter:  dgoulet       |      Owner:  (none)
         Type:  defect        |     Status:  new
     Priority:  Medium        |  Milestone:  Tor: 0.3.2.x-final
    Component:  Core Tor/Tor  |    Version:
     Severity:  Normal        |   Keywords:  tor-sched
Actual Points:                |  Parent ID:
       Points:                |   Reviewer:
      Sponsor:                |
 KIST scheduler does call a write to kernel contrary to the vanilla
 scheduler. This is done through `channel_write_to_kernel()` which calls

 That last function will ultimately call `connection_or_flushed_some()`
 which triggers a `scheduler_channel_wants_writes()` because of this

   datalen = connection_get_outbuf_len(TO_CONN(conn));
   if (datalen < OR_CONN_LOWWATER) {

 That is OK if `datalen > 0` but useless if `datalen == 0`. For KIST, it
 makes the channel go back in pending state and scheduled because it wants
 to write. But then if the outbuf or the cmux queue is empty, we end up
 scheduling a channel that actually does NOT need to write at all.

 Could be the fix here is probably simple as:

   if (datalen > 0 && datalen < OR_CONN_LOWWATER) {

 I suspect with KIST, the datalen will always be 0 because KIST in theory
 controls exactly what goes in the outbuf and what can be written to the
 kernel so when it triggers a connection write(), the entire outbuf should
 be drained (in theory). So the effect of this is that every write to the
 kernel from KIST triggers a useless "wants to write" event rescheduling
 the channel. Note that this only happens if the channel is in

Ticket URL: <https://trac.torproject.org/projects/tor/ticket/23711>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online

More information about the tor-bugs mailing list