Skip to content

Commit 5e6ef4f

Browse files
committed
rxrpc: Make the I/O thread take over the call and local processor work
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: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: [email protected]
1 parent 393a2a2 commit 5e6ef4f

File tree

15 files changed

+545
-791
lines changed

15 files changed

+545
-791
lines changed

include/trace/events/rxrpc.h

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#define rxrpc_skb_traces \
2727
EM(rxrpc_skb_eaten_by_unshare, "ETN unshare ") \
2828
EM(rxrpc_skb_eaten_by_unshare_nomem, "ETN unshar-nm") \
29-
EM(rxrpc_skb_get_ack, "GET ack ") \
3029
EM(rxrpc_skb_get_conn_work, "GET conn-work") \
3130
EM(rxrpc_skb_get_local_work, "GET locl-work") \
3231
EM(rxrpc_skb_get_reject_work, "GET rej-work ") \
@@ -36,7 +35,6 @@
3635
EM(rxrpc_skb_new_error_report, "NEW error-rpt") \
3736
EM(rxrpc_skb_new_jumbo_subpacket, "NEW jumbo-sub") \
3837
EM(rxrpc_skb_new_unshared, "NEW unshared ") \
39-
EM(rxrpc_skb_put_ack, "PUT ack ") \
4038
EM(rxrpc_skb_put_conn_work, "PUT conn-work") \
4139
EM(rxrpc_skb_put_error_report, "PUT error-rep") \
4240
EM(rxrpc_skb_put_input, "PUT input ") \
@@ -45,7 +43,6 @@
4543
EM(rxrpc_skb_put_rotate, "PUT rotate ") \
4644
EM(rxrpc_skb_put_unknown, "PUT unknown ") \
4745
EM(rxrpc_skb_see_conn_work, "SEE conn-work") \
48-
EM(rxrpc_skb_see_local_work, "SEE locl-work") \
4946
EM(rxrpc_skb_see_recvmsg, "SEE recvmsg ") \
5047
EM(rxrpc_skb_see_reject, "SEE reject ") \
5148
EM(rxrpc_skb_see_rotate, "SEE rotate ") \
@@ -58,38 +55,32 @@
5855
EM(rxrpc_local_get_for_use, "GET for-use ") \
5956
EM(rxrpc_local_get_peer, "GET peer ") \
6057
EM(rxrpc_local_get_prealloc_conn, "GET conn-pre") \
61-
EM(rxrpc_local_get_queue, "GET queue ") \
6258
EM(rxrpc_local_new, "NEW ") \
63-
EM(rxrpc_local_processing, "PROCESSING ") \
64-
EM(rxrpc_local_put_already_queued, "PUT alreadyq") \
6559
EM(rxrpc_local_put_bind, "PUT bind ") \
6660
EM(rxrpc_local_put_call, "PUT call ") \
6761
EM(rxrpc_local_put_for_use, "PUT for-use ") \
6862
EM(rxrpc_local_put_kill_conn, "PUT conn-kil") \
6963
EM(rxrpc_local_put_peer, "PUT peer ") \
7064
EM(rxrpc_local_put_prealloc_conn, "PUT conn-pre") \
7165
EM(rxrpc_local_put_release_sock, "PUT rel-sock") \
72-
EM(rxrpc_local_put_queue, "PUT queue ") \
73-
EM(rxrpc_local_queued, "QUEUED ") \
7466
EM(rxrpc_local_see_tx_ack, "SEE tx-ack ") \
7567
EM(rxrpc_local_stop, "STOP ") \
7668
EM(rxrpc_local_stopped, "STOPPED ") \
7769
EM(rxrpc_local_unuse_bind, "UNU bind ") \
7870
EM(rxrpc_local_unuse_conn_work, "UNU conn-wrk") \
7971
EM(rxrpc_local_unuse_peer_keepalive, "UNU peer-kpa") \
8072
EM(rxrpc_local_unuse_release_sock, "UNU rel-sock") \
81-
EM(rxrpc_local_unuse_work, "UNU work ") \
8273
EM(rxrpc_local_use_conn_work, "USE conn-wrk") \
8374
EM(rxrpc_local_use_lookup, "USE lookup ") \
84-
EM(rxrpc_local_use_peer_keepalive, "USE peer-kpa") \
85-
E_(rxrpc_local_use_work, "USE work ")
75+
E_(rxrpc_local_use_peer_keepalive, "USE peer-kpa")
8676

8777
#define rxrpc_peer_traces \
8878
EM(rxrpc_peer_free, "FREE ") \
8979
EM(rxrpc_peer_get_accept, "GET accept ") \
9080
EM(rxrpc_peer_get_activate_call, "GET act-call") \
9181
EM(rxrpc_peer_get_bundle, "GET bundle ") \
9282
EM(rxrpc_peer_get_client_conn, "GET cln-conn") \
83+
EM(rxrpc_peer_get_input, "GET input ") \
9384
EM(rxrpc_peer_get_input_error, "GET inpt-err") \
9485
EM(rxrpc_peer_get_keepalive, "GET keepaliv") \
9586
EM(rxrpc_peer_get_lookup_client, "GET look-cln") \
@@ -100,6 +91,7 @@
10091
EM(rxrpc_peer_put_call, "PUT call ") \
10192
EM(rxrpc_peer_put_conn, "PUT conn ") \
10293
EM(rxrpc_peer_put_discard_tmp, "PUT disc-tmp") \
94+
EM(rxrpc_peer_put_input, "PUT input ") \
10395
EM(rxrpc_peer_put_input_error, "PUT inpt-err") \
10496
E_(rxrpc_peer_put_keepalive, "PUT keepaliv")
10597

@@ -180,11 +172,6 @@
180172
EM(rxrpc_call_put_sendmsg, "PUT sendmsg ") \
181173
EM(rxrpc_call_put_unnotify, "PUT unnotify") \
182174
EM(rxrpc_call_put_userid_exists, "PUT u-exists") \
183-
EM(rxrpc_call_queue_abort, "QUE abort ") \
184-
EM(rxrpc_call_queue_requeue, "QUE requeue ") \
185-
EM(rxrpc_call_queue_resend, "QUE resend ") \
186-
EM(rxrpc_call_queue_timer, "QUE timer ") \
187-
EM(rxrpc_call_queue_tx_data, "QUE tx-data ") \
188175
EM(rxrpc_call_see_accept, "SEE accept ") \
189176
EM(rxrpc_call_see_activate_client, "SEE act-clnt") \
190177
EM(rxrpc_call_see_connect_failed, "SEE con-fail") \
@@ -282,6 +269,7 @@
282269
EM(rxrpc_propose_ack_respond_to_ping, "Rsp2Png") \
283270
EM(rxrpc_propose_ack_retry_tx, "RetryTx") \
284271
EM(rxrpc_propose_ack_rotate_rx, "RxAck ") \
272+
EM(rxrpc_propose_ack_rx_idle, "RxIdle ") \
285273
E_(rxrpc_propose_ack_terminal_ack, "ClTerm ")
286274

287275
#define rxrpc_congest_modes \
@@ -1532,40 +1520,50 @@ TRACE_EVENT(rxrpc_connect_call,
15321520
__field(unsigned long, user_call_ID )
15331521
__field(u32, cid )
15341522
__field(u32, call_id )
1523+
__field_struct(struct sockaddr_rxrpc, srx )
15351524
),
15361525

15371526
TP_fast_assign(
15381527
__entry->call = call->debug_id;
15391528
__entry->user_call_ID = call->user_call_ID;
15401529
__entry->cid = call->cid;
15411530
__entry->call_id = call->call_id;
1531+
__entry->srx = call->dest_srx;
15421532
),
15431533

1544-
TP_printk("c=%08x u=%p %08x:%08x",
1534+
TP_printk("c=%08x u=%p %08x:%08x dst=%pISp",
15451535
__entry->call,
15461536
(void *)__entry->user_call_ID,
15471537
__entry->cid,
1548-
__entry->call_id)
1538+
__entry->call_id,
1539+
&__entry->srx.transport)
15491540
);
15501541

15511542
TRACE_EVENT(rxrpc_resend,
1552-
TP_PROTO(struct rxrpc_call *call),
1543+
TP_PROTO(struct rxrpc_call *call, struct sk_buff *ack),
15531544

1554-
TP_ARGS(call),
1545+
TP_ARGS(call, ack),
15551546

15561547
TP_STRUCT__entry(
15571548
__field(unsigned int, call )
15581549
__field(rxrpc_seq_t, seq )
1550+
__field(rxrpc_seq_t, transmitted )
1551+
__field(rxrpc_serial_t, ack_serial )
15591552
),
15601553

15611554
TP_fast_assign(
1555+
struct rxrpc_skb_priv *sp = ack ? rxrpc_skb(ack) : NULL;
15621556
__entry->call = call->debug_id;
15631557
__entry->seq = call->acks_hard_ack;
1558+
__entry->transmitted = call->tx_transmitted;
1559+
__entry->ack_serial = sp ? sp->hdr.serial : 0;
15641560
),
15651561

1566-
TP_printk("c=%08x q=%x",
1562+
TP_printk("c=%08x r=%x q=%x tq=%x",
15671563
__entry->call,
1568-
__entry->seq)
1564+
__entry->ack_serial,
1565+
__entry->seq,
1566+
__entry->transmitted)
15691567
);
15701568

15711569
TRACE_EVENT(rxrpc_rx_icmp,

net/rxrpc/ar-internal.h

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,11 @@ struct rxrpc_local {
283283
struct rxrpc_net *rxnet; /* The network ns in which this resides */
284284
struct hlist_node link;
285285
struct socket *socket; /* my UDP socket */
286-
struct work_struct processor;
287286
struct task_struct *io_thread;
288287
struct list_head ack_tx_queue; /* List of ACKs that need sending */
289288
spinlock_t ack_tx_lock; /* ACK list lock */
290289
struct rxrpc_sock __rcu *service; /* Service(s) listening on this endpoint */
291290
struct rw_semaphore defrag_sem; /* control re-enablement of IP DF bit */
292-
struct sk_buff_head reject_queue; /* packets awaiting rejection */
293-
struct sk_buff_head event_queue; /* endpoint event packets awaiting processing */
294291
struct sk_buff_head rx_queue; /* Received packets */
295292
struct list_head call_attend_q; /* Calls requiring immediate attention */
296293
struct rb_root client_bundles; /* Client connection bundles by socket params */
@@ -524,23 +521,19 @@ enum rxrpc_call_flag {
524521
RXRPC_CALL_RETRANS_TIMEOUT, /* Retransmission due to timeout occurred */
525522
RXRPC_CALL_BEGAN_RX_TIMER, /* We began the expect_rx_by timer */
526523
RXRPC_CALL_RX_HEARD, /* The peer responded at least once to this call */
527-
RXRPC_CALL_RX_UNDERRUN, /* Got data underrun */
528524
RXRPC_CALL_DISCONNECTED, /* The call has been disconnected */
529525
RXRPC_CALL_KERNEL, /* The call was made by the kernel */
530526
RXRPC_CALL_UPGRADE, /* Service upgrade was requested for the call */
531-
RXRPC_CALL_DELAY_ACK_PENDING, /* DELAY ACK generation is pending */
532-
RXRPC_CALL_IDLE_ACK_PENDING, /* IDLE ACK generation is pending */
533527
RXRPC_CALL_EXCLUSIVE, /* The call uses a once-only connection */
528+
RXRPC_CALL_RX_IS_IDLE, /* Reception is idle - send an ACK */
534529
};
535530

536531
/*
537532
* Events that can be raised on a call.
538533
*/
539534
enum rxrpc_call_event {
540-
RXRPC_CALL_EV_ABORT, /* need to generate abort */
541-
RXRPC_CALL_EV_RESEND, /* Tx resend required */
542-
RXRPC_CALL_EV_EXPIRED, /* Expiry occurred */
543535
RXRPC_CALL_EV_ACK_LOST, /* ACK may be lost, send ping */
536+
RXRPC_CALL_EV_INITIAL_PING, /* Send initial ping for a new service call */
544537
};
545538

546539
/*
@@ -611,7 +604,6 @@ struct rxrpc_call {
611604
u32 next_rx_timo; /* Timeout for next Rx packet (jif) */
612605
u32 next_req_timo; /* Timeout for next Rx request packet (jif) */
613606
struct timer_list timer; /* Combined event timer */
614-
struct work_struct processor; /* Event processor */
615607
struct work_struct destroyer; /* In-process-context destroyer */
616608
rxrpc_notify_rx_t notify_rx; /* kernel service Rx notification function */
617609
struct list_head link; /* link in master call list */
@@ -705,11 +697,7 @@ struct rxrpc_call {
705697
rxrpc_seq_t acks_prev_seq; /* Highest previousPacket received */
706698
rxrpc_seq_t acks_hard_ack; /* Latest hard-ack point */
707699
rxrpc_seq_t acks_lowest_nak; /* Lowest NACK in the buffer (or ==tx_hard_ack) */
708-
rxrpc_seq_t acks_lost_top; /* tx_top at the time lost-ack ping sent */
709-
rxrpc_serial_t acks_lost_ping; /* Serial number of probe ACK */
710700
rxrpc_serial_t acks_highest_serial; /* Highest serial number ACK'd */
711-
struct sk_buff *acks_soft_tbl; /* The last ACK packet with NAKs in it */
712-
spinlock_t acks_ack_lock; /* Access to ->acks_last_ack */
713701
};
714702

715703
/*
@@ -822,10 +810,9 @@ extern struct workqueue_struct *rxrpc_workqueue;
822810
*/
823811
int rxrpc_service_prealloc(struct rxrpc_sock *, gfp_t);
824812
void rxrpc_discard_prealloc(struct rxrpc_sock *);
825-
struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *,
826-
struct rxrpc_sock *,
827-
struct sockaddr_rxrpc *,
828-
struct sk_buff *);
813+
bool rxrpc_new_incoming_call(struct rxrpc_local *, struct rxrpc_peer *,
814+
struct rxrpc_connection *, struct sockaddr_rxrpc *,
815+
struct sk_buff *);
829816
void rxrpc_accept_incoming_calls(struct rxrpc_local *);
830817
int rxrpc_user_charge_accept(struct rxrpc_sock *, unsigned long);
831818

@@ -838,13 +825,15 @@ void rxrpc_send_ACK(struct rxrpc_call *, u8, rxrpc_serial_t, enum rxrpc_propose_
838825
void rxrpc_propose_delay_ACK(struct rxrpc_call *, rxrpc_serial_t,
839826
enum rxrpc_propose_ack_trace);
840827
void rxrpc_shrink_call_tx_buffer(struct rxrpc_call *);
841-
void rxrpc_process_call(struct work_struct *);
828+
void rxrpc_resend(struct rxrpc_call *call, struct sk_buff *ack_skb);
842829

843830
void rxrpc_reduce_call_timer(struct rxrpc_call *call,
844831
unsigned long expire_at,
845832
unsigned long now,
846833
enum rxrpc_timer_trace why);
847834

835+
void rxrpc_input_call_event(struct rxrpc_call *call, struct sk_buff *skb);
836+
848837
/*
849838
* call_object.c
850839
*/
@@ -864,9 +853,8 @@ void rxrpc_incoming_call(struct rxrpc_sock *, struct rxrpc_call *,
864853
struct sk_buff *);
865854
void rxrpc_release_call(struct rxrpc_sock *, struct rxrpc_call *);
866855
void rxrpc_release_calls_on_socket(struct rxrpc_sock *);
867-
void rxrpc_queue_call(struct rxrpc_call *, enum rxrpc_call_trace);
868856
void rxrpc_see_call(struct rxrpc_call *, enum rxrpc_call_trace);
869-
bool rxrpc_try_get_call(struct rxrpc_call *, enum rxrpc_call_trace);
857+
struct rxrpc_call *rxrpc_try_get_call(struct rxrpc_call *, enum rxrpc_call_trace);
870858
void rxrpc_get_call(struct rxrpc_call *, enum rxrpc_call_trace);
871859
void rxrpc_put_call(struct rxrpc_call *, enum rxrpc_call_trace);
872860
void rxrpc_cleanup_call(struct rxrpc_call *);
@@ -908,6 +896,7 @@ void rxrpc_clean_up_local_conns(struct rxrpc_local *);
908896
*/
909897
void rxrpc_process_connection(struct work_struct *);
910898
void rxrpc_process_delayed_final_acks(struct rxrpc_connection *, bool);
899+
int rxrpc_input_conn_packet(struct rxrpc_connection *conn, struct sk_buff *skb);
911900

912901
/*
913902
* conn_object.c
@@ -916,10 +905,9 @@ extern unsigned int rxrpc_connection_expiry;
916905
extern unsigned int rxrpc_closed_conn_expiry;
917906

918907
struct rxrpc_connection *rxrpc_alloc_connection(struct rxrpc_net *, gfp_t);
919-
struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *,
920-
struct sockaddr_rxrpc *,
921-
struct sk_buff *,
922-
struct rxrpc_peer **);
908+
struct rxrpc_connection *rxrpc_find_client_connection_rcu(struct rxrpc_local *,
909+
struct sockaddr_rxrpc *,
910+
struct sk_buff *);
923911
void __rxrpc_disconnect_call(struct rxrpc_connection *, struct rxrpc_call *);
924912
void rxrpc_disconnect_call(struct rxrpc_call *);
925913
void rxrpc_kill_client_conn(struct rxrpc_connection *);
@@ -962,8 +950,8 @@ void rxrpc_unpublish_service_conn(struct rxrpc_connection *);
962950
/*
963951
* input.c
964952
*/
965-
void rxrpc_input_call_event(struct rxrpc_call *, struct sk_buff *);
966-
void rxrpc_input_implicit_end_call(struct rxrpc_connection *, struct rxrpc_call *);
953+
void rxrpc_input_call_packet(struct rxrpc_call *, struct sk_buff *);
954+
void rxrpc_implicit_end_call(struct rxrpc_call *, struct sk_buff *);
967955

968956
/*
969957
* io_thread.c
@@ -993,7 +981,9 @@ int rxrpc_get_server_data_key(struct rxrpc_connection *, const void *, time64_t,
993981
/*
994982
* local_event.c
995983
*/
996-
extern void rxrpc_process_local_events(struct rxrpc_local *);
984+
void rxrpc_send_version_request(struct rxrpc_local *local,
985+
struct rxrpc_host_header *hdr,
986+
struct sk_buff *skb);
997987

998988
/*
999989
* local_object.c
@@ -1004,7 +994,6 @@ struct rxrpc_local *rxrpc_get_local_maybe(struct rxrpc_local *, enum rxrpc_local
1004994
void rxrpc_put_local(struct rxrpc_local *, enum rxrpc_local_trace);
1005995
struct rxrpc_local *rxrpc_use_local(struct rxrpc_local *, enum rxrpc_local_trace);
1006996
void rxrpc_unuse_local(struct rxrpc_local *, enum rxrpc_local_trace);
1007-
void rxrpc_queue_local(struct rxrpc_local *);
1008997
void rxrpc_destroy_local(struct rxrpc_local *local);
1009998
void rxrpc_destroy_all_locals(struct rxrpc_net *);
1010999

@@ -1068,7 +1057,7 @@ static inline struct rxrpc_net *rxrpc_net(struct net *net)
10681057
void rxrpc_transmit_ack_packets(struct rxrpc_local *);
10691058
int rxrpc_send_abort_packet(struct rxrpc_call *);
10701059
int rxrpc_send_data_packet(struct rxrpc_call *, struct rxrpc_txbuf *);
1071-
void rxrpc_reject_packets(struct rxrpc_local *);
1060+
void rxrpc_reject_packet(struct rxrpc_local *local, struct sk_buff *skb);
10721061
void rxrpc_send_keepalive(struct rxrpc_peer *);
10731062
void rxrpc_transmit_one(struct rxrpc_call *call, struct rxrpc_txbuf *txb);
10741063

@@ -1178,7 +1167,6 @@ int rxrpc_server_keyring(struct rxrpc_sock *, sockptr_t, int);
11781167
* skbuff.c
11791168
*/
11801169
void rxrpc_kernel_data_consumed(struct rxrpc_call *, struct sk_buff *);
1181-
void rxrpc_packet_destructor(struct sk_buff *);
11821170
void rxrpc_new_skb(struct sk_buff *, enum rxrpc_skb_trace);
11831171
void rxrpc_see_skb(struct sk_buff *, enum rxrpc_skb_trace);
11841172
void rxrpc_eaten_skb(struct sk_buff *, enum rxrpc_skb_trace);

0 commit comments

Comments
 (0)