1. 01 Dec, 2022 32 commits
    • David Howells's avatar
      rxrpc: Remove the _bh annotation from all the spinlocks · 3dd9c8b5
      David Howells authored
      None of the spinlocks in rxrpc need a _bh annotation now as the RCU
      callback routines no longer take spinlocks and the bulk of the packet
      wrangling code is now run in the I/O thread, not softirq context.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      3dd9c8b5
    • David Howells's avatar
      rxrpc: Make the I/O thread take over the call and local processor work · 5e6ef4f1
      David Howells authored
      Move the functions from the call->processor and local->processor work items
      into the domain of the I/O thread.
      
      The call event processor, now called from the I/O thread, then takes over
      the job of cranking the call state machine, processing incoming packets and
      transmitting DATA, ACK and ABORT packets.  In a future patch,
      rxrpc_send_ACK() will transmit the ACK on the spot rather than queuing it
      for later transmission.
      
      The call event processor becomes purely received-skb driven.  It only
      transmits things in response to events.  We use "pokes" to queue a dummy
      skb to make it do things like start/resume transmitting data.  Timer expiry
      also results in pokes.
      
      The connection event processor, becomes similar, though crypto events, such
      as dealing with CHALLENGE and RESPONSE packets is offloaded to a work item
      to avoid doing crypto in the I/O thread.
      
      The local event processor is removed and VERSION response packets are
      generated directly from the packet parser.  Similarly, ABORTs generated in
      response to protocol errors will be transmitted immediately rather than
      being pushed onto a queue for later transmission.
      
      Changes:
      ========
      ver #2)
       - Fix a couple of introduced lock context imbalances.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      5e6ef4f1
    • David Howells's avatar
      rxrpc: Extract the peer address from an incoming packet earlier · 393a2a20
      David Howells authored
      Extract the peer address from an incoming packet earlier, at the beginning
      of rxrpc_input_packet() and thence pass a pointer to it to various
      functions that use it as part of the lookup rather than doing it on several
      separate paths.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      393a2a20
    • David Howells's avatar
      rxrpc: Reduce the use of RCU in packet input · cd21effb
      David Howells authored
      Shrink the region of rxrpc_input_packet() that is covered by the RCU read
      lock so that it only covers the connection and call lookup.  This means
      that the bits now outside of that can call sleepable functions such as
      kmalloc and sendmsg.
      
      Also take a ref on the conn or call we're going to use before we drop the
      RCU read lock.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      cd21effb
    • David Howells's avatar
      rxrpc: Simplify skbuff accounting in receive path · 2d1faf7a
      David Howells authored
      A received skbuff needs a ref when it gets put on a call data queue or conn
      packet queue, and rxrpc_input_packet() and co. jump through a lot of hoops
      to avoid double-dropping the skbuff ref so that we can avoid getting a ref
      when we queue the packet.
      
      Change this so that the skbuff ref is unconditionally dropped by the caller
      of rxrpc_input_packet().  An additional ref is then taken on the packet if
      it is pushed onto a queue.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      2d1faf7a
    • David Howells's avatar
      rxrpc: Remove RCU from peer->error_targets list · 29fb4ec3
      David Howells authored
      Remove the RCU requirements from the peer's list of error targets so that
      the error distributor can call sleeping functions.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      29fb4ec3
    • David Howells's avatar
      rxrpc: Move DATA transmission into call processor work item · cf37b598
      David Howells authored
      Move DATA transmission into the call processor work item.  In a future
      patch, this will be called from the I/O thread rather than being itsown
      work item.
      
      This will allow DATA transmission to be driven directly by incoming ACKs,
      pokes and timers as those are processed.
      
      The Tx queue is also split: The queue of packets prepared by sendmsg is now
      places in call->tx_sendmsg and the packet dispatcher decants the packets
      into call->tx_buffer as space becomes available in the transmission
      window.  This allows sendmsg to run ahead of the available space to try and
      prevent an underflow in transmission.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      cf37b598
    • David Howells's avatar
      rxrpc: Copy client call parameters into rxrpc_call earlier · f3441d41
      David Howells authored
      Copy client call parameters into rxrpc_call earlier so that that can be
      used to convey them to the connection code - which can then be offloaded to
      the I/O thread.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      f3441d41
    • David Howells's avatar
      rxrpc: Implement a mechanism to send an event notification to a call · 15f661dc
      David Howells authored
      Provide a means by which an event notification can be sent to a call such
      that the I/O thread can process it rather than it being done in a separate
      workqueue.  This will allow a lot of locking to be removed.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      15f661dc
    • David Howells's avatar
      rxrpc: Don't use sk->sk_receive_queue.lock to guard socket state changes · 81f2e8ad
      David Howells authored
      Don't use sk->sk_receive_queue.lock to guard socket state changes as the
      socket mutex is sufficient.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      81f2e8ad
    • David Howells's avatar
      rxrpc: Remove call->input_lock · 4041a8ff
      David Howells authored
      Remove call->input_lock as it was only necessary to serialise access to the
      state stored in the rxrpc_call struct by simultaneous softirq handlers
      presenting received packets.  They now dump the packets in a queue and a
      single process-context handler now processes them.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      4041a8ff
    • David Howells's avatar
      rxrpc: Move error processing into the local endpoint I/O thread · ff734825
      David Howells authored
      Move the processing of error packets into the local endpoint I/O thread,
      leaving the handover from UDP to merely transfer them into the local
      endpoint queue.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      ff734825
    • David Howells's avatar
      rxrpc: Move packet reception processing into I/O thread · 446b3e14
      David Howells authored
      Split the packet input handler to make the softirq side just dump the
      received packet into the local endpoint receive queue and then call the
      remainder of the input function from the I/O thread.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      446b3e14
    • David Howells's avatar
      rxrpc: Create a per-local endpoint receive queue and I/O thread · a275da62
      David Howells authored
      Create a per-local receive queue to which, in a future patch, all incoming
      packets will be directed and an I/O thread that will process those packets
      and perform all transmission of packets.
      
      Destruction of the local endpoint is also moved from the local processor
      work item (which will be absorbed) to the thread.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      a275da62
    • David Howells's avatar
      rxrpc: Split the receive code · 96b2d69b
      David Howells authored
      Split the code that handles packet reception in softirq mode as a prelude
      to moving all the packet processing beyond routing to the appropriate call
      and setting up of a new call out into process context.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      96b2d69b
    • David Howells's avatar
      rxrpc: Don't hold a ref for connection workqueue · 3cec055c
      David Howells authored
      Currently, rxrpc gives the connection's work item a ref on the connection
      when it queues it - and this is called from the timer expiration function.
      The problem comes when queue_work() fails (ie. the work item is already
      queued): the timer routine must put the ref - but this may cause the
      cleanup code to run.
      
      This has the unfortunate effect that the cleanup code may then be run in
      softirq context - which means that any spinlocks it might need to touch
      have to be guarded to disable softirqs (ie. they need a "_bh" suffix).
      
       (1) Don't give a ref to the work item.
      
       (2) Simplify handling of service connections by adding a separate active
           count so that the refcount isn't also used for this.
      
       (3) Connection destruction for both client and service connections can
           then be cleaned up by putting rxrpc_put_connection() out of line and
           making a tidy progression through the destruction code (offloaded to a
           workqueue if put from softirq or processor function context).  The RCU
           part of the cleanup then only deals with the freeing at the end.
      
       (4) Make rxrpc_queue_conn() return immediately if it sees the active count
           is -1 rather then queuing the connection.
      
       (5) Make sure that the cleanup routine waits for the work item to
           complete.
      
       (6) Stash the rxrpc_net pointer in the conn struct so that the rcu free
           routine can use it, even if the local endpoint has been freed.
      
      Unfortunately, neither the timer nor the work item can simply get around
      the problem by just using refcount_inc_not_zero() as the waits would still
      have to be done, and there would still be the possibility of having to put
      the ref in the expiration function.
      
      Note the connection work item is mostly going to go away with the main
      event work being transferred to the I/O thread, so the wait in (6) will
      become obsolete.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      3cec055c
    • David Howells's avatar
      rxrpc: Don't hold a ref for call timer or workqueue · 3feda9d6
      David Howells authored
      Currently, rxrpc gives the call timer a ref on the call when it starts it
      and this is passed along to the workqueue by the timer expiration function.
      The problem comes when queue_work() fails (ie. the work item is already
      queued): the timer routine must put the ref - but this may cause the
      cleanup code to run.
      
      This has the unfortunate effect that the cleanup code may then be run in
      softirq context - which means that any spinlocks it might need to touch
      have to be guarded to disable softirqs (ie. they need a "_bh" suffix).
      
      Fix this by:
      
       (1) Don't give a ref to the timer.
      
       (2) Making the expiration function not do anything if the refcount is 0.
           Note that this is more of an optimisation.
      
       (3) Make sure that the cleanup routine waits for timer to complete.
      
      However, this has a consequence that timer cannot give a ref to the work
      item.  Therefore the following fixes are also necessary:
      
       (4) Don't give a ref to the work item.
      
       (5) Make the work item return asap if it sees the ref count is 0.
      
       (6) Make sure that the cleanup routine waits for the work item to
           complete.
      
      Unfortunately, neither the timer nor the work item can simply get around
      the problem by just using refcount_inc_not_zero() as the waits would still
      have to be done, and there would still be the possibility of having to put
      the ref in the expiration function.
      
      Note the call work item is going to go away with the work being transferred
      to the I/O thread, so the wait in (6) will become obsolete.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      3feda9d6
    • David Howells's avatar
      rxrpc: trace: Don't use __builtin_return_address for sk_buff tracing · 9a36a6bc
      David Howells authored
      In rxrpc tracing, use enums to generate lists of points of interest rather
      than __builtin_return_address() for the sk_buff tracepoint.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      9a36a6bc
    • David Howells's avatar
      rxrpc: Trace rxrpc_bundle refcount · fa3492ab
      David Howells authored
      Add a tracepoint for the rxrpc_bundle refcounting.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      fa3492ab
    • David Howells's avatar
      rxrpc: trace: Don't use __builtin_return_address for rxrpc_call tracing · cb0fc0c9
      David Howells authored
      In rxrpc tracing, use enums to generate lists of points of interest rather
      than __builtin_return_address() for the rxrpc_call tracepoint
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      cb0fc0c9
    • David Howells's avatar
      rxrpc: trace: Don't use __builtin_return_address for rxrpc_conn tracing · 7fa25105
      David Howells authored
      In rxrpc tracing, use enums to generate lists of points of interest rather
      than __builtin_return_address() for the rxrpc_conn tracepoint
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      7fa25105
    • David Howells's avatar
      rxrpc: trace: Don't use __builtin_return_address for rxrpc_peer tracing · 47c810a7
      David Howells authored
      In rxrpc tracing, use enums to generate lists of points of interest rather
      than __builtin_return_address() for the rxrpc_peer tracepoint
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      47c810a7
    • David Howells's avatar
      rxrpc: trace: Don't use __builtin_return_address for rxrpc_local tracing · 0fde882f
      David Howells authored
      In rxrpc tracing, use enums to generate lists of points of interest rather
      than __builtin_return_address() for the rxrpc_local tracepoint
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      0fde882f
    • David Howells's avatar
      rxrpc: Extract the code from a received ABORT packet much earlier · f14febd8
      David Howells authored
      Extract the code from a received rx ABORT packet much earlier and in a
      single place and harmonise the responses to malformed ABORT packets.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      f14febd8
    • David Howells's avatar
      rxrpc: Drop rxrpc_conn_parameters from rxrpc_connection and rxrpc_bundle · 2cc80086
      David Howells authored
      Remove the rxrpc_conn_parameters struct from the rxrpc_connection and
      rxrpc_bundle structs and emplace the members directly.  These are going to
      get filled in from the rxrpc_call struct in future.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      2cc80086
    • David Howells's avatar
      rxrpc: Remove the [_k]net() debugging macros · e969c92c
      David Howells authored
      Remove the _net() and knet() debugging macros in favour of tracepoints.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      e969c92c
    • David Howells's avatar
      rxrpc: Remove the [k_]proto() debugging macros · 2ebdb26e
      David Howells authored
      Remove the kproto() and _proto() debugging macros in preference to using
      tracepoints for this.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      2ebdb26e
    • David Howells's avatar
      rxrpc: Remove handling of duplicate packets in recvmsg_queue · 30efa3ce
      David Howells authored
      We should not now see duplicate packets in the recvmsg_queue.  At one
      point, jumbo packets that overlapped with already queued data would be
      added to the queue and dealt with in recvmsg rather than in the softirq
      input code, but now jumbo packets are split/cloned before being processed
      by the input code and the subpackets can be discarded individually.
      
      So remove the recvmsg-side code for handling this.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      30efa3ce
    • David Howells's avatar
      rxrpc: Remove decl for rxrpc_kernel_call_is_complete() · 2ed83ed2
      David Howells authored
      rxrpc_kernel_call_is_complete() has been removed, so remove its declaration
      too.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      2ed83ed2
    • David Howells's avatar
      rxrpc: Fix call leak · 49df54a6
      David Howells authored
      When retransmitting a packet, rxrpc_resend() shouldn't be attaching a ref
      to the call to the txbuf as that pins the call and prevents the call from
      clearing the packet buffer.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Fixes: d57a3a15 ("rxrpc: Save last ACK's SACK table rather than marking txbufs")
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      49df54a6
    • David Howells's avatar
      rxrpc: Implement an in-kernel rxperf server for testing purposes · 75bfdbf2
      David Howells authored
      Implement an in-kernel rxperf server to allow kernel-based rxrpc services
      to be tested directly, unlike with AFS where they're accessed by the
      fileserver when the latter decides it wants to.
      
      This is implemented as a module that, if loaded, opens UDP port 7009
      (afs3-rmtsys) and listens on it for incoming calls.  Calls can be generated
      using the rxperf command shipped with OpenAFS, for example.
      
      Changes
      =======
      ver #2)
       - Use min_t() instead of min().
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      cc: Jakub Kicinski <kuba@kernel.org>
      75bfdbf2
    • David Howells's avatar
      rxrpc: Fix checker warning · 84924aac
      David Howells authored
      Fix the following checker warning:
      
      ../net/rxrpc/key.c:692:9: error: subtraction of different types can't work (different address spaces)
      
      Checker is wrong in this case, but cast the pointers to unsigned long to
      avoid the warning.
      
      Whilst we're at it, reduce the assertions to WARN_ON() and return an error.
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      84924aac
  2. 30 Nov, 2022 8 commits