Commit b065e1ea authored by Joanne Hugé's avatar Joanne Hugé

Add option to trace until threshold is met in client

parent 0594ac5c
......@@ -45,6 +45,10 @@ typedef struct thread_param {
int affinity_cpu;
uint64_t start_ts;
int enable_etf_tracing;
int enable_threshold_tracing;
int threshold;
} thread_param_t;
typedef struct main_param {
......@@ -104,6 +108,7 @@ static void help(char *argv[]) {
" -t Enable TX timestamps\n"
" -v Verbose\n"
" -T Enable tracing until deadline is missed\n"
" -S Enable tracing until threshold is reached\n"
"\n",
argv[0]);
}
......@@ -184,6 +189,17 @@ static void *packet_sending_thread(void *p) {
egress_stats.avg_interval =
(egress_stats.avg_interval * nb_cycles + interval_us) /
(nb_cycles + 1);
if (thread_params.enable_threshold_tracing) {
int jitter = (egress_stats.max_interval - egress_stats.min_interval);
if ( jitter > thread_params.threshold) {
tracemark("Threshold reached\n");
tracing(0);
printf("Threshold reached: %dus\n", jitter);
printf("Exiting packet-exchange...\n", jitter);
exit(EXIT_SUCCESS);
}
}
}
previous = current;
......@@ -216,6 +232,8 @@ int main(int argc, char *argv[]) {
thread_params.send_tx_delay = 0;
thread_params.affinity_cpu = -1;
thread_params.start_ts = 0;
thread_params.enable_etf_tracing = 0;
thread_params.enable_threshold_tracing = 0;
main_params.refresh_rate = 50000;
main_params.verbose = 0;
main_params.enable_tracing = 0;
......@@ -247,7 +265,7 @@ int main(int argc, char *argv[]) {
}
if (main_params.enable_tracing) {
// Enable ftrace
// Open tracing file descriptors
open_fds();
}
......@@ -256,7 +274,7 @@ int main(int argc, char *argv[]) {
// Initialize the UDP packet sending socket
init_udp_send(&egress_params, &egress_stats, enable_histograms,
main_params.enable_tracing, kernel_latency_hist);
thread_params.enable_etf_tracing, kernel_latency_hist);
// Initialize the UDP packet receiving socket if RTT is measured
if (tsn_task == RTT_TASK)
......@@ -415,7 +433,7 @@ static void sighand(int sig_num) {
*/
static void process_options(int argc, char *argv[]) {
for (;;) {
int c = getopt(argc, argv, "a:bc:d:e:ghi:l:p:q:r:s:tvT");
int c = getopt(argc, argv, "a:bc:d:e:ghi:l:p:q:r:s:tvTS:");
if (c == -1) break;
......@@ -473,6 +491,12 @@ static void process_options(int argc, char *argv[]) {
break;
case 'T':
main_params.enable_tracing = 1;
thread_params.enable_etf_tracing = 1;
break;
case 'S':
main_params.enable_tracing = 1;
thread_params.enable_threshold_tracing = 1;
thread_params.threshold = atoi(optarg);
break;
}
}
......
......@@ -30,7 +30,8 @@ Usage: $0 [-h] QDISC_OPT [CLIENT_OPTS] BOARD_HOSTNAME
TRACE_OPTS: -T [-P TRACER -E EVENTS -B SIZE]
Options to trace with trace-cmd until ETF deadline is missed
(see trace-cmd man page and ftrace documentation)
-T Enable tracing
-T Enable ETF tracing
-S THRESHOLD Enable threshold tracing
-P TRACER Which trace to use when tracing: function, function_graph, wakeup etc...
Default: function
-E EVENTS Specify which events to trace (e.g: "-E "-e net -e irq")
......@@ -56,7 +57,7 @@ etf_offset=500
tracecmd_events="-e irq -e sched -e net_dev_start_xmit -e net_dev_xmit -e net_dev_xmit_timeout"
tracecmd_opts=""
while getopts "a:bc:d:e:o:ghi:pqs:tB:E:I:HP:T" opt; do
while getopts "a:bc:d:e:o:ghi:pqs:tB:E:I:HP:TS:" opt; do
case "${opt}" in
a )
cpu=${OPTARG}
......@@ -123,6 +124,10 @@ while getopts "a:bc:d:e:o:ghi:pqs:tB:E:I:HP:T" opt; do
use_tracer=1
client_options+=" -T"
;;
S )
use_tracer=1
client_options+=" -S ${OPTARG}"
;;
* )
usage
;;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment