Skip to content

Commit fe137a4

Browse files
Andreas Zieglerrostedt
authored andcommitted
tools/tracing/rtla: osnoise_hist: use total duration for average calculation
Sampled durations must be weighted by observed quantity, to arrive at a correct average duration value. Perform calculation of total duration by summing (duration * count). Link: https://lkml.kernel.org/r/[email protected] Fixes: 829a6c0 ("rtla/osnoise: Add the hist mode") Signed-off-by: Andreas Ziegler <[email protected]> Acked-by: Daniel Bristot de Oliveira <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent a37380e commit fe137a4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ static void osnoise_hist_update_multiple(struct osnoise_tool *tool, int cpu,
121121
{
122122
struct osnoise_hist_params *params = tool->params;
123123
struct osnoise_hist_data *data = tool->data;
124+
unsigned long long total_duration;
124125
int entries = data->entries;
125126
int bucket;
126127
int *hist;
@@ -131,10 +132,12 @@ static void osnoise_hist_update_multiple(struct osnoise_tool *tool, int cpu,
131132
if (data->bucket_size)
132133
bucket = duration / data->bucket_size;
133134

135+
total_duration = duration * count;
136+
134137
hist = data->hist[cpu].samples;
135138
data->hist[cpu].count += count;
136139
update_min(&data->hist[cpu].min_sample, &duration);
137-
update_sum(&data->hist[cpu].sum_sample, &duration);
140+
update_sum(&data->hist[cpu].sum_sample, &total_duration);
138141
update_max(&data->hist[cpu].max_sample, &duration);
139142

140143
if (bucket < entries)

0 commit comments

Comments
 (0)