mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
tc-policy: Monitor TXQ usage with bpftrace script
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This commit is contained in:
@@ -54,3 +54,21 @@ You can now use it in all perf tools, such as:
|
|||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Afterwards run =perf script= and see results.
|
Afterwards run =perf script= and see results.
|
||||||
|
|
||||||
|
** bpftrace
|
||||||
|
|
||||||
|
It is also possible to monitor TXQ usage via a =bpftrace= script.
|
||||||
|
* see [[file:monitor_txq_usage.bt]].
|
||||||
|
|
||||||
|
The main part of the script is:
|
||||||
|
#+begin_src sh
|
||||||
|
tracepoint:net:net_dev_start_xmit {
|
||||||
|
$qm = args->queue_mapping;
|
||||||
|
$dev = str(args->name, 15);
|
||||||
|
|
||||||
|
@stat_txq_usage[$dev] = lhist($qm, 0,32,1);
|
||||||
|
}
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
Or as oneliner:
|
||||||
|
* =bpftrace -e 't:net:net_dev_start_xmit {@txq[str(args->name, 15)]=lhist(args->queue_mapping, 0,32,1)}'=
|
||||||
|
|||||||
26
tc-policy/monitor_txq_usage.bt
Executable file
26
tc-policy/monitor_txq_usage.bt
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/bpftrace
|
||||||
|
|
||||||
|
//BEGIN {
|
||||||
|
// printf("Monitor TXQ usage\n");
|
||||||
|
// printf(" - Remember: BPF set queue_mapping is one-less here (zero-indexed)\n");
|
||||||
|
//}
|
||||||
|
|
||||||
|
tracepoint:net:net_dev_start_xmit {
|
||||||
|
$qm = args->queue_mapping;
|
||||||
|
$dev = str(args->name, 15);
|
||||||
|
|
||||||
|
@stat_txq_usage[$dev] = lhist($qm, 0,32,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Periodically print stats */
|
||||||
|
interval:s:3
|
||||||
|
{
|
||||||
|
printf("\nPeriodic show stats - time: ");
|
||||||
|
time();
|
||||||
|
print(@stat_txq_usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Default bpftrace will print all remaining maps at END */
|
||||||
|
//END {
|
||||||
|
// printf("END stats:\n");
|
||||||
|
//}
|
||||||
Reference in New Issue
Block a user