Commit 9ef4fea2 authored by Joanne Hugé's avatar Joanne Hugé

Add histogram for diff ts measures

parent 2ba307c4
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#define MAX_KERNEL_LATENCY 1000 #define MAX_KERNEL_LATENCY 1000
#define MAX_RTT 1000 #define MAX_RTT 1000
#define MAX_JITTER 1000 #define MAX_JITTER 1000
#define MAX_DIFF_TS 1000
#define MAX_BUFFER_SIZE 1024 #define MAX_BUFFER_SIZE 1024
......
...@@ -65,6 +65,7 @@ static void sighand(int sig_num); ...@@ -65,6 +65,7 @@ static void sighand(int sig_num);
static uint64_t kernel_latency_hist[MAX_KERNEL_LATENCY]; static uint64_t kernel_latency_hist[MAX_KERNEL_LATENCY];
static uint64_t jitter_hist[MAX_JITTER]; static uint64_t jitter_hist[MAX_JITTER];
static uint64_t diff_ts_hist[MAX_DIFF_TS];
static main_param_t main_params; static main_param_t main_params;
static thread_param_t thread_params; static thread_param_t thread_params;
static ingress_param_t ingress_params; static ingress_param_t ingress_params;
...@@ -84,6 +85,7 @@ static pthread_cond_t emit_signal_ts_received; ...@@ -84,6 +85,7 @@ static pthread_cond_t emit_signal_ts_received;
static int64_t min_diff_ts = INT_MAX; static int64_t min_diff_ts = INT_MAX;
static int64_t max_diff_ts = 0; static int64_t max_diff_ts = 0;
static int64_t avg_diff_ts = 0; static int64_t avg_diff_ts = 0;
static uint64_t high_diff_ts = 0;
static char ts_tracemark_buf[64]; static char ts_tracemark_buf[64];
...@@ -264,6 +266,14 @@ static void *tsn_thread(void *p) { ...@@ -264,6 +266,14 @@ static void *tsn_thread(void *p) {
max_diff_ts = _max_(diff_us, max_diff_ts); max_diff_ts = _max_(diff_us, max_diff_ts);
avg_diff_ts = (avg_diff_ts * ingress_stats.packets_received + diff_us) / (ingress_stats.packets_received + 1); avg_diff_ts = (avg_diff_ts * ingress_stats.packets_received + diff_us) / (ingress_stats.packets_received + 1);
// Histogram
if (enable_histograms) {
if (diff_us > ((int)MAX_DIFF_TS) || diff_us < 0)
high_diff_ts++;
else
diff_ts_hist[diff_us]++;
}
// If the latency hits the tracing threshold, stop tracing // If the latency hits the tracing threshold, stop tracing
if (main_params.enable_tracing && if (main_params.enable_tracing &&
(max_diff_ts > ((int64_t)thread_params.latency_threshold))) { (max_diff_ts > ((int64_t)thread_params.latency_threshold))) {
...@@ -400,6 +410,7 @@ int main(int argc, char *argv[]) { ...@@ -400,6 +410,7 @@ int main(int argc, char *argv[]) {
if (enable_histograms) { if (enable_histograms) {
memset(kernel_latency_hist, 0, sizeof(kernel_latency_hist)); memset(kernel_latency_hist, 0, sizeof(kernel_latency_hist));
memset(jitter_hist, 0, sizeof(jitter_hist)); memset(jitter_hist, 0, sizeof(jitter_hist));
memset(diff_ts_hist, 0, sizeof(diff_ts_hist));
} }
// Enable ftrace // Enable ftrace
...@@ -481,35 +492,51 @@ static void print_histograms() { ...@@ -481,35 +492,51 @@ static void print_histograms() {
duration_hour = duration / NSEC_PER_SEC / 3600; duration_hour = duration / NSEC_PER_SEC / 3600;
duration_minutes = duration / NSEC_PER_SEC / 60 - duration_hour * 60; duration_minutes = duration / NSEC_PER_SEC / 60 - duration_hour * 60;
max_jitter = histogram_max(jitter_hist, MAX_JITTER - 1); if (thread_params.enable_diff_ts) {
min_jitter = histogram_min(jitter_hist, MAX_JITTER - 1); printf("# RX latency histogram\n");
if (enable_timestamps) { max_latency = histogram_max(diff_ts_hist, MAX_DIFF_TS - 1);
max_latency = histogram_max(kernel_latency_hist, MAX_KERNEL_LATENCY - 1);
printf("# Packet RX timestamps histogram\n");
for (int j = 0; j < max_latency; j++) for (int j = 0; j < max_latency; j++)
printf(" %06d %015" PRIi64 "\n", j, kernel_latency_hist[j]); printf(" %06d %015" PRIi64 "\n", j, diff_ts_hist[j]);
printf( printf(
"# Duration: %dh%d\n" "# Duration: %dh%d\n"
"# Lost packets: %" PRIu64 "\n", "# Lost packets: %" PRIu64 "\n",
duration_hour, duration_minutes, ingress_stats.high_jitter); duration_hour, duration_minutes, high_diff_ts);
} }
else {
printf("# Packet jitter histogram\n"); max_jitter = histogram_max(jitter_hist, MAX_JITTER - 1);
min_jitter = histogram_min(jitter_hist, MAX_JITTER - 1);
for (int j = min_jitter; j < max_jitter; j++) if (enable_timestamps) {
printf(" %06d %015" PRIi64 "\n", j, jitter_hist[j]); max_latency = histogram_max(kernel_latency_hist, MAX_KERNEL_LATENCY - 1);
printf( printf("# Packet RX timestamps histogram\n");
"# Middle: %d\n"
"# Duration: %dh%d\n" for (int j = 0; j < max_latency; j++)
"# Lost packets: %" PRIu64 "\n", printf(" %06d %015" PRIi64 "\n", j, kernel_latency_hist[j]);
MAX_JITTER / 2 - min_jitter, duration_hour, duration_minutes,
ingress_stats.high_jitter); printf(
"# Duration: %dh%d\n"
"# Lost packets: %" PRIu64 "\n",
duration_hour, duration_minutes, ingress_stats.high_jitter);
}
printf("# Packet jitter histogram\n");
for (int j = min_jitter; j < max_jitter; j++)
printf(" %06d %015" PRIi64 "\n", j, jitter_hist[j]);
printf(
"# Middle: %d\n"
"# Duration: %dh%d\n"
"# Lost packets: %" PRIu64 "\n",
MAX_JITTER / 2 - min_jitter, duration_hour, duration_minutes,
ingress_stats.high_jitter);
}
} }
......
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