Commit a25e21f0 authored by David Howells's avatar David Howells
Browse files

rxrpc, afs: Use debug_ids rather than pointers in traces



In rxrpc and afs, use the debug_ids that are monotonically allocated to
various objects as they're allocated rather than pointers as kernel
pointers are now hashed making them less useful.  Further, the debug ids
aren't reused anywhere nearly as quickly.

In addition, allow kernel services that use rxrpc, such as afs, to take
numbers from the rxrpc counter, assign them to their own call struct and
pass them in to rxrpc for both client and service calls so that the trace
lines for each will have the same ID tag.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent 827efed6
......@@ -118,6 +118,7 @@ struct afs_call {
bool ret_reply0; /* T if should return reply[0] on success */
bool upgrade; /* T to request service upgrade */
u16 service_id; /* Actual service ID (after upgrade) */
unsigned int debug_id; /* Trace ID */
u32 operation_ID; /* operation ID for an incoming call */
u32 count; /* count for use in unmarshalling */
__be32 tmp; /* place to extract temporary data */
......
......@@ -131,6 +131,7 @@ static struct afs_call *afs_alloc_call(struct afs_net *net,
call->type = type;
call->net = net;
call->debug_id = atomic_inc_return(&rxrpc_debug_id);
atomic_set(&call->usage, 1);
INIT_WORK(&call->async_work, afs_process_async_call);
init_waitqueue_head(&call->waitq);
......@@ -169,11 +170,12 @@ void afs_put_call(struct afs_call *call)
afs_put_server(call->net, call->cm_server);
afs_put_cb_interest(call->net, call->cbi);
kfree(call->request);
kfree(call);
o = atomic_dec_return(&net->nr_outstanding_calls);
trace_afs_call(call, afs_call_trace_free, 0, o,
__builtin_return_address(0));
kfree(call);
o = atomic_dec_return(&net->nr_outstanding_calls);
if (o == 0)
wake_up_atomic_t(&net->nr_outstanding_calls);
}
......@@ -378,7 +380,8 @@ long afs_make_call(struct afs_addr_cursor *ac, struct afs_call *call,
(async ?
afs_wake_up_async_call :
afs_wake_up_call_waiter),
call->upgrade);
call->upgrade,
call->debug_id);
if (IS_ERR(rxcall)) {
ret = PTR_ERR(rxcall);
goto error_kill_call;
......@@ -727,7 +730,8 @@ void afs_charge_preallocation(struct work_struct *work)
afs_wake_up_async_call,
afs_rx_attach,
(unsigned long)call,
GFP_KERNEL) < 0)
GFP_KERNEL,
call->debug_id) < 0)
break;
call = NULL;
}
......
......@@ -31,6 +31,11 @@ enum rxrpc_call_completion {
NR__RXRPC_CALL_COMPLETIONS
};
/*
* Debug ID counter for tracing.
*/
extern atomic_t rxrpc_debug_id;
typedef void (*rxrpc_notify_rx_t)(struct sock *, struct rxrpc_call *,
unsigned long);
typedef void (*rxrpc_notify_end_tx_t)(struct sock *, struct rxrpc_call *,
......@@ -50,7 +55,8 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *,
s64,
gfp_t,
rxrpc_notify_rx_t,
bool);
bool,
unsigned int);
int rxrpc_kernel_send_data(struct socket *, struct rxrpc_call *,
struct msghdr *, size_t,
rxrpc_notify_end_tx_t);
......@@ -63,7 +69,8 @@ void rxrpc_kernel_get_peer(struct socket *, struct rxrpc_call *,
struct sockaddr_rxrpc *);
u64 rxrpc_kernel_get_rtt(struct socket *, struct rxrpc_call *);
int rxrpc_kernel_charge_accept(struct socket *, rxrpc_notify_rx_t,
rxrpc_user_attach_call_t, unsigned long, gfp_t);
rxrpc_user_attach_call_t, unsigned long, gfp_t,
unsigned int);
void rxrpc_kernel_set_tx_length(struct socket *, struct rxrpc_call *, s64);
int rxrpc_kernel_retry_call(struct socket *, struct rxrpc_call *,
struct sockaddr_rxrpc *, struct key *);
......
......@@ -133,8 +133,7 @@ TRACE_EVENT(afs_recv_data,
TP_ARGS(call, count, offset, want_more, ret),
TP_STRUCT__entry(
__field(struct rxrpc_call *, rxcall )
__field(struct afs_call *, call )
__field(unsigned int, call )
__field(enum afs_call_state, state )
__field(unsigned int, count )
__field(unsigned int, offset )
......@@ -144,8 +143,7 @@ TRACE_EVENT(afs_recv_data,
),
TP_fast_assign(
__entry->rxcall = call->rxcall;
__entry->call = call;
__entry->call = call->debug_id;
__entry->state = call->state;
__entry->unmarshall = call->unmarshall;
__entry->count = count;
......@@ -154,8 +152,7 @@ TRACE_EVENT(afs_recv_data,
__entry->ret = ret;
),
TP_printk("c=%p ac=%p s=%u u=%u %u/%u wm=%u ret=%d",
__entry->rxcall,
TP_printk("c=%08x s=%u u=%u %u/%u wm=%u ret=%d",
__entry->call,
__entry->state, __entry->unmarshall,
__entry->offset, __entry->count,
......@@ -168,21 +165,18 @@ TRACE_EVENT(afs_notify_call,
TP_ARGS(rxcall, call),
TP_STRUCT__entry(
__field(struct rxrpc_call *, rxcall )
__field(struct afs_call *, call )
__field(unsigned int, call )
__field(enum afs_call_state, state )
__field(unsigned short, unmarshall )
),
TP_fast_assign(
__entry->rxcall = rxcall;
__entry->call = call;
__entry->call = call->debug_id;
__entry->state = call->state;
__entry->unmarshall = call->unmarshall;
),
TP_printk("c=%p ac=%p s=%u u=%u",
__entry->rxcall,
TP_printk("c=%08x s=%u u=%u",
__entry->call,
__entry->state, __entry->unmarshall)
);
......@@ -193,21 +187,18 @@ TRACE_EVENT(afs_cb_call,
TP_ARGS(call),
TP_STRUCT__entry(
__field(struct rxrpc_call *, rxcall )
__field(struct afs_call *, call )
__field(unsigned int, call )
__field(const char *, name )
__field(u32, op )
),
TP_fast_assign(
__entry->rxcall = call->rxcall;
__entry->call = call;
__entry->call = call->debug_id;
__entry->name = call->type->name;
__entry->op = call->operation_ID;
),
TP_printk("c=%p ac=%p %s o=%u",
__entry->rxcall,
TP_printk("c=%08x %s o=%u",
__entry->call,
__entry->name,
__entry->op)
......@@ -220,7 +211,7 @@ TRACE_EVENT(afs_call,
TP_ARGS(call, op, usage, outstanding, where),
TP_STRUCT__entry(
__field(struct afs_call *, call )
__field(unsigned int, call )
__field(int, op )
__field(int, usage )
__field(int, outstanding )
......@@ -228,14 +219,14 @@ TRACE_EVENT(afs_call,
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->op = op;
__entry->usage = usage;
__entry->outstanding = outstanding;
__entry->where = where;
),
TP_printk("c=%p %s u=%d o=%d sp=%pSR",
TP_printk("c=%08x %s u=%d o=%d sp=%pSR",
__entry->call,
__print_symbolic(__entry->op, afs_call_traces),
__entry->usage,
......@@ -249,13 +240,13 @@ TRACE_EVENT(afs_make_fs_call,
TP_ARGS(call, fid),
TP_STRUCT__entry(
__field(struct afs_call *, call )
__field(unsigned int, call )
__field(enum afs_fs_operation, op )
__field_struct(struct afs_fid, fid )
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->op = call->operation_ID;
if (fid) {
__entry->fid = *fid;
......@@ -266,7 +257,7 @@ TRACE_EVENT(afs_make_fs_call,
}
),
TP_printk("c=%p %06x:%06x:%06x %s",
TP_printk("c=%08x %06x:%06x:%06x %s",
__entry->call,
__entry->fid.vid,
__entry->fid.vnode,
......@@ -280,16 +271,16 @@ TRACE_EVENT(afs_make_vl_call,
TP_ARGS(call),
TP_STRUCT__entry(
__field(struct afs_call *, call )
__field(unsigned int, call )
__field(enum afs_vl_operation, op )
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->op = call->operation_ID;
),
TP_printk("c=%p %s",
TP_printk("c=%08x %s",
__entry->call,
__print_symbolic(__entry->op, afs_vl_operations))
);
......@@ -300,20 +291,20 @@ TRACE_EVENT(afs_call_done,
TP_ARGS(call),
TP_STRUCT__entry(
__field(struct afs_call *, call )
__field(unsigned int, call )
__field(struct rxrpc_call *, rx_call )
__field(int, ret )
__field(u32, abort_code )
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->rx_call = call->rxcall;
__entry->ret = call->error;
__entry->abort_code = call->abort_code;
),
TP_printk(" c=%p ret=%d ab=%d [%p]",
TP_printk(" c=%08x ret=%d ab=%d [%p]",
__entry->call,
__entry->ret,
__entry->abort_code,
......@@ -327,7 +318,7 @@ TRACE_EVENT(afs_send_pages,
TP_ARGS(call, msg, first, last, offset),
TP_STRUCT__entry(
__field(struct afs_call *, call )
__field(unsigned int, call )
__field(pgoff_t, first )
__field(pgoff_t, last )
__field(unsigned int, nr )
......@@ -337,7 +328,7 @@ TRACE_EVENT(afs_send_pages,
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->first = first;
__entry->last = last;
__entry->nr = msg->msg_iter.nr_segs;
......@@ -346,7 +337,7 @@ TRACE_EVENT(afs_send_pages,
__entry->flags = msg->msg_flags;
),
TP_printk(" c=%p %lx-%lx-%lx b=%x o=%x f=%x",
TP_printk(" c=%08x %lx-%lx-%lx b=%x o=%x f=%x",
__entry->call,
__entry->first, __entry->first + __entry->nr - 1, __entry->last,
__entry->bytes, __entry->offset,
......@@ -360,7 +351,7 @@ TRACE_EVENT(afs_sent_pages,
TP_ARGS(call, first, last, cursor, ret),
TP_STRUCT__entry(
__field(struct afs_call *, call )
__field(unsigned int, call )
__field(pgoff_t, first )
__field(pgoff_t, last )
__field(pgoff_t, cursor )
......@@ -368,14 +359,14 @@ TRACE_EVENT(afs_sent_pages,
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->first = first;
__entry->last = last;
__entry->cursor = cursor;
__entry->ret = ret;
),
TP_printk(" c=%p %lx-%lx c=%lx r=%d",
TP_printk(" c=%08x %lx-%lx c=%lx r=%d",
__entry->call,
__entry->first, __entry->last,
__entry->cursor, __entry->ret)
......@@ -450,7 +441,7 @@ TRACE_EVENT(afs_call_state,
TP_ARGS(call, from, to, ret, remote_abort),
TP_STRUCT__entry(
__field(struct afs_call *, call )
__field(unsigned int, call )
__field(enum afs_call_state, from )
__field(enum afs_call_state, to )
__field(int, ret )
......@@ -458,14 +449,14 @@ TRACE_EVENT(afs_call_state,
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->from = from;
__entry->to = to;
__entry->ret = ret;
__entry->abort = remote_abort;
),
TP_printk("c=%p %u->%u r=%d ab=%d",
TP_printk("c=%08x %u->%u r=%d ab=%d",
__entry->call,
__entry->from, __entry->to,
__entry->ret, __entry->abort)
......
......@@ -439,20 +439,20 @@ TRACE_EVENT(rxrpc_conn,
TP_ARGS(conn, op, usage, where),
TP_STRUCT__entry(
__field(struct rxrpc_connection *, conn )
__field(int, op )
__field(int, usage )
__field(const void *, where )
__field(unsigned int, conn )
__field(int, op )
__field(int, usage )
__field(const void *, where )
),
TP_fast_assign(
__entry->conn = conn;
__entry->conn = conn->debug_id;
__entry->op = op;
__entry->usage = usage;
__entry->where = where;
),
TP_printk("C=%p %s u=%d sp=%pSR",
TP_printk("C=%08x %s u=%d sp=%pSR",
__entry->conn,
__print_symbolic(__entry->op, rxrpc_conn_traces),
__entry->usage,
......@@ -466,7 +466,7 @@ TRACE_EVENT(rxrpc_client,
TP_ARGS(conn, channel, op),
TP_STRUCT__entry(
__field(struct rxrpc_connection *, conn )
__field(unsigned int, conn )
__field(u32, cid )
__field(int, channel )
__field(int, usage )
......@@ -475,7 +475,7 @@ TRACE_EVENT(rxrpc_client,
),
TP_fast_assign(
__entry->conn = conn;
__entry->conn = conn->debug_id;
__entry->channel = channel;
__entry->usage = atomic_read(&conn->usage);
__entry->op = op;
......@@ -483,7 +483,7 @@ TRACE_EVENT(rxrpc_client,
__entry->cs = conn->cache_state;
),
TP_printk("C=%p h=%2d %s %s i=%08x u=%d",
TP_printk("C=%08x h=%2d %s %s i=%08x u=%d",
__entry->conn,
__entry->channel,
__print_symbolic(__entry->op, rxrpc_client_traces),
......@@ -499,7 +499,7 @@ TRACE_EVENT(rxrpc_call,
TP_ARGS(call, op, usage, where, aux),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(unsigned int, call )
__field(int, op )
__field(int, usage )
__field(const void *, where )
......@@ -507,14 +507,14 @@ TRACE_EVENT(rxrpc_call,
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->op = op;
__entry->usage = usage;
__entry->where = where;
__entry->aux = aux;
),
TP_printk("c=%p %s u=%d sp=%pSR a=%p",
TP_printk("c=%08x %s u=%d sp=%pSR a=%p",
__entry->call,
__print_symbolic(__entry->op, rxrpc_call_traces),
__entry->usage,
......@@ -593,12 +593,13 @@ TRACE_EVENT(rxrpc_rx_done,
);
TRACE_EVENT(rxrpc_abort,
TP_PROTO(const char *why, u32 cid, u32 call_id, rxrpc_seq_t seq,
int abort_code, int error),
TP_PROTO(unsigned int call_nr, const char *why, u32 cid, u32 call_id,
rxrpc_seq_t seq, int abort_code, int error),
TP_ARGS(why, cid, call_id, seq, abort_code, error),
TP_ARGS(call_nr, why, cid, call_id, seq, abort_code, error),
TP_STRUCT__entry(
__field(unsigned int, call_nr )
__array(char, why, 4 )
__field(u32, cid )
__field(u32, call_id )
......@@ -609,6 +610,7 @@ TRACE_EVENT(rxrpc_abort,
TP_fast_assign(
memcpy(__entry->why, why, 4);
__entry->call_nr = call_nr;
__entry->cid = cid;
__entry->call_id = call_id;
__entry->abort_code = abort_code;
......@@ -616,7 +618,8 @@ TRACE_EVENT(rxrpc_abort,
__entry->seq = seq;
),
TP_printk("%08x:%08x s=%u a=%d e=%d %s",
TP_printk("c=%08x %08x:%08x s=%u a=%d e=%d %s",
__entry->call_nr,
__entry->cid, __entry->call_id, __entry->seq,
__entry->abort_code, __entry->error, __entry->why)
);
......@@ -627,7 +630,7 @@ TRACE_EVENT(rxrpc_transmit,
TP_ARGS(call, why),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(unsigned int, call )
__field(enum rxrpc_transmit_trace, why )
__field(rxrpc_seq_t, tx_hard_ack )
__field(rxrpc_seq_t, tx_top )
......@@ -635,14 +638,14 @@ TRACE_EVENT(rxrpc_transmit,
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->why = why;
__entry->tx_hard_ack = call->tx_hard_ack;
__entry->tx_top = call->tx_top;
__entry->tx_winsize = call->tx_winsize;
),
TP_printk("c=%p %s f=%08x n=%u/%u",
TP_printk("c=%08x %s f=%08x n=%u/%u",
__entry->call,
__print_symbolic(__entry->why, rxrpc_transmit_traces),
__entry->tx_hard_ack + 1,
......@@ -657,7 +660,7 @@ TRACE_EVENT(rxrpc_rx_data,
TP_ARGS(call, seq, serial, flags, anno),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(unsigned int, call )
__field(rxrpc_seq_t, seq )
__field(rxrpc_serial_t, serial )
__field(u8, flags )
......@@ -665,14 +668,14 @@ TRACE_EVENT(rxrpc_rx_data,
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->seq = seq;
__entry->serial = serial;
__entry->flags = flags;
__entry->anno = anno;
),
TP_printk("c=%p DATA %08x q=%08x fl=%02x a=%02x",
TP_printk("c=%08x DATA %08x q=%08x fl=%02x a=%02x",
__entry->call,
__entry->serial,
__entry->seq,
......@@ -688,7 +691,7 @@ TRACE_EVENT(rxrpc_rx_ack,
TP_ARGS(call, serial, ack_serial, first, prev, reason, n_acks),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(unsigned int, call )
__field(rxrpc_serial_t, serial )
__field(rxrpc_serial_t, ack_serial )
__field(rxrpc_seq_t, first )
......@@ -698,7 +701,7 @@ TRACE_EVENT(rxrpc_rx_ack,
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->serial = serial;
__entry->ack_serial = ack_serial;
__entry->first = first;
......@@ -707,7 +710,7 @@ TRACE_EVENT(rxrpc_rx_ack,
__entry->n_acks = n_acks;
),
TP_printk("c=%p %08x %s r=%08x f=%08x p=%08x n=%u",
TP_printk("c=%08x %08x %s r=%08x f=%08x p=%08x n=%u",
__entry->call,
__entry->serial,
__print_symbolic(__entry->reason, rxrpc_ack_names),
......@@ -724,18 +727,18 @@ TRACE_EVENT(rxrpc_rx_abort,
TP_ARGS(call, serial, abort_code),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(unsigned int, call )
__field(rxrpc_serial_t, serial )
__field(u32, abort_code )
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->serial = serial;
__entry->abort_code = abort_code;
),
TP_printk("c=%p ABORT %08x ac=%d",
TP_printk("c=%08x ABORT %08x ac=%d",
__entry->call,
__entry->serial,
__entry->abort_code)
......@@ -748,20 +751,20 @@ TRACE_EVENT(rxrpc_rx_rwind_change,
TP_ARGS(call, serial, rwind, wake),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(unsigned int, call )
__field(rxrpc_serial_t, serial )
__field(u32, rwind )
__field(bool, wake )
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->serial = serial;
__entry->rwind = rwind;
__entry->wake = wake;
),
TP_printk("c=%p %08x rw=%u%s",
TP_printk("c=%08x %08x rw=%u%s",
__entry->call,
__entry->serial,
__entry->rwind,
......@@ -775,7 +778,7 @@ TRACE_EVENT(rxrpc_tx_data,
TP_ARGS(call, seq, serial, flags, retrans, lose),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(unsigned int, call )
__field(rxrpc_seq_t, seq )
__field(rxrpc_serial_t, serial )
__field(u8, flags )
......@@ -784,7 +787,7 @@ TRACE_EVENT(rxrpc_tx_data,
),
TP_fast_assign(
__entry->call = call;
__entry->call = call->debug_id;
__entry->seq = seq;
__entry->serial = serial;
__entry->flags = flags;
......@@ -792,7 +795,7 @@ TRACE_EVENT(rxrpc_tx_data,
__entry->lose = lose;
),
TP_printk("c=%p DATA %08x q=%08x fl=%02x%s%s",
TP_printk("c=%08x DATA %08x q=%08x fl=%02x%s%s",
__entry->call,
__entry->serial,
__entry->seq,
......@@ -809,7 +812,7 @@ TRACE_EVENT(rxrpc_tx_ack,
TP_ARGS(call, serial, ack_first, ack_serial, reason, n_acks),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(unsigned int, call )
__field(rxrpc_serial_t, serial )
__field(rxrpc_seq_t, ack_first )
__field(rxrpc_serial_t, ack_serial )
......@@ -818,7 +821,7 @@ TRACE_EVENT(rxrpc_tx_ack,
),
TP_fast_assign(
__entry->call = call;
__entry->call = call ? call->debug_id : 0;
__entry->serial = serial;
__entry->ack_first = ack_first;
__entry->ack_serial = ack_serial;
......@@ -826,7 +829,7 @@ TRACE_EVENT(rxrpc_tx_ack,
__entry->n_acks = n_acks;
),
TP_printk(" c=%p ACK %08x %s f=%08x r=%08x n=%u",
TP_printk(" c=%08x ACK %08x %s f=%08x r=%08x n=%u",
__entry->call,
__entry->serial,
__print_symbolic(__entry->reason, rxrpc_ack_names),
......@@ -842,7 +845,7 @@ TRACE_EVENT(rxrpc_receive,
TP_ARGS(call, why, serial, seq),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(unsigned int, call )
__field(enum rxrpc_receive_trace, why )
__field(rxrpc_serial_t, serial )