linux/net/rxrpc
David Howells 00e907127e rxrpc: Preallocate peers, conns and calls for incoming service requests
Make it possible for the data_ready handler called from the UDP transport
socket to completely instantiate an rxrpc_call structure and make it
immediately live by preallocating all the memory it might need.  The idea
is to cut out the background thread usage as much as possible.

[Note that the preallocated structs are not actually used in this patch -
 that will be done in a future patch.]

If insufficient resources are available in the preallocation buffers, it
will be possible to discard the DATA packet in the data_ready handler or
schedule a BUSY packet without the need to schedule an attempt at
allocation in a background thread.

To this end:

 (1) Preallocate rxrpc_peer, rxrpc_connection and rxrpc_call structs to a
     maximum number each of the listen backlog size.  The backlog size is
     limited to a maxmimum of 32.  Only this many of each can be in the
     preallocation buffer.

 (2) For userspace sockets, the preallocation is charged initially by
     listen() and will be recharged by accepting or rejecting pending
     new incoming calls.

 (3) For kernel services {,re,dis}charging of the preallocation buffers is
     handled manually.  Two notifier callbacks have to be provided before
     kernel_listen() is invoked:

     (a) An indication that a new call has been instantiated.  This can be
     	 used to trigger background recharging.

     (b) An indication that a call is being discarded.  This is used when
     	 the socket is being released.

     A function, rxrpc_kernel_charge_accept() is called by the kernel
     service to preallocate a single call.  It should be passed the user ID
     to be used for that call and a callback to associate the rxrpc call
     with the kernel service's side of the ID.

 (4) Discard the preallocation when the socket is closed.

 (5) Temporarily bump the refcount on the call allocated in
     rxrpc_incoming_call() so that rxrpc_release_call() can ditch the
     preallocation ref on service calls unconditionally.  This will no
     longer be necessary once the preallocation is used.

Note that this does not yet control the number of active service calls on a
client - that will come in a later patch.

A future development would be to provide a setsockopt() call that allows a
userspace server to manually charge the preallocation buffer.  This would
allow user call IDs to be provided in advance and the awkward manual accept
stage to be bypassed.

Signed-off-by: David Howells <dhowells@redhat.com>
2016-09-08 11:10:12 +01:00
..
Kconfig rxrpc: Absorb the rxkad security module 2016-04-11 15:34:41 -04:00
Makefile rxrpc: Split sendmsg from packet transmission code 2016-09-04 21:41:39 +01:00
af_rxrpc.c rxrpc: Preallocate peers, conns and calls for incoming service requests 2016-09-08 11:10:12 +01:00
ar-internal.h rxrpc: Preallocate peers, conns and calls for incoming service requests 2016-09-08 11:10:12 +01:00
call_accept.c rxrpc: Preallocate peers, conns and calls for incoming service requests 2016-09-08 11:10:12 +01:00
call_event.c rxrpc: Add tracepoint for working out where aborts happen 2016-09-07 16:34:40 +01:00
call_object.c rxrpc: Preallocate peers, conns and calls for incoming service requests 2016-09-08 11:10:12 +01:00
conn_client.c rxrpc: Cache the security index in the rxrpc_call struct 2016-09-07 15:30:22 +01:00
conn_event.c rxrpc: Add tracepoint for working out where aborts happen 2016-09-07 16:34:40 +01:00
conn_object.c rxrpc: Preallocate peers, conns and calls for incoming service requests 2016-09-08 11:10:12 +01:00
conn_service.c rxrpc: Preallocate peers, conns and calls for incoming service requests 2016-09-08 11:10:12 +01:00
input.c rxrpc: Preallocate peers, conns and calls for incoming service requests 2016-09-08 11:10:12 +01:00
insecure.c rxrpc: Add tracepoint for working out where aborts happen 2016-09-07 16:34:40 +01:00
key.c rxrpc: Use structs to hold connection params and protocol info 2016-06-22 09:09:59 +01:00
local_event.c rxrpc: Use a tracepoint for skb accounting debugging 2016-08-23 15:27:24 +01:00
local_object.c rxrpc: Convert rxrpc_local::services to an hlist 2016-09-08 11:10:11 +01:00
misc.c rxrpc: Split sendmsg from packet transmission code 2016-09-04 21:41:39 +01:00
output.c rxrpc: Calls shouldn't hold socket refs 2016-09-07 15:33:20 +01:00
peer_event.c rxrpc: Trace rxrpc_call usage 2016-08-30 16:02:36 +01:00
peer_object.c rxrpc: Provide a way for AFS to ask for the peer address of a call 2016-08-30 16:07:53 +01:00
proc.c rxrpc: Preallocate peers, conns and calls for incoming service requests 2016-09-08 11:10:12 +01:00
recvmsg.c rxrpc: Calls shouldn't hold socket refs 2016-09-07 15:33:20 +01:00
rxkad.c rxrpc: Add tracepoint for working out where aborts happen 2016-09-07 16:34:40 +01:00
security.c rxrpc: Convert rxrpc_local::services to an hlist 2016-09-08 11:10:11 +01:00
sendmsg.c rxrpc: Add tracepoint for working out where aborts happen 2016-09-07 16:34:40 +01:00
skbuff.c rxrpc: Calls shouldn't hold socket refs 2016-09-07 15:33:20 +01:00
sysctl.c rxrpc: Calls shouldn't hold socket refs 2016-09-07 15:33:20 +01:00
utils.c rxrpc: Move data_ready peer lookup into rxrpc_find_connection() 2016-07-06 10:51:14 +01:00