From: Niklas Cassel <niklas.cassel@xxxxxxx> It is not obvious why add_clat_sample() shouldn't add a high/low clat prio sample when ts->lat_percentiles is set. Especially considering that ts->lat_percentiles is used for controlling if total latency percentiles should be displayed or not. Neither did I manage to find anything in the man page related to this. Luckily, I managed to find commit 38ec5c514104 ("stat: make priority summary statistics consistent with percentiles") that describes why things are implemented the way they are. Add comments to describe why add_clat_sample() has to care about ts->lat_percentiles. Signed-off-by: Niklas Cassel <niklas.cassel@xxxxxxx> --- stat.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/stat.c b/stat.c index 514f08eb..48c70072 100644 --- a/stat.c +++ b/stat.c @@ -3090,6 +3090,15 @@ void add_clat_sample(struct thread_data *td, enum fio_ddir ddir, add_stat_sample(&ts->clat_stat[ddir], nsec); + /* + * When lat_percentiles=1 (default 0), the reported high/low priority + * percentiles and stats are used for describing total latency values, + * even though the variable names themselves start with clat_. + * + * Because of the above definition, only let this function add a prio + * stat sample when lat_percentiles=0 (add_lat_sample() will add the + * prio stat sample when lat_percentiles=1). + */ if (!ts->lat_percentiles) { if (high_prio) add_stat_sample(&ts->clat_high_prio_stat[ddir], nsec); @@ -3103,6 +3112,12 @@ void add_clat_sample(struct thread_data *td, enum fio_ddir ddir, if (ts->clat_percentiles) { add_lat_percentile_sample(ts, nsec, ddir, FIO_CLAT); + /* + * Because of the above definition, only let this function add a + * prio lat percentile sample when lat_percentiles=0 + * (add_lat_sample() will add the prio lat percentile sample + * when lat_percentiles=1). + */ if (!ts->lat_percentiles) add_lat_percentile_prio_sample(ts, nsec, ddir, high_prio); @@ -3195,6 +3210,16 @@ void add_lat_sample(struct thread_data *td, enum fio_ddir ddir, add_log_sample(td, td->lat_log, sample_val(nsec), ddir, bs, offset, ioprio); + /* + * When lat_percentiles=1 (default 0), the reported high/low priority + * percentiles and stats are used for describing total latency values, + * even though the variable names themselves start with clat_. + * + * Because of the above definition, only let this function add a prio + * stat and prio lat percentile sample when lat_percentiles=1 + * (add_clat_sample() will add the prio stat and prio lat percentile + * sample when lat_percentiles=0). + */ if (ts->lat_percentiles) { add_lat_percentile_sample(ts, nsec, ddir, FIO_LAT); add_lat_percentile_prio_sample(ts, nsec, ddir, high_prio); -- 2.33.1