rxrpc: trace: Don't use __builtin_return_address for rxrpc_conn tracing
authorDavid Howells <dhowells@redhat.com>
Fri, 21 Oct 2022 13:06:16 +0000 (14:06 +0100)
committerDavid Howells <dhowells@redhat.com>
Thu, 1 Dec 2022 13:36:39 +0000 (13:36 +0000)
In rxrpc tracing, use enums to generate lists of points of interest rather
than __builtin_return_address() for the rxrpc_conn tracepoint

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org

include/trace/events/rxrpc.h
net/rxrpc/ar-internal.h
net/rxrpc/call_accept.c
net/rxrpc/call_object.c
net/rxrpc/conn_client.c
net/rxrpc/conn_event.c
net/rxrpc/conn_object.c
net/rxrpc/conn_service.c
net/rxrpc/input.c

index 1c74143a51c150c1ac8f0402d5aebd2c7e146bbe..e09568a8c17382f23f022f2d6631934c1b1dd561 100644 (file)
        E_(rxrpc_peer_put_keepalive,            "PUT keepaliv")
 
 #define rxrpc_conn_traces \
-       EM(rxrpc_conn_got,                      "GOT") \
-       EM(rxrpc_conn_new_client,               "NWc") \
-       EM(rxrpc_conn_new_service,              "NWs") \
-       EM(rxrpc_conn_put_client,               "PTc") \
-       EM(rxrpc_conn_put_service,              "PTs") \
-       EM(rxrpc_conn_queued,                   "QUE") \
-       EM(rxrpc_conn_reap_service,             "RPs") \
-       E_(rxrpc_conn_seen,                     "SEE")
+       EM(rxrpc_conn_free,                     "FREE        ") \
+       EM(rxrpc_conn_get_activate_call,        "GET act-call") \
+       EM(rxrpc_conn_get_call_input,           "GET inp-call") \
+       EM(rxrpc_conn_get_conn_input,           "GET inp-conn") \
+       EM(rxrpc_conn_get_idle,                 "GET idle    ") \
+       EM(rxrpc_conn_get_poke,                 "GET poke    ") \
+       EM(rxrpc_conn_get_service_conn,         "GET svc-conn") \
+       EM(rxrpc_conn_new_client,               "NEW client  ") \
+       EM(rxrpc_conn_new_service,              "NEW service ") \
+       EM(rxrpc_conn_put_already_queued,       "PUT alreadyq") \
+       EM(rxrpc_conn_put_call,                 "PUT call    ") \
+       EM(rxrpc_conn_put_call_input,           "PUT inp-call") \
+       EM(rxrpc_conn_put_conn_input,           "PUT inp-conn") \
+       EM(rxrpc_conn_put_discard,              "PUT discard ") \
+       EM(rxrpc_conn_put_discard_idle,         "PUT disc-idl") \
+       EM(rxrpc_conn_put_local_dead,           "PUT loc-dead") \
+       EM(rxrpc_conn_put_noreuse,              "PUT noreuse ") \
+       EM(rxrpc_conn_put_poke,                 "PUT poke    ") \
+       EM(rxrpc_conn_put_unbundle,             "PUT unbundle") \
+       EM(rxrpc_conn_put_unidle,               "PUT unidle  ") \
+       EM(rxrpc_conn_put_work,                 "PUT work    ") \
+       EM(rxrpc_conn_queue_challenge,          "GQ  chall   ") \
+       EM(rxrpc_conn_queue_retry_work,         "GQ  retry-wk") \
+       EM(rxrpc_conn_queue_rx_work,            "GQ  rx-work ") \
+       EM(rxrpc_conn_queue_timer,              "GQ  timer   ") \
+       EM(rxrpc_conn_see_new_service_conn,     "SEE new-svc ") \
+       EM(rxrpc_conn_see_reap_service,         "SEE reap-svc") \
+       E_(rxrpc_conn_see_work,                 "SEE work    ")
 
 #define rxrpc_client_traces \
        EM(rxrpc_client_activate_chans,         "Activa") \
@@ -430,30 +450,26 @@ TRACE_EVENT(rxrpc_peer,
            );
 
 TRACE_EVENT(rxrpc_conn,
-           TP_PROTO(unsigned int conn_debug_id, enum rxrpc_conn_trace op,
-                    int usage, const void *where),
+           TP_PROTO(unsigned int conn_debug_id, int ref, enum rxrpc_conn_trace why),
 
-           TP_ARGS(conn_debug_id, op, usage, where),
+           TP_ARGS(conn_debug_id, ref, why),
 
            TP_STRUCT__entry(
                    __field(unsigned int,       conn            )
-                   __field(int,                op              )
-                   __field(int,                usage           )
-                   __field(const void *,       where           )
+                   __field(int,                ref             )
+                   __field(int,                why             )
                             ),
 
            TP_fast_assign(
                    __entry->conn = conn_debug_id;
-                   __entry->op = op;
-                   __entry->usage = usage;
-                   __entry->where = where;
+                   __entry->ref = ref;
+                   __entry->why = why;
                           ),
 
-           TP_printk("C=%08x %s u=%d sp=%pSR",
+           TP_printk("C=%08x %s r=%d",
                      __entry->conn,
-                     __print_symbolic(__entry->op, rxrpc_conn_traces),
-                     __entry->usage,
-                     __entry->where)
+                     __print_symbolic(__entry->why, rxrpc_conn_traces),
+                     __entry->ref)
            );
 
 TRACE_EVENT(rxrpc_client,
index 6cb111e9761cd0ac091ca7189e6faeba2fa903bd..bc8281c410c587b8b2fa71d41bbfc4f80f35728e 100644 (file)
@@ -882,7 +882,7 @@ int rxrpc_connect_call(struct rxrpc_sock *, struct rxrpc_call *,
                       gfp_t);
 void rxrpc_expose_client_call(struct rxrpc_call *);
 void rxrpc_disconnect_client_call(struct rxrpc_bundle *, struct rxrpc_call *);
-void rxrpc_put_client_conn(struct rxrpc_connection *);
+void rxrpc_put_client_conn(struct rxrpc_connection *, enum rxrpc_conn_trace);
 void rxrpc_discard_expired_client_conns(struct work_struct *);
 void rxrpc_destroy_all_client_connections(struct rxrpc_net *);
 void rxrpc_clean_up_local_conns(struct rxrpc_local *);
@@ -906,11 +906,13 @@ struct rxrpc_connection *rxrpc_find_connection_rcu(struct rxrpc_local *,
 void __rxrpc_disconnect_call(struct rxrpc_connection *, struct rxrpc_call *);
 void rxrpc_disconnect_call(struct rxrpc_call *);
 void rxrpc_kill_connection(struct rxrpc_connection *);
-bool rxrpc_queue_conn(struct rxrpc_connection *);
-void rxrpc_see_connection(struct rxrpc_connection *);
-struct rxrpc_connection *rxrpc_get_connection(struct rxrpc_connection *);
-struct rxrpc_connection *rxrpc_get_connection_maybe(struct rxrpc_connection *);
-void rxrpc_put_service_conn(struct rxrpc_connection *);
+bool rxrpc_queue_conn(struct rxrpc_connection *, enum rxrpc_conn_trace);
+void rxrpc_see_connection(struct rxrpc_connection *, enum rxrpc_conn_trace);
+struct rxrpc_connection *rxrpc_get_connection(struct rxrpc_connection *,
+                                             enum rxrpc_conn_trace);
+struct rxrpc_connection *rxrpc_get_connection_maybe(struct rxrpc_connection *,
+                                                   enum rxrpc_conn_trace);
+void rxrpc_put_service_conn(struct rxrpc_connection *, enum rxrpc_conn_trace);
 void rxrpc_service_connection_reaper(struct work_struct *);
 void rxrpc_destroy_all_connections(struct rxrpc_net *);
 
@@ -924,15 +926,16 @@ static inline bool rxrpc_conn_is_service(const struct rxrpc_connection *conn)
        return !rxrpc_conn_is_client(conn);
 }
 
-static inline void rxrpc_put_connection(struct rxrpc_connection *conn)
+static inline void rxrpc_put_connection(struct rxrpc_connection *conn,
+                                       enum rxrpc_conn_trace why)
 {
        if (!conn)
                return;
 
        if (rxrpc_conn_is_client(conn))
-               rxrpc_put_client_conn(conn);
+               rxrpc_put_client_conn(conn, why);
        else
-               rxrpc_put_service_conn(conn);
+               rxrpc_put_service_conn(conn, why);
 }
 
 static inline void rxrpc_reduce_conn_timer(struct rxrpc_connection *conn,
index f6bc3b07c3e58c4870c9915bc0332c567a7fc231..04b52e28e0cc89a6b8d7934fd9d8f5173db6a8e9 100644 (file)
@@ -91,9 +91,6 @@ static int rxrpc_service_prealloc_one(struct rxrpc_sock *rx,
                b->conn_backlog[head] = conn;
                smp_store_release(&b->conn_backlog_head,
                                  (head + 1) & (size - 1));
-
-               trace_rxrpc_conn(conn->debug_id, rxrpc_conn_new_service,
-                                refcount_read(&conn->ref), here);
        }
 
        /* Now it gets complicated, because calls get registered with the
@@ -309,10 +306,10 @@ static struct rxrpc_call *rxrpc_alloc_incoming_call(struct rxrpc_sock *rx,
                                  (conn_tail + 1) & (RXRPC_BACKLOG_MAX - 1));
                conn->local = rxrpc_get_local(local, rxrpc_local_get_prealloc_conn);
                conn->peer = peer;
-               rxrpc_see_connection(conn);
+               rxrpc_see_connection(conn, rxrpc_conn_see_new_service_conn);
                rxrpc_new_incoming_connection(rx, conn, sec, skb);
        } else {
-               rxrpc_get_connection(conn);
+               rxrpc_get_connection(conn, rxrpc_conn_get_service_conn);
        }
 
        /* And now we can allocate and set up a new call */
@@ -402,7 +399,7 @@ struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *local,
        case RXRPC_CONN_SERVICE_UNSECURED:
                conn->state = RXRPC_CONN_SERVICE_CHALLENGING;
                set_bit(RXRPC_CONN_EV_CHALLENGE, &call->conn->events);
-               rxrpc_queue_conn(call->conn);
+               rxrpc_queue_conn(call->conn, rxrpc_conn_queue_challenge);
                break;
 
        case RXRPC_CONN_SERVICE:
index 1b725afd6e2cfc6efbffb6f69d382d941584e448..29ec4013aa0b4ab9fb80c51b8113e4882bf3696e 100644 (file)
@@ -635,7 +635,7 @@ static void rxrpc_destroy_call(struct work_struct *work)
 
        rxrpc_delete_call_timer(call);
 
-       rxrpc_put_connection(call->conn);
+       rxrpc_put_connection(call->conn, rxrpc_conn_put_call);
        rxrpc_put_peer(call->peer, rxrpc_peer_put_call);
        kmem_cache_free(rxrpc_call_jar, call);
        if (atomic_dec_and_test(&rxnet->nr_calls))
index 9444da235a4872161ddeb2f55d712078f794de27..dcfec6a45255e35c3f12a5bc1c71992ad3606207 100644 (file)
@@ -211,9 +211,8 @@ rxrpc_alloc_client_connection(struct rxrpc_bundle *bundle, gfp_t gfp)
        rxrpc_get_local(conn->local, rxrpc_local_get_client_conn);
        key_get(conn->key);
 
-       trace_rxrpc_conn(conn->debug_id, rxrpc_conn_new_client,
-                        refcount_read(&conn->ref),
-                        __builtin_return_address(0));
+       trace_rxrpc_conn(conn->debug_id, refcount_read(&conn->ref),
+                        rxrpc_conn_new_client);
 
        atomic_inc(&rxnet->nr_client_conns);
        trace_rxrpc_client(conn, -1, rxrpc_client_alloc);
@@ -467,10 +466,10 @@ static void rxrpc_add_conn_to_bundle(struct rxrpc_bundle *bundle, gfp_t gfp)
        if (candidate) {
                _debug("discard C=%x", candidate->debug_id);
                trace_rxrpc_client(candidate, -1, rxrpc_client_duplicate);
-               rxrpc_put_connection(candidate);
+               rxrpc_put_connection(candidate, rxrpc_conn_put_discard);
        }
 
-       rxrpc_put_connection(old);
+       rxrpc_put_connection(old, rxrpc_conn_put_noreuse);
        _leave("");
 }
 
@@ -544,7 +543,7 @@ static void rxrpc_activate_one_channel(struct rxrpc_connection *conn,
        rxrpc_see_call(call);
        list_del_init(&call->chan_wait_link);
        call->peer      = rxrpc_get_peer(conn->peer, rxrpc_peer_get_activate_call);
-       call->conn      = rxrpc_get_connection(conn);
+       call->conn      = rxrpc_get_connection(conn, rxrpc_conn_get_activate_call);
        call->cid       = conn->proto.cid | channel;
        call->call_id   = call_id;
        call->security  = conn->security;
@@ -592,7 +591,7 @@ static void rxrpc_unidle_conn(struct rxrpc_bundle *bundle, struct rxrpc_connecti
                }
                spin_unlock(&rxnet->client_conn_cache_lock);
                if (drop_ref)
-                       rxrpc_put_connection(conn);
+                       rxrpc_put_connection(conn, rxrpc_conn_put_unidle);
        }
 }
 
@@ -896,7 +895,7 @@ void rxrpc_disconnect_client_call(struct rxrpc_bundle *bundle, struct rxrpc_call
                trace_rxrpc_client(conn, channel, rxrpc_client_to_idle);
                conn->idle_timestamp = jiffies;
 
-               rxrpc_get_connection(conn);
+               rxrpc_get_connection(conn, rxrpc_conn_get_idle);
                spin_lock(&rxnet->client_conn_cache_lock);
                list_move_tail(&conn->cache_link, &rxnet->idle_client_conns);
                spin_unlock(&rxnet->client_conn_cache_lock);
@@ -938,7 +937,7 @@ static void rxrpc_unbundle_conn(struct rxrpc_connection *conn)
 
        if (need_drop) {
                rxrpc_deactivate_bundle(bundle);
-               rxrpc_put_connection(conn);
+               rxrpc_put_connection(conn, rxrpc_conn_put_unbundle);
        }
 }
 
@@ -983,15 +982,15 @@ static void rxrpc_kill_client_conn(struct rxrpc_connection *conn)
 /*
  * Clean up a dead client connections.
  */
-void rxrpc_put_client_conn(struct rxrpc_connection *conn)
+void rxrpc_put_client_conn(struct rxrpc_connection *conn,
+                          enum rxrpc_conn_trace why)
 {
-       const void *here = __builtin_return_address(0);
        unsigned int debug_id = conn->debug_id;
        bool dead;
        int r;
 
        dead = __refcount_dec_and_test(&conn->ref, &r);
-       trace_rxrpc_conn(debug_id, rxrpc_conn_put_client, r - 1, here);
+       trace_rxrpc_conn(debug_id, r - 1, why);
        if (dead)
                rxrpc_kill_client_conn(conn);
 }
@@ -1063,7 +1062,8 @@ next:
        spin_unlock(&rxnet->client_conn_cache_lock);
 
        rxrpc_unbundle_conn(conn);
-       rxrpc_put_connection(conn); /* Drop the ->cache_link ref */
+       /* Drop the ->cache_link ref */
+       rxrpc_put_connection(conn, rxrpc_conn_put_discard_idle);
 
        nr_conns--;
        goto next;
@@ -1134,7 +1134,7 @@ void rxrpc_clean_up_local_conns(struct rxrpc_local *local)
                                  struct rxrpc_connection, cache_link);
                list_del_init(&conn->cache_link);
                rxrpc_unbundle_conn(conn);
-               rxrpc_put_connection(conn);
+               rxrpc_put_connection(conn, rxrpc_conn_put_local_dead);
        }
 
        _leave(" [culled]");
index 225edaf019f1473de81370f3002194120725875f..817f895c77ca25ac4e6ad1fd0858f89a838ff365 100644 (file)
@@ -472,14 +472,14 @@ void rxrpc_process_connection(struct work_struct *work)
        struct rxrpc_connection *conn =
                container_of(work, struct rxrpc_connection, processor);
 
-       rxrpc_see_connection(conn);
+       rxrpc_see_connection(conn, rxrpc_conn_see_work);
 
        if (__rxrpc_use_local(conn->local, rxrpc_local_use_conn_work)) {
                rxrpc_do_process_connection(conn);
                rxrpc_unuse_local(conn->local, rxrpc_local_unuse_conn_work);
        }
 
-       rxrpc_put_connection(conn);
+       rxrpc_put_connection(conn, rxrpc_conn_put_work);
        _leave("");
        return;
 }
index 554ee5dd3325e31b151da588a8bf7c6baec109bb..bbace8d9953dc68cbc9c56a719979da63669ff0b 100644 (file)
@@ -26,7 +26,7 @@ static void rxrpc_connection_timer(struct timer_list *timer)
        struct rxrpc_connection *conn =
                container_of(timer, struct rxrpc_connection, timer);
 
-       rxrpc_queue_conn(conn);
+       rxrpc_queue_conn(conn, rxrpc_conn_queue_timer);
 }
 
 /*
@@ -260,43 +260,42 @@ void rxrpc_kill_connection(struct rxrpc_connection *conn)
  * Queue a connection's work processor, getting a ref to pass to the work
  * queue.
  */
-bool rxrpc_queue_conn(struct rxrpc_connection *conn)
+bool rxrpc_queue_conn(struct rxrpc_connection *conn, enum rxrpc_conn_trace why)
 {
-       const void *here = __builtin_return_address(0);
        int r;
 
        if (!__refcount_inc_not_zero(&conn->ref, &r))
                return false;
        if (rxrpc_queue_work(&conn->processor))
-               trace_rxrpc_conn(conn->debug_id, rxrpc_conn_queued, r + 1, here);
+               trace_rxrpc_conn(conn->debug_id, why, r + 1);
        else
-               rxrpc_put_connection(conn);
+               rxrpc_put_connection(conn, rxrpc_conn_put_already_queued);
        return true;
 }
 
 /*
  * Note the re-emergence of a connection.
  */
-void rxrpc_see_connection(struct rxrpc_connection *conn)
+void rxrpc_see_connection(struct rxrpc_connection *conn,
+                         enum rxrpc_conn_trace why)
 {
-       const void *here = __builtin_return_address(0);
        if (conn) {
-               int n = refcount_read(&conn->ref);
+               int r = refcount_read(&conn->ref);
 
-               trace_rxrpc_conn(conn->debug_id, rxrpc_conn_seen, n, here);
+               trace_rxrpc_conn(conn->debug_id, r, why);
        }
 }
 
 /*
  * Get a ref on a connection.
  */
-struct rxrpc_connection *rxrpc_get_connection(struct rxrpc_connection *conn)
+struct rxrpc_connection *rxrpc_get_connection(struct rxrpc_connection *conn,
+                                             enum rxrpc_conn_trace why)
 {
-       const void *here = __builtin_return_address(0);
        int r;
 
        __refcount_inc(&conn->ref, &r);
-       trace_rxrpc_conn(conn->debug_id, rxrpc_conn_got, r, here);
+       trace_rxrpc_conn(conn->debug_id, r + 1, why);
        return conn;
 }
 
@@ -304,14 +303,14 @@ struct rxrpc_connection *rxrpc_get_connection(struct rxrpc_connection *conn)
  * Try to get a ref on a connection.
  */
 struct rxrpc_connection *
-rxrpc_get_connection_maybe(struct rxrpc_connection *conn)
+rxrpc_get_connection_maybe(struct rxrpc_connection *conn,
+                          enum rxrpc_conn_trace why)
 {
-       const void *here = __builtin_return_address(0);
        int r;
 
        if (conn) {
                if (__refcount_inc_not_zero(&conn->ref, &r))
-                       trace_rxrpc_conn(conn->debug_id, rxrpc_conn_got, r + 1, here);
+                       trace_rxrpc_conn(conn->debug_id, r + 1, why);
                else
                        conn = NULL;
        }
@@ -331,14 +330,14 @@ static void rxrpc_set_service_reap_timer(struct rxrpc_net *rxnet,
 /*
  * Release a service connection
  */
-void rxrpc_put_service_conn(struct rxrpc_connection *conn)
+void rxrpc_put_service_conn(struct rxrpc_connection *conn,
+                           enum rxrpc_conn_trace why)
 {
-       const void *here = __builtin_return_address(0);
        unsigned int debug_id = conn->debug_id;
        int r;
 
        __refcount_dec(&conn->ref, &r);
-       trace_rxrpc_conn(debug_id, rxrpc_conn_put_service, r - 1, here);
+       trace_rxrpc_conn(debug_id, r - 1, why);
        if (r - 1 == 1)
                rxrpc_set_service_reap_timer(conn->local->rxnet,
                                             jiffies + rxrpc_connection_expiry);
@@ -354,6 +353,9 @@ static void rxrpc_destroy_connection(struct rcu_head *rcu)
 
        _enter("{%d,u=%d}", conn->debug_id, refcount_read(&conn->ref));
 
+       trace_rxrpc_conn(conn->debug_id, refcount_read(&conn->ref),
+                        rxrpc_conn_free);
+
        ASSERTCMP(refcount_read(&conn->ref), ==, 0);
 
        del_timer_sync(&conn->timer);
@@ -419,7 +421,7 @@ void rxrpc_service_connection_reaper(struct work_struct *work)
                 */
                if (!refcount_dec_if_one(&conn->ref))
                        continue;
-               trace_rxrpc_conn(conn->debug_id, rxrpc_conn_reap_service, 0, NULL);
+               rxrpc_see_connection(conn, rxrpc_conn_see_reap_service);
 
                if (rxrpc_conn_is_client(conn))
                        BUG();
index a3b91864ef21b9ae91d06ab4174939e6baeac4fc..bf087213bd4d25964e68606b95732b4f2cbcbd0a 100644 (file)
@@ -141,9 +141,7 @@ struct rxrpc_connection *rxrpc_prealloc_service_connection(struct rxrpc_net *rxn
                list_add_tail(&conn->proc_link, &rxnet->conn_proc_list);
                write_unlock(&rxnet->conn_lock);
 
-               trace_rxrpc_conn(conn->debug_id, rxrpc_conn_new_service,
-                                refcount_read(&conn->ref),
-                                __builtin_return_address(0));
+               rxrpc_see_connection(conn, rxrpc_conn_new_service);
        }
 
        return conn;
index cecfd201d832002e9db9922335d829c43b519adc..c8ff7489b4128c6139f9c17fd4f2e33bbadc2ec0 100644 (file)
@@ -1121,7 +1121,7 @@ static void rxrpc_post_packet_to_conn(struct rxrpc_connection *conn,
        _enter("%p,%p", conn, skb);
 
        skb_queue_tail(&conn->rx_queue, skb);
-       rxrpc_queue_conn(conn);
+       rxrpc_queue_conn(conn, rxrpc_conn_queue_rx_work);
 }
 
 /*