Skip to content

Commit 57af281

Browse files
committed
rxrpc: Tidy up abort generation infrastructure
Tidy up the abort generation infrastructure in the following ways: (1) Create an enum and string mapping table to list the reasons an abort might be generated in tracing. (2) Replace the 3-char string with the values from (1) in the places that use that to log the abort source. This gets rid of a memcpy() in the tracepoint. (3) Subsume the rxrpc_rx_eproto tracepoint with the rxrpc_abort tracepoint and use values from (1) to indicate the trace reason. (4) Always make a call to an abort function at the point of the abort rather than stashing the values into variables and using goto to get to a place where it reported. The C optimiser will collapse the calls together as appropriate. The abort functions return a value that can be returned directly if appropriate. Note that this extends into afs also at the points where that generates an abort. To aid with this, the afs sources need to #define RXRPC_TRACE_ONLY_DEFINE_ENUMS before including the rxrpc tracing header because they don't have access to the rxrpc internal structures that some of the tracepoints make use of. Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: [email protected]
1 parent a00ce28 commit 57af281

File tree

17 files changed

+484
-444
lines changed

17 files changed

+484
-444
lines changed

fs/afs/cmservice.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "internal.h"
1414
#include "afs_cm.h"
1515
#include "protocol_yfs.h"
16+
#define RXRPC_TRACE_ONLY_DEFINE_ENUMS
17+
#include <trace/events/rxrpc.h>
1618

1719
static int afs_deliver_cb_init_call_back_state(struct afs_call *);
1820
static int afs_deliver_cb_init_call_back_state3(struct afs_call *);
@@ -191,7 +193,7 @@ static void afs_cm_destructor(struct afs_call *call)
191193
* Abort a service call from within an action function.
192194
*/
193195
static void afs_abort_service_call(struct afs_call *call, u32 abort_code, int error,
194-
const char *why)
196+
enum rxrpc_abort_reason why)
195197
{
196198
rxrpc_kernel_abort_call(call->net->socket, call->rxcall,
197199
abort_code, error, why);
@@ -469,7 +471,7 @@ static void SRXAFSCB_ProbeUuid(struct work_struct *work)
469471
if (memcmp(r, &call->net->uuid, sizeof(call->net->uuid)) == 0)
470472
afs_send_empty_reply(call);
471473
else
472-
afs_abort_service_call(call, 1, 1, "K-1");
474+
afs_abort_service_call(call, 1, 1, afs_abort_probeuuid_negative);
473475

474476
afs_put_call(call);
475477
_leave("");

fs/afs/rxrpc.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "internal.h"
1414
#include "afs_cm.h"
1515
#include "protocol_yfs.h"
16+
#define RXRPC_TRACE_ONLY_DEFINE_ENUMS
17+
#include <trace/events/rxrpc.h>
1618

1719
struct workqueue_struct *afs_async_calls;
1820

@@ -397,7 +399,8 @@ void afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call, gfp_t gfp)
397399
error_do_abort:
398400
if (ret != -ECONNABORTED) {
399401
rxrpc_kernel_abort_call(call->net->socket, rxcall,
400-
RX_USER_ABORT, ret, "KSD");
402+
RX_USER_ABORT, ret,
403+
afs_abort_send_data_error);
401404
} else {
402405
len = 0;
403406
iov_iter_kvec(&msg.msg_iter, ITER_DEST, NULL, 0, 0);
@@ -527,7 +530,8 @@ static void afs_deliver_to_call(struct afs_call *call)
527530
case -ENOTSUPP:
528531
abort_code = RXGEN_OPCODE;
529532
rxrpc_kernel_abort_call(call->net->socket, call->rxcall,
530-
abort_code, ret, "KIV");
533+
abort_code, ret,
534+
afs_abort_op_not_supported);
531535
goto local_abort;
532536
case -EIO:
533537
pr_err("kAFS: Call %u in bad state %u\n",
@@ -542,12 +546,14 @@ static void afs_deliver_to_call(struct afs_call *call)
542546
if (state != AFS_CALL_CL_AWAIT_REPLY)
543547
abort_code = RXGEN_SS_UNMARSHAL;
544548
rxrpc_kernel_abort_call(call->net->socket, call->rxcall,
545-
abort_code, ret, "KUM");
549+
abort_code, ret,
550+
afs_abort_unmarshal_error);
546551
goto local_abort;
547552
default:
548553
abort_code = RX_CALL_DEAD;
549554
rxrpc_kernel_abort_call(call->net->socket, call->rxcall,
550-
abort_code, ret, "KER");
555+
abort_code, ret,
556+
afs_abort_general_error);
551557
goto local_abort;
552558
}
553559
}
@@ -619,7 +625,8 @@ long afs_wait_for_call_to_complete(struct afs_call *call,
619625
/* Kill off the call if it's still live. */
620626
_debug("call interrupted");
621627
if (rxrpc_kernel_abort_call(call->net->socket, call->rxcall,
622-
RX_USER_ABORT, -EINTR, "KWI"))
628+
RX_USER_ABORT, -EINTR,
629+
afs_abort_interrupted))
623630
afs_set_call_complete(call, -EINTR, 0);
624631
}
625632
}
@@ -836,7 +843,8 @@ void afs_send_empty_reply(struct afs_call *call)
836843
case -ENOMEM:
837844
_debug("oom");
838845
rxrpc_kernel_abort_call(net->socket, call->rxcall,
839-
RXGEN_SS_MARSHAL, -ENOMEM, "KOO");
846+
RXGEN_SS_MARSHAL, -ENOMEM,
847+
afs_abort_oom);
840848
fallthrough;
841849
default:
842850
_leave(" [error]");
@@ -878,7 +886,8 @@ void afs_send_simple_reply(struct afs_call *call, const void *buf, size_t len)
878886
if (n == -ENOMEM) {
879887
_debug("oom");
880888
rxrpc_kernel_abort_call(net->socket, call->rxcall,
881-
RXGEN_SS_MARSHAL, -ENOMEM, "KOO");
889+
RXGEN_SS_MARSHAL, -ENOMEM,
890+
afs_abort_oom);
882891
}
883892
_leave(" [error]");
884893
}

include/net/af_rxrpc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ struct key;
1515
struct sock;
1616
struct socket;
1717
struct rxrpc_call;
18+
enum rxrpc_abort_reason;
1819

1920
enum rxrpc_interruptibility {
2021
RXRPC_INTERRUPTIBLE, /* Call is interruptible */
@@ -55,7 +56,7 @@ int rxrpc_kernel_send_data(struct socket *, struct rxrpc_call *,
5556
int rxrpc_kernel_recv_data(struct socket *, struct rxrpc_call *,
5657
struct iov_iter *, size_t *, bool, u32 *, u16 *);
5758
bool rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *,
58-
u32, int, const char *);
59+
u32, int, enum rxrpc_abort_reason);
5960
void rxrpc_kernel_end_call(struct socket *, struct rxrpc_call *);
6061
void rxrpc_kernel_get_peer(struct socket *, struct rxrpc_call *,
6162
struct sockaddr_rxrpc *);

include/trace/events/rxrpc.h

Lines changed: 111 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,104 @@
1616
/*
1717
* Declare tracing information enums and their string mappings for display.
1818
*/
19+
#define rxrpc_abort_reasons \
20+
/* AFS errors */ \
21+
EM(afs_abort_general_error, "afs-error") \
22+
EM(afs_abort_interrupted, "afs-intr") \
23+
EM(afs_abort_oom, "afs-oom") \
24+
EM(afs_abort_op_not_supported, "afs-op-notsupp") \
25+
EM(afs_abort_probeuuid_negative, "afs-probeuuid-neg") \
26+
EM(afs_abort_send_data_error, "afs-send-data") \
27+
EM(afs_abort_unmarshal_error, "afs-unmarshal") \
28+
/* rxperf errors */ \
29+
EM(rxperf_abort_general_error, "rxperf-error") \
30+
EM(rxperf_abort_oom, "rxperf-oom") \
31+
EM(rxperf_abort_op_not_supported, "rxperf-op-notsupp") \
32+
EM(rxperf_abort_unmarshal_error, "rxperf-unmarshal") \
33+
/* RxKAD security errors */ \
34+
EM(rxkad_abort_1_short_check, "rxkad1-short-check") \
35+
EM(rxkad_abort_1_short_data, "rxkad1-short-data") \
36+
EM(rxkad_abort_1_short_encdata, "rxkad1-short-encdata") \
37+
EM(rxkad_abort_1_short_header, "rxkad1-short-hdr") \
38+
EM(rxkad_abort_2_short_check, "rxkad2-short-check") \
39+
EM(rxkad_abort_2_short_data, "rxkad2-short-data") \
40+
EM(rxkad_abort_2_short_header, "rxkad2-short-hdr") \
41+
EM(rxkad_abort_2_short_len, "rxkad2-short-len") \
42+
EM(rxkad_abort_bad_checksum, "rxkad2-bad-cksum") \
43+
EM(rxkad_abort_chall_key_expired, "rxkad-chall-key-exp") \
44+
EM(rxkad_abort_chall_level, "rxkad-chall-level") \
45+
EM(rxkad_abort_chall_no_key, "rxkad-chall-nokey") \
46+
EM(rxkad_abort_chall_short, "rxkad-chall-short") \
47+
EM(rxkad_abort_chall_version, "rxkad-chall-version") \
48+
EM(rxkad_abort_resp_bad_callid, "rxkad-resp-bad-callid") \
49+
EM(rxkad_abort_resp_bad_checksum, "rxkad-resp-bad-cksum") \
50+
EM(rxkad_abort_resp_bad_param, "rxkad-resp-bad-param") \
51+
EM(rxkad_abort_resp_call_ctr, "rxkad-resp-call-ctr") \
52+
EM(rxkad_abort_resp_call_state, "rxkad-resp-call-state") \
53+
EM(rxkad_abort_resp_key_expired, "rxkad-resp-key-exp") \
54+
EM(rxkad_abort_resp_key_rejected, "rxkad-resp-key-rej") \
55+
EM(rxkad_abort_resp_level, "rxkad-resp-level") \
56+
EM(rxkad_abort_resp_nokey, "rxkad-resp-nokey") \
57+
EM(rxkad_abort_resp_ooseq, "rxkad-resp-ooseq") \
58+
EM(rxkad_abort_resp_short, "rxkad-resp-short") \
59+
EM(rxkad_abort_resp_short_tkt, "rxkad-resp-short-tkt") \
60+
EM(rxkad_abort_resp_tkt_aname, "rxkad-resp-tk-aname") \
61+
EM(rxkad_abort_resp_tkt_expired, "rxkad-resp-tk-exp") \
62+
EM(rxkad_abort_resp_tkt_future, "rxkad-resp-tk-future") \
63+
EM(rxkad_abort_resp_tkt_inst, "rxkad-resp-tk-inst") \
64+
EM(rxkad_abort_resp_tkt_len, "rxkad-resp-tk-len") \
65+
EM(rxkad_abort_resp_tkt_realm, "rxkad-resp-tk-realm") \
66+
EM(rxkad_abort_resp_tkt_short, "rxkad-resp-tk-short") \
67+
EM(rxkad_abort_resp_tkt_sinst, "rxkad-resp-tk-sinst") \
68+
EM(rxkad_abort_resp_tkt_sname, "rxkad-resp-tk-sname") \
69+
EM(rxkad_abort_resp_unknown_tkt, "rxkad-resp-unknown-tkt") \
70+
EM(rxkad_abort_resp_version, "rxkad-resp-version") \
71+
/* rxrpc errors */ \
72+
EM(rxrpc_abort_call_improper_term, "call-improper-term") \
73+
EM(rxrpc_abort_call_reset, "call-reset") \
74+
EM(rxrpc_abort_call_sendmsg, "call-sendmsg") \
75+
EM(rxrpc_abort_call_sock_release, "call-sock-rel") \
76+
EM(rxrpc_abort_call_sock_release_tba, "call-sock-rel-tba") \
77+
EM(rxrpc_abort_call_timeout, "call-timeout") \
78+
EM(rxrpc_abort_no_service_key, "no-serv-key") \
79+
EM(rxrpc_abort_nomem, "nomem") \
80+
EM(rxrpc_abort_service_not_offered, "serv-not-offered") \
81+
EM(rxrpc_abort_shut_down, "shut-down") \
82+
EM(rxrpc_abort_unsupported_security, "unsup-sec") \
83+
EM(rxrpc_badmsg_bad_abort, "bad-abort") \
84+
EM(rxrpc_badmsg_bad_jumbo, "bad-jumbo") \
85+
EM(rxrpc_badmsg_short_ack, "short-ack") \
86+
EM(rxrpc_badmsg_short_ack_info, "short-ack-info") \
87+
EM(rxrpc_badmsg_short_hdr, "short-hdr") \
88+
EM(rxrpc_badmsg_unsupported_packet, "unsup-pkt") \
89+
EM(rxrpc_badmsg_zero_call, "zero-call") \
90+
EM(rxrpc_badmsg_zero_seq, "zero-seq") \
91+
EM(rxrpc_badmsg_zero_service, "zero-service") \
92+
EM(rxrpc_eproto_ackr_outside_window, "ackr-out-win") \
93+
EM(rxrpc_eproto_ackr_sack_overflow, "ackr-sack-over") \
94+
EM(rxrpc_eproto_ackr_short_sack, "ackr-short-sack") \
95+
EM(rxrpc_eproto_ackr_zero, "ackr-zero") \
96+
EM(rxrpc_eproto_bad_upgrade, "bad-upgrade") \
97+
EM(rxrpc_eproto_data_after_last, "data-after-last") \
98+
EM(rxrpc_eproto_different_last, "diff-last") \
99+
EM(rxrpc_eproto_early_reply, "early-reply") \
100+
EM(rxrpc_eproto_improper_term, "improper-term") \
101+
EM(rxrpc_eproto_no_client_call, "no-cl-call") \
102+
EM(rxrpc_eproto_no_client_conn, "no-cl-conn") \
103+
EM(rxrpc_eproto_no_service_call, "no-sv-call") \
104+
EM(rxrpc_eproto_reupgrade, "re-upgrade") \
105+
EM(rxrpc_eproto_rxnull_challenge, "rxnull-chall") \
106+
EM(rxrpc_eproto_rxnull_response, "rxnull-resp") \
107+
EM(rxrpc_eproto_tx_rot_last, "tx-rot-last") \
108+
EM(rxrpc_eproto_unexpected_ack, "unex-ack") \
109+
EM(rxrpc_eproto_unexpected_ackall, "unex-ackall") \
110+
EM(rxrpc_eproto_unexpected_implicit_end, "unex-impl-end") \
111+
EM(rxrpc_eproto_unexpected_reply, "unex-reply") \
112+
EM(rxrpc_eproto_wrong_security, "wrong-sec") \
113+
EM(rxrpc_recvmsg_excess_data, "recvmsg-excess") \
114+
EM(rxrpc_recvmsg_short_data, "recvmsg-short") \
115+
E_(rxrpc_sendmsg_late_send, "sendmsg-late")
116+
19117
#define rxrpc_call_poke_traces \
20118
EM(rxrpc_call_poke_abort, "Abort") \
21119
EM(rxrpc_call_poke_complete, "Compl") \
@@ -382,6 +480,7 @@
382480
#define EM(a, b) a,
383481
#define E_(a, b) a
384482

483+
enum rxrpc_abort_reason { rxrpc_abort_reasons } __mode(byte);
385484
enum rxrpc_bundle_trace { rxrpc_bundle_traces } __mode(byte);
386485
enum rxrpc_call_poke_trace { rxrpc_call_poke_traces } __mode(byte);
387486
enum rxrpc_call_trace { rxrpc_call_traces } __mode(byte);
@@ -410,9 +509,13 @@ enum rxrpc_txqueue_trace { rxrpc_txqueue_traces } __mode(byte);
410509
*/
411510
#undef EM
412511
#undef E_
512+
513+
#ifndef RXRPC_TRACE_ONLY_DEFINE_ENUMS
514+
413515
#define EM(a, b) TRACE_DEFINE_ENUM(a);
414516
#define E_(a, b) TRACE_DEFINE_ENUM(a);
415517

518+
rxrpc_abort_reasons;
416519
rxrpc_bundle_traces;
417520
rxrpc_call_poke_traces;
418521
rxrpc_call_traces;
@@ -663,14 +766,14 @@ TRACE_EVENT(rxrpc_rx_done,
663766
);
664767

665768
TRACE_EVENT(rxrpc_abort,
666-
TP_PROTO(unsigned int call_nr, const char *why, u32 cid, u32 call_id,
667-
rxrpc_seq_t seq, int abort_code, int error),
769+
TP_PROTO(unsigned int call_nr, enum rxrpc_abort_reason why,
770+
u32 cid, u32 call_id, rxrpc_seq_t seq, int abort_code, int error),
668771

669772
TP_ARGS(call_nr, why, cid, call_id, seq, abort_code, error),
670773

671774
TP_STRUCT__entry(
672775
__field(unsigned int, call_nr )
673-
__array(char, why, 4 )
776+
__field(enum rxrpc_abort_reason, why )
674777
__field(u32, cid )
675778
__field(u32, call_id )
676779
__field(rxrpc_seq_t, seq )
@@ -679,8 +782,8 @@ TRACE_EVENT(rxrpc_abort,
679782
),
680783

681784
TP_fast_assign(
682-
memcpy(__entry->why, why, 4);
683785
__entry->call_nr = call_nr;
786+
__entry->why = why;
684787
__entry->cid = cid;
685788
__entry->call_id = call_id;
686789
__entry->abort_code = abort_code;
@@ -691,7 +794,8 @@ TRACE_EVENT(rxrpc_abort,
691794
TP_printk("c=%08x %08x:%08x s=%u a=%d e=%d %s",
692795
__entry->call_nr,
693796
__entry->cid, __entry->call_id, __entry->seq,
694-
__entry->abort_code, __entry->error, __entry->why)
797+
__entry->abort_code, __entry->error,
798+
__print_symbolic(__entry->why, rxrpc_abort_reasons))
695799
);
696800

697801
TRACE_EVENT(rxrpc_call_complete,
@@ -1527,30 +1631,6 @@ TRACE_EVENT(rxrpc_improper_term,
15271631
__entry->abort_code)
15281632
);
15291633

1530-
TRACE_EVENT(rxrpc_rx_eproto,
1531-
TP_PROTO(struct rxrpc_call *call, rxrpc_serial_t serial,
1532-
const char *why),
1533-
1534-
TP_ARGS(call, serial, why),
1535-
1536-
TP_STRUCT__entry(
1537-
__field(unsigned int, call )
1538-
__field(rxrpc_serial_t, serial )
1539-
__field(const char *, why )
1540-
),
1541-
1542-
TP_fast_assign(
1543-
__entry->call = call ? call->debug_id : 0;
1544-
__entry->serial = serial;
1545-
__entry->why = why;
1546-
),
1547-
1548-
TP_printk("c=%08x EPROTO %08x %s",
1549-
__entry->call,
1550-
__entry->serial,
1551-
__entry->why)
1552-
);
1553-
15541634
TRACE_EVENT(rxrpc_connect_call,
15551635
TP_PROTO(struct rxrpc_call *call),
15561636

@@ -1848,6 +1928,8 @@ TRACE_EVENT(rxrpc_call_poked,
18481928

18491929
#undef EM
18501930
#undef E_
1931+
1932+
#endif /* RXRPC_TRACE_ONLY_DEFINE_ENUMS */
18511933
#endif /* _TRACE_RXRPC_H */
18521934

18531935
/* This part must be outside protection */

0 commit comments

Comments
 (0)