Skip to content

Commit 71d1479

Browse files
committed
tc-policy: Add more advanced bpftrace script
Digging into the return value of netdev_pick_tx(). Want to be able to debug the case where a socket selects another queue_id. Signed-off-by: Jesper Dangaard Brouer <[email protected]>
1 parent ba2c114 commit 71d1479

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tc-policy/adv_monitor_txq_usage.bt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/bpftrace
2+
3+
//BEGIN {
4+
// printf("Monitor TXQ usage\n");
5+
// printf(" - Remember: BPF set queue_mapping is one-less here (zero-indexed)\n");
6+
//}
7+
8+
tracepoint:net:net_dev_start_xmit {
9+
$qm = args->queue_mapping;
10+
$dev = str(args->name, 16);
11+
12+
@stat_txq_usage[$dev] = lhist($qm, 0,32,1);
13+
}
14+
15+
/*
16+
* More precisely we actually want to see what netdev_pick_tx() is
17+
* selecting, as sockets can possibly return another queue_id.
18+
*/
19+
20+
kprobe:netdev_pick_tx {
21+
$dev = ((struct net_device *)arg0)->name;
22+
@record[cpu] = $dev;
23+
}
24+
25+
kretprobe:netdev_pick_tx {
26+
$dev = @record[cpu];
27+
@netdev_pick_tx[$dev] = lhist(retval, 0,32,1);
28+
}
29+
30+
/* Periodically print stats */
31+
interval:s:3
32+
{
33+
printf("\nPeriodic show stats - time: ");
34+
time();
35+
print(@stat_txq_usage);
36+
print(@netdev_pick_tx);
37+
}
38+
39+
/* Default bpftrace will print all remaining maps at END */
40+
//END {
41+
// printf("END stats:\n");
42+
//}

0 commit comments

Comments
 (0)