Skip to content

Commit

Permalink
rxrpc: trace: Don't use __builtin_return_address for rxrpc_local tracing
Browse files Browse the repository at this point in the history
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: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
  • Loading branch information
David Howells committed Dec 1, 2022
1 parent f14febd commit 0fde882
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 76 deletions.
49 changes: 36 additions & 13 deletions include/trace/events/rxrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,35 @@
E_(rxrpc_skb_unshared_nomem, "US0")

#define rxrpc_local_traces \
EM(rxrpc_local_got, "GOT") \
EM(rxrpc_local_new, "NEW") \
EM(rxrpc_local_processing, "PRO") \
EM(rxrpc_local_put, "PUT") \
EM(rxrpc_local_queued, "QUE") \
E_(rxrpc_local_tx_ack, "TAK")
EM(rxrpc_local_free, "FREE ") \
EM(rxrpc_local_get_client_conn, "GET conn-cln") \
EM(rxrpc_local_get_for_use, "GET for-use ") \
EM(rxrpc_local_get_peer, "GET peer ") \
EM(rxrpc_local_get_prealloc_conn, "GET conn-pre") \
EM(rxrpc_local_get_queue, "GET queue ") \
EM(rxrpc_local_new, "NEW ") \
EM(rxrpc_local_processing, "PROCESSING ") \
EM(rxrpc_local_put_already_queued, "PUT alreadyq") \
EM(rxrpc_local_put_bind, "PUT bind ") \
EM(rxrpc_local_put_for_use, "PUT for-use ") \
EM(rxrpc_local_put_kill_conn, "PUT conn-kil") \
EM(rxrpc_local_put_peer, "PUT peer ") \
EM(rxrpc_local_put_prealloc_conn, "PUT conn-pre") \
EM(rxrpc_local_put_release_sock, "PUT rel-sock") \
EM(rxrpc_local_put_queue, "PUT queue ") \
EM(rxrpc_local_queued, "QUEUED ") \
EM(rxrpc_local_see_tx_ack, "SEE tx-ack ") \
EM(rxrpc_local_stop, "STOP ") \
EM(rxrpc_local_stopped, "STOPPED ") \
EM(rxrpc_local_unuse_bind, "UNU bind ") \
EM(rxrpc_local_unuse_conn_work, "UNU conn-wrk") \
EM(rxrpc_local_unuse_peer_keepalive, "UNU peer-kpa") \
EM(rxrpc_local_unuse_release_sock, "UNU rel-sock") \
EM(rxrpc_local_unuse_work, "UNU work ") \
EM(rxrpc_local_use_conn_work, "USE conn-wrk") \
EM(rxrpc_local_use_lookup, "USE lookup ") \
EM(rxrpc_local_use_peer_keepalive, "USE peer-kpa") \
E_(rxrpc_local_use_work, "USE work ")

#define rxrpc_peer_traces \
EM(rxrpc_peer_got, "GOT") \
Expand Down Expand Up @@ -345,29 +368,29 @@ rxrpc_txqueue_traces;

TRACE_EVENT(rxrpc_local,
TP_PROTO(unsigned int local_debug_id, enum rxrpc_local_trace op,
int usage, const void *where),
int ref, int usage),

TP_ARGS(local_debug_id, op, usage, where),
TP_ARGS(local_debug_id, op, ref, usage),

TP_STRUCT__entry(
__field(unsigned int, local )
__field(int, op )
__field(int, ref )
__field(int, usage )
__field(const void *, where )
),

TP_fast_assign(
__entry->local = local_debug_id;
__entry->op = op;
__entry->ref = ref;
__entry->usage = usage;
__entry->where = where;
),

TP_printk("L=%08x %s u=%d sp=%pSR",
TP_printk("L=%08x %s r=%d u=%d",
__entry->local,
__print_symbolic(__entry->op, rxrpc_local_traces),
__entry->usage,
__entry->where)
__entry->ref,
__entry->usage)
);

TRACE_EVENT(rxrpc_peer,
Expand Down
8 changes: 4 additions & 4 deletions net/rxrpc/af_rxrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ static int rxrpc_bind(struct socket *sock, struct sockaddr *saddr, int len)

service_in_use:
write_unlock(&local->services_lock);
rxrpc_unuse_local(local);
rxrpc_put_local(local);
rxrpc_unuse_local(local, rxrpc_local_unuse_bind);
rxrpc_put_local(local, rxrpc_local_put_bind);
ret = -EADDRINUSE;
error_unlock:
release_sock(&rx->sk);
Expand Down Expand Up @@ -888,8 +888,8 @@ static int rxrpc_release_sock(struct sock *sk)
flush_workqueue(rxrpc_workqueue);
rxrpc_purge_queue(&sk->sk_receive_queue);

rxrpc_unuse_local(rx->local);
rxrpc_put_local(rx->local);
rxrpc_unuse_local(rx->local, rxrpc_local_unuse_release_sock);
rxrpc_put_local(rx->local, rxrpc_local_put_release_sock);
rx->local = NULL;
key_put(rx->key);
rx->key = NULL;
Expand Down
41 changes: 32 additions & 9 deletions net/rxrpc/ar-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -979,22 +979,45 @@ extern void rxrpc_process_local_events(struct rxrpc_local *);
* local_object.c
*/
struct rxrpc_local *rxrpc_lookup_local(struct net *, const struct sockaddr_rxrpc *);
struct rxrpc_local *rxrpc_get_local(struct rxrpc_local *);
struct rxrpc_local *rxrpc_get_local_maybe(struct rxrpc_local *);
void rxrpc_put_local(struct rxrpc_local *);
struct rxrpc_local *rxrpc_use_local(struct rxrpc_local *);
void rxrpc_unuse_local(struct rxrpc_local *);
struct rxrpc_local *rxrpc_get_local(struct rxrpc_local *, enum rxrpc_local_trace);
struct rxrpc_local *rxrpc_get_local_maybe(struct rxrpc_local *, enum rxrpc_local_trace);
void rxrpc_put_local(struct rxrpc_local *, enum rxrpc_local_trace);
struct rxrpc_local *rxrpc_use_local(struct rxrpc_local *, enum rxrpc_local_trace);
void rxrpc_unuse_local(struct rxrpc_local *, enum rxrpc_local_trace);
void rxrpc_queue_local(struct rxrpc_local *);
void rxrpc_destroy_all_locals(struct rxrpc_net *);

static inline bool __rxrpc_unuse_local(struct rxrpc_local *local)
static inline bool __rxrpc_unuse_local(struct rxrpc_local *local,
enum rxrpc_local_trace why)
{
return atomic_dec_return(&local->active_users) == 0;
unsigned int debug_id = local->debug_id;
int r, u;

r = refcount_read(&local->ref);
u = atomic_dec_return(&local->active_users);
trace_rxrpc_local(debug_id, why, r, u);
return u == 0;
}

static inline bool __rxrpc_use_local(struct rxrpc_local *local,
enum rxrpc_local_trace why)
{
int r, u;

r = refcount_read(&local->ref);
u = atomic_fetch_add_unless(&local->active_users, 1, 0);
trace_rxrpc_local(local->debug_id, why, r, u);
return u != 0;
}

static inline bool __rxrpc_use_local(struct rxrpc_local *local)
static inline void rxrpc_see_local(struct rxrpc_local *local,
enum rxrpc_local_trace why)
{
return atomic_fetch_add_unless(&local->active_users, 1, 0) != 0;
int r, u;

r = refcount_read(&local->ref);
u = atomic_read(&local->active_users);
trace_rxrpc_local(local->debug_id, why, r, u);
}

/*
Expand Down
4 changes: 2 additions & 2 deletions net/rxrpc/call_accept.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void rxrpc_discard_prealloc(struct rxrpc_sock *rx)
tail = b->peer_backlog_tail;
while (CIRC_CNT(head, tail, size) > 0) {
struct rxrpc_peer *peer = b->peer_backlog[tail];
rxrpc_put_local(peer->local);
rxrpc_put_local(peer->local, rxrpc_local_put_prealloc_conn);
kfree(peer);
tail = (tail + 1) & (size - 1);
}
Expand Down Expand Up @@ -305,7 +305,7 @@ static struct rxrpc_call *rxrpc_alloc_incoming_call(struct rxrpc_sock *rx,
b->conn_backlog[conn_tail] = NULL;
smp_store_release(&b->conn_backlog_tail,
(conn_tail + 1) & (RXRPC_BACKLOG_MAX - 1));
conn->local = rxrpc_get_local(local);
conn->local = rxrpc_get_local(local, rxrpc_local_get_prealloc_conn);
conn->peer = peer;
rxrpc_see_connection(conn);
rxrpc_new_incoming_connection(rx, conn, sec, skb);
Expand Down
2 changes: 1 addition & 1 deletion net/rxrpc/call_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void rxrpc_send_ACK(struct rxrpc_call *call, u8 ack_reason,
if (in_task()) {
rxrpc_transmit_ack_packets(call->peer->local);
} else {
rxrpc_get_local(local);
rxrpc_get_local(local, rxrpc_local_get_queue);
rxrpc_queue_local(local);
}
}
Expand Down
2 changes: 1 addition & 1 deletion net/rxrpc/conn_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ rxrpc_alloc_client_connection(struct rxrpc_bundle *bundle, gfp_t gfp)

rxrpc_get_bundle(bundle);
rxrpc_get_peer(conn->peer);
rxrpc_get_local(conn->local);
rxrpc_get_local(conn->local, rxrpc_local_get_client_conn);
key_get(conn->key);

trace_rxrpc_conn(conn->debug_id, rxrpc_conn_new_client,
Expand Down
4 changes: 2 additions & 2 deletions net/rxrpc/conn_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,9 @@ void rxrpc_process_connection(struct work_struct *work)

rxrpc_see_connection(conn);

if (__rxrpc_use_local(conn->local)) {
if (__rxrpc_use_local(conn->local, rxrpc_local_use_conn_work)) {
rxrpc_do_process_connection(conn);
rxrpc_unuse_local(conn->local);
rxrpc_unuse_local(conn->local, rxrpc_local_unuse_conn_work);
}

rxrpc_put_connection(conn);
Expand Down
2 changes: 1 addition & 1 deletion net/rxrpc/conn_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ static void rxrpc_destroy_connection(struct rcu_head *rcu)

if (atomic_dec_and_test(&conn->local->rxnet->nr_conns))
wake_up_var(&conn->local->rxnet->nr_conns);
rxrpc_put_local(conn->local);
rxrpc_put_local(conn->local, rxrpc_local_put_kill_conn);

kfree(conn);
_leave("");
Expand Down
4 changes: 2 additions & 2 deletions net/rxrpc/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ static void rxrpc_post_packet_to_local(struct rxrpc_local *local,
{
_enter("%p,%p", local, skb);

if (rxrpc_get_local_maybe(local)) {
if (rxrpc_get_local_maybe(local, rxrpc_local_get_queue)) {
skb_queue_tail(&local->event_queue, skb);
rxrpc_queue_local(local);
} else {
Expand All @@ -1146,7 +1146,7 @@ static void rxrpc_post_packet_to_local(struct rxrpc_local *local,
*/
static void rxrpc_reject_packet(struct rxrpc_local *local, struct sk_buff *skb)
{
if (rxrpc_get_local_maybe(local)) {
if (rxrpc_get_local_maybe(local, rxrpc_local_get_queue)) {
skb_queue_tail(&local->reject_queue, skb);
rxrpc_queue_local(local);
} else {
Expand Down
Loading

0 comments on commit 0fde882

Please sign in to comment.