Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ceph: track average r/w/m latency

Make the math a bit simpler to understand (should not
affect execution speeds).

Signed-off-by: Venky Shankar <vshankar@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

authored by

Venky Shankar and committed by
Ilya Dryomov
367290e6 8d728c76

+15 -13
+14 -13
fs/ceph/metric.c
··· 249 249 metric->size_max = 0; 250 250 metric->total = 0; 251 251 metric->latency_sum = 0; 252 + metric->latency_avg = 0; 252 253 metric->latency_sq_sum = 0; 253 254 metric->latency_min = KTIME_MAX; 254 255 metric->latency_max = 0; ··· 307 306 max = new; \ 308 307 } 309 308 310 - static inline void __update_stdev(ktime_t total, ktime_t lsum, 311 - ktime_t *sq_sump, ktime_t lat) 309 + static inline void __update_mean_and_stdev(ktime_t total, ktime_t *lavg, 310 + ktime_t *sq_sump, ktime_t lat) 312 311 { 313 - ktime_t avg, sq; 312 + ktime_t avg; 314 313 315 - if (unlikely(total == 1)) 316 - return; 317 - 318 - /* the sq is (lat - old_avg) * (lat - new_avg) */ 319 - avg = DIV64_U64_ROUND_CLOSEST((lsum - lat), (total - 1)); 320 - sq = lat - avg; 321 - avg = DIV64_U64_ROUND_CLOSEST(lsum, total); 322 - sq = sq * (lat - avg); 323 - *sq_sump += sq; 314 + if (unlikely(total == 1)) { 315 + *lavg = lat; 316 + } else { 317 + /* the sq is (lat - old_avg) * (lat - new_avg) */ 318 + avg = *lavg + div64_s64(lat - *lavg, total); 319 + *sq_sump += (lat - *lavg)*(lat - avg); 320 + *lavg = avg; 321 + } 324 322 } 325 323 326 324 void ceph_update_metrics(struct ceph_metric *m, ··· 338 338 METRIC_UPDATE_MIN_MAX(m->size_min, m->size_max, size); 339 339 m->latency_sum += lat; 340 340 METRIC_UPDATE_MIN_MAX(m->latency_min, m->latency_max, lat); 341 - __update_stdev(total, m->latency_sum, &m->latency_sq_sum, lat); 341 + __update_mean_and_stdev(total, &m->latency_avg, &m->latency_sq_sum, 342 + lat); 342 343 spin_unlock(&m->lock); 343 344 }
+1
fs/ceph/metric.h
··· 137 137 u64 size_min; 138 138 u64 size_max; 139 139 ktime_t latency_sum; 140 + ktime_t latency_avg; 140 141 ktime_t latency_sq_sum; 141 142 ktime_t latency_min; 142 143 ktime_t latency_max;