Skip to content

Commit

Permalink
rxrpc: Use the tx-phase skb flag to simplify tracing
Browse files Browse the repository at this point in the history
Use the previously-added transmit-phase skbuff private flag to simplify the
socket buffer tracing a bit.  Which phase the skbuff comes from can now be
divined from the skb rather than having to be guessed from the call state.

We can also reduce the number of rxrpc_skb_trace values by eliminating the
difference between Tx and Rx in the symbols.

Signed-off-by: David Howells <[email protected]>
  • Loading branch information
dhowells committed Aug 27, 2019
1 parent b311e68 commit 987db9f
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 76 deletions.
51 changes: 22 additions & 29 deletions include/trace/events/rxrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,15 @@
#define __RXRPC_DECLARE_TRACE_ENUMS_ONCE_ONLY

enum rxrpc_skb_trace {
rxrpc_skb_rx_cleaned,
rxrpc_skb_rx_freed,
rxrpc_skb_rx_got,
rxrpc_skb_rx_lost,
rxrpc_skb_rx_purged,
rxrpc_skb_rx_received,
rxrpc_skb_rx_rotated,
rxrpc_skb_rx_seen,
rxrpc_skb_tx_cleaned,
rxrpc_skb_tx_freed,
rxrpc_skb_tx_got,
rxrpc_skb_tx_new,
rxrpc_skb_tx_rotated,
rxrpc_skb_tx_seen,
rxrpc_skb_cleaned,
rxrpc_skb_freed,
rxrpc_skb_got,
rxrpc_skb_lost,
rxrpc_skb_new,
rxrpc_skb_purged,
rxrpc_skb_received,
rxrpc_skb_rotated,
rxrpc_skb_seen,
};

enum rxrpc_local_trace {
Expand Down Expand Up @@ -228,20 +223,15 @@ enum rxrpc_tx_point {
* Declare tracing information enums and their string mappings for display.
*/
#define rxrpc_skb_traces \
EM(rxrpc_skb_rx_cleaned, "Rx CLN") \
EM(rxrpc_skb_rx_freed, "Rx FRE") \
EM(rxrpc_skb_rx_got, "Rx GOT") \
EM(rxrpc_skb_rx_lost, "Rx *L*") \
EM(rxrpc_skb_rx_purged, "Rx PUR") \
EM(rxrpc_skb_rx_received, "Rx RCV") \
EM(rxrpc_skb_rx_rotated, "Rx ROT") \
EM(rxrpc_skb_rx_seen, "Rx SEE") \
EM(rxrpc_skb_tx_cleaned, "Tx CLN") \
EM(rxrpc_skb_tx_freed, "Tx FRE") \
EM(rxrpc_skb_tx_got, "Tx GOT") \
EM(rxrpc_skb_tx_new, "Tx NEW") \
EM(rxrpc_skb_tx_rotated, "Tx ROT") \
E_(rxrpc_skb_tx_seen, "Tx SEE")
EM(rxrpc_skb_cleaned, "CLN") \
EM(rxrpc_skb_freed, "FRE") \
EM(rxrpc_skb_got, "GOT") \
EM(rxrpc_skb_lost, "*L*") \
EM(rxrpc_skb_new, "NEW") \
EM(rxrpc_skb_purged, "PUR") \
EM(rxrpc_skb_received, "RCV") \
EM(rxrpc_skb_rotated, "ROT") \
E_(rxrpc_skb_seen, "SEE")

#define rxrpc_local_traces \
EM(rxrpc_local_got, "GOT") \
Expand Down Expand Up @@ -650,21 +640,24 @@ TRACE_EVENT(rxrpc_skb,
TP_STRUCT__entry(
__field(struct sk_buff *, skb )
__field(enum rxrpc_skb_trace, op )
__field(u8, flags )
__field(int, usage )
__field(int, mod_count )
__field(const void *, where )
),

TP_fast_assign(
__entry->skb = skb;
__entry->flags = rxrpc_skb(skb)->rx_flags;
__entry->op = op;
__entry->usage = usage;
__entry->mod_count = mod_count;
__entry->where = where;
),

TP_printk("s=%p %s u=%d m=%d p=%pSR",
TP_printk("s=%p %cx %s u=%d m=%d p=%pSR",
__entry->skb,
__entry->flags & RXRPC_SKB_TX_BUFFER ? 'T' : 'R',
__print_symbolic(__entry->op, rxrpc_skb_traces),
__entry->usage,
__entry->mod_count,
Expand Down
1 change: 1 addition & 0 deletions net/rxrpc/ar-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ struct rxrpc_host_header {
* - max 48 bytes (struct sk_buff::cb)
*/
struct rxrpc_skb_priv {
atomic_t nr_ring_pins; /* Number of rxtx ring pins */
u8 nr_subpackets; /* Number of subpackets */
u8 rx_flags; /* Received packet flags */
#define RXRPC_SKB_INCL_LAST 0x01 /* - Includes last packet */
Expand Down
8 changes: 4 additions & 4 deletions net/rxrpc/call_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call, unsigned long now_j)
continue;

skb = call->rxtx_buffer[ix];
rxrpc_see_skb(skb, rxrpc_skb_tx_seen);
rxrpc_see_skb(skb, rxrpc_skb_seen);

if (anno_type == RXRPC_TX_ANNO_UNACK) {
if (ktime_after(skb->tstamp, max_age)) {
Expand Down Expand Up @@ -255,18 +255,18 @@ static void rxrpc_resend(struct rxrpc_call *call, unsigned long now_j)
continue;

skb = call->rxtx_buffer[ix];
rxrpc_get_skb(skb, rxrpc_skb_tx_got);
rxrpc_get_skb(skb, rxrpc_skb_got);
spin_unlock_bh(&call->lock);

if (rxrpc_send_data_packet(call, skb, true) < 0) {
rxrpc_free_skb(skb, rxrpc_skb_tx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
return;
}

if (rxrpc_is_client_call(call))
rxrpc_expose_client_call(call);

rxrpc_free_skb(skb, rxrpc_skb_tx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
spin_lock_bh(&call->lock);

/* We need to clear the retransmit state, but there are two
Expand Down
6 changes: 2 additions & 4 deletions net/rxrpc/call_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,7 @@ static void rxrpc_cleanup_ring(struct rxrpc_call *call)
int i;

for (i = 0; i < RXRPC_RXTX_BUFF_SIZE; i++) {
rxrpc_free_skb(call->rxtx_buffer[i],
(call->tx_phase ? rxrpc_skb_tx_cleaned :
rxrpc_skb_rx_cleaned));
rxrpc_free_skb(call->rxtx_buffer[i], rxrpc_skb_cleaned);
call->rxtx_buffer[i] = NULL;
}
}
Expand Down Expand Up @@ -587,7 +585,7 @@ void rxrpc_cleanup_call(struct rxrpc_call *call)
ASSERTCMP(call->conn, ==, NULL);

rxrpc_cleanup_ring(call);
rxrpc_free_skb(call->tx_pending, rxrpc_skb_tx_cleaned);
rxrpc_free_skb(call->tx_pending, rxrpc_skb_cleaned);

call_rcu(&call->rcu, rxrpc_rcu_destroy_call);
}
Expand Down
6 changes: 3 additions & 3 deletions net/rxrpc/conn_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ void rxrpc_process_connection(struct work_struct *work)
/* go through the conn-level event packets, releasing the ref on this
* connection that each one has when we've finished with it */
while ((skb = skb_dequeue(&conn->rx_queue))) {
rxrpc_see_skb(skb, rxrpc_skb_rx_seen);
rxrpc_see_skb(skb, rxrpc_skb_seen);
ret = rxrpc_process_event(conn, skb, &abort_code);
switch (ret) {
case -EPROTO:
Expand All @@ -484,7 +484,7 @@ void rxrpc_process_connection(struct work_struct *work)
goto requeue_and_leave;
case -ECONNABORTED:
default:
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
break;
}
}
Expand All @@ -501,6 +501,6 @@ void rxrpc_process_connection(struct work_struct *work)
protocol_error:
if (rxrpc_abort_connection(conn, ret, abort_code) < 0)
goto requeue_and_leave;
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
goto out;
}
22 changes: 11 additions & 11 deletions net/rxrpc/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static bool rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
ix = call->tx_hard_ack & RXRPC_RXTX_BUFF_MASK;
skb = call->rxtx_buffer[ix];
annotation = call->rxtx_annotations[ix];
rxrpc_see_skb(skb, rxrpc_skb_tx_rotated);
rxrpc_see_skb(skb, rxrpc_skb_rotated);
call->rxtx_buffer[ix] = NULL;
call->rxtx_annotations[ix] = 0;
skb->next = list;
Expand All @@ -258,7 +258,7 @@ static bool rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,
skb = list;
list = skb->next;
skb_mark_not_on_list(skb);
rxrpc_free_skb(skb, rxrpc_skb_tx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
}

return rot_last;
Expand Down Expand Up @@ -443,7 +443,7 @@ static void rxrpc_input_data(struct rxrpc_call *call, struct sk_buff *skb)

state = READ_ONCE(call->state);
if (state >= RXRPC_CALL_COMPLETE) {
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
return;
}

Expand Down Expand Up @@ -559,7 +559,7 @@ static void rxrpc_input_data(struct rxrpc_call *call, struct sk_buff *skb)
* and also rxrpc_fill_out_ack().
*/
if (!terminal)
rxrpc_get_skb(skb, rxrpc_skb_rx_got);
rxrpc_get_skb(skb, rxrpc_skb_got);
call->rxtx_annotations[ix] = annotation;
smp_wmb();
call->rxtx_buffer[ix] = skb;
Expand Down Expand Up @@ -620,7 +620,7 @@ static void rxrpc_input_data(struct rxrpc_call *call, struct sk_buff *skb)

unlock:
spin_unlock(&call->input_lock);
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
_leave(" [queued]");
}

Expand Down Expand Up @@ -1056,7 +1056,7 @@ static void rxrpc_input_call_packet(struct rxrpc_call *call,
break;
}

rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
no_free:
_leave("");
}
Expand Down Expand Up @@ -1119,7 +1119,7 @@ static void rxrpc_post_packet_to_local(struct rxrpc_local *local,
skb_queue_tail(&local->event_queue, skb);
rxrpc_queue_local(local);
} else {
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
}
}

Expand All @@ -1134,7 +1134,7 @@ static void rxrpc_reject_packet(struct rxrpc_local *local, struct sk_buff *skb)
skb_queue_tail(&local->reject_queue, skb);
rxrpc_queue_local(local);
} else {
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
}
}

Expand Down Expand Up @@ -1198,7 +1198,7 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
if (skb->tstamp == 0)
skb->tstamp = ktime_get_real();

rxrpc_new_skb(skb, rxrpc_skb_rx_received);
rxrpc_new_skb(skb, rxrpc_skb_received);

skb_pull(skb, sizeof(struct udphdr));

Expand All @@ -1215,7 +1215,7 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
static int lose;
if ((lose++ & 7) == 7) {
trace_rxrpc_rx_lose(sp);
rxrpc_free_skb(skb, rxrpc_skb_rx_lost);
rxrpc_free_skb(skb, rxrpc_skb_lost);
return 0;
}
}
Expand Down Expand Up @@ -1389,7 +1389,7 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
goto out;

discard:
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
out:
trace_rxrpc_rx_done(0, 0);
return 0;
Expand Down
4 changes: 2 additions & 2 deletions net/rxrpc/local_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void rxrpc_process_local_events(struct rxrpc_local *local)
if (skb) {
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);

rxrpc_see_skb(skb, rxrpc_skb_rx_seen);
rxrpc_see_skb(skb, rxrpc_skb_seen);
_debug("{%d},{%u}", local->debug_id, sp->hdr.type);

switch (sp->hdr.type) {
Expand All @@ -108,7 +108,7 @@ void rxrpc_process_local_events(struct rxrpc_local *local)
break;
}

rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
}

_leave("");
Expand Down
6 changes: 3 additions & 3 deletions net/rxrpc/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void rxrpc_reject_packets(struct rxrpc_local *local)
memset(&whdr, 0, sizeof(whdr));

while ((skb = skb_dequeue(&local->reject_queue))) {
rxrpc_see_skb(skb, rxrpc_skb_rx_seen);
rxrpc_see_skb(skb, rxrpc_skb_seen);
sp = rxrpc_skb(skb);

switch (skb->mark) {
Expand All @@ -581,7 +581,7 @@ void rxrpc_reject_packets(struct rxrpc_local *local)
ioc = 2;
break;
default:
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
continue;
}

Expand All @@ -606,7 +606,7 @@ void rxrpc_reject_packets(struct rxrpc_local *local)
rxrpc_tx_point_reject);
}

rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
}

_leave("");
Expand Down
10 changes: 5 additions & 5 deletions net/rxrpc/peer_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ void rxrpc_error_report(struct sock *sk)
_leave("UDP socket errqueue empty");
return;
}
rxrpc_new_skb(skb, rxrpc_skb_rx_received);
rxrpc_new_skb(skb, rxrpc_skb_received);
serr = SKB_EXT_ERR(skb);
if (!skb->len && serr->ee.ee_origin == SO_EE_ORIGIN_TIMESTAMPING) {
_leave("UDP empty message");
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
return;
}

Expand All @@ -177,7 +177,7 @@ void rxrpc_error_report(struct sock *sk)
peer = NULL;
if (!peer) {
rcu_read_unlock();
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
_leave(" [no peer]");
return;
}
Expand All @@ -189,15 +189,15 @@ void rxrpc_error_report(struct sock *sk)
serr->ee.ee_code == ICMP_FRAG_NEEDED)) {
rxrpc_adjust_mtu(peer, serr);
rcu_read_unlock();
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
rxrpc_put_peer(peer);
_leave(" [MTU update]");
return;
}

rxrpc_store_error(peer, serr);
rcu_read_unlock();
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);
rxrpc_put_peer(peer);

_leave("");
Expand Down
6 changes: 3 additions & 3 deletions net/rxrpc/recvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ static void rxrpc_rotate_rx_window(struct rxrpc_call *call)
hard_ack++;
ix = hard_ack & RXRPC_RXTX_BUFF_MASK;
skb = call->rxtx_buffer[ix];
rxrpc_see_skb(skb, rxrpc_skb_rx_rotated);
rxrpc_see_skb(skb, rxrpc_skb_rotated);
sp = rxrpc_skb(skb);

subpacket = call->rxtx_annotations[ix] & RXRPC_RX_ANNO_SUBPACKET;
Expand All @@ -205,7 +205,7 @@ static void rxrpc_rotate_rx_window(struct rxrpc_call *call)
/* Barrier against rxrpc_input_data(). */
smp_store_release(&call->rx_hard_ack, hard_ack);

rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
rxrpc_free_skb(skb, rxrpc_skb_freed);

trace_rxrpc_receive(call, rxrpc_receive_rotate, serial, hard_ack);
if (last) {
Expand Down Expand Up @@ -340,7 +340,7 @@ static int rxrpc_recvmsg_data(struct socket *sock, struct rxrpc_call *call,
break;
}
smp_rmb();
rxrpc_see_skb(skb, rxrpc_skb_rx_seen);
rxrpc_see_skb(skb, rxrpc_skb_seen);
sp = rxrpc_skb(skb);

if (!(flags & MSG_PEEK)) {
Expand Down
Loading

0 comments on commit 987db9f

Please sign in to comment.