1a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#ifndef FIO_STAT_H 2a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#define FIO_STAT_H 3a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 4ec41265e81c70d8573d1359e27876c37c30c7d9dJens Axboe#include "iolog.h" 5eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes#include "lib/output_buffer.h" 6ec41265e81c70d8573d1359e27876c37c30c7d9dJens Axboe 7a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboestruct group_run_stats { 86eaf09d6e9ca1f8accb057cdb18620b7e53ae33fShaohua Li uint64_t max_run[DDIR_RWDIR_CNT], min_run[DDIR_RWDIR_CNT]; 96eaf09d6e9ca1f8accb057cdb18620b7e53ae33fShaohua Li uint64_t max_bw[DDIR_RWDIR_CNT], min_bw[DDIR_RWDIR_CNT]; 10eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t iobytes[DDIR_RWDIR_CNT]; 116eaf09d6e9ca1f8accb057cdb18620b7e53ae33fShaohua Li uint64_t agg[DDIR_RWDIR_CNT]; 12a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint32_t kb_base; 13ad705bcb7e79a7cdb9891db17b4c40b13b6c30c3Steven Noonan uint32_t unit_base; 14a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint32_t groupid; 15771e58befea806d2d881953050c4e65329eee382Jens Axboe uint32_t unified_rw_rep; 16eb663201be7f38339e9177fbbd2b99da30f19e61Jens Axboe} __attribute__((packed)); 17a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 18a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe/* 19a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * How many depth levels to log 20a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe */ 21a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#define FIO_IO_U_MAP_NR 7 22a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#define FIO_IO_U_LAT_U_NR 10 23a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#define FIO_IO_U_LAT_M_NR 12 24a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 25a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe/* 26a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * Aggregate clat samples to report percentile(s) of them. 27a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 28a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * EXECUTIVE SUMMARY 29a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 30a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * FIO_IO_U_PLAT_BITS determines the maximum statistical error on the 31a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * value of resulting percentiles. The error will be approximately 32a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 1/2^(FIO_IO_U_PLAT_BITS+1) of the value. 33a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 34a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * FIO_IO_U_PLAT_GROUP_NR and FIO_IO_U_PLAT_BITS determine the maximum 35a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * range being tracked for latency samples. The maximum value tracked 36a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * accurately will be 2^(GROUP_NR + PLAT_BITS -1) microseconds. 37a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 38a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * FIO_IO_U_PLAT_GROUP_NR and FIO_IO_U_PLAT_BITS determine the memory 39a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * requirement of storing those aggregate counts. The memory used will 40a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * be (FIO_IO_U_PLAT_GROUP_NR * 2^FIO_IO_U_PLAT_BITS) * sizeof(int) 41a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * bytes. 42a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 43a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * FIO_IO_U_PLAT_NR is the total number of buckets. 44a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 45a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * DETAILS 46a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 47a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * Suppose the clat varies from 0 to 999 (usec), the straightforward 48a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * method is to keep an array of (999 + 1) buckets, in which a counter 49a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * keeps the count of samples which fall in the bucket, e.g., 50a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * {[0],[1],...,[999]}. However this consumes a huge amount of space, 51a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * and can be avoided if an approximation is acceptable. 52a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 53a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * One such method is to let the range of the bucket to be greater 54a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * than one. This method has low accuracy when the value is small. For 55a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * example, let the buckets be {[0,99],[100,199],...,[900,999]}, and 56a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * the represented value of each bucket be the mean of the range. Then 57a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * a value 0 has an round-off error of 49.5. To improve on this, we 58a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * use buckets with non-uniform ranges, while bounding the error of 59a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * each bucket within a ratio of the sample value. A simple example 60a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * would be when error_bound = 0.005, buckets are { 61a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * {[0],[1],...,[99]}, {[100,101],[102,103],...,[198,199]},.., 62a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * {[900,909],[910,919]...} }. The total range is partitioned into 63a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * groups with different ranges, then buckets with uniform ranges. An 64a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * upper bound of the error is (range_of_bucket/2)/value_of_bucket 65a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 66a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * For better efficiency, we implement this using base two. We group 67a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * samples by their Most Significant Bit (MSB), extract the next M bit 68a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * of them as an index within the group, and discard the rest of the 69a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * bits. 70a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 71a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * E.g., assume a sample 'x' whose MSB is bit n (starting from bit 0), 72a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * and use M bit for indexing 73a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 74a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * | n | M bits | bit (n-M-1) ... bit 0 | 75a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 76a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * Because x is at least 2^n, and bit 0 to bit (n-M-1) is at most 77a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * (2^(n-M) - 1), discarding bit 0 to (n-M-1) makes the round-off 78a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * error 79a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 80a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 2^(n-M)-1 2^(n-M) 1 81a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * e <= --------- <= ------- = --- 82a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 2^n 2^n 2^M 83a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 84a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * Furthermore, we use "mean" of the range to represent the bucket, 85a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * the error e can be lowered by half to 1 / 2^(M+1). By using M bits 86a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * as the index, each group must contains 2^M buckets. 87a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 88a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * E.g. Let M (FIO_IO_U_PLAT_BITS) be 6 89a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * Error bound is 1/2^(6+1) = 0.0078125 (< 1%) 90a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 91a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * Group MSB #discarded range of #buckets 92a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * error_bits value 93a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * ---------------------------------------------------------------- 94a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 0* 0~5 0 [0,63] 64 95a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 1* 6 0 [64,127] 64 96a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 2 7 1 [128,255] 64 97a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 3 8 2 [256,511] 64 98a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 4 9 3 [512,1023] 64 99a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * ... ... ... [...,...] ... 100a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 18 23 17 [8838608,+inf]** 64 101a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 102a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * * Special cases: when n < (M-1) or when n == (M-1), in both cases, 103a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * the value cannot be rounded off. Use all bits of the sample as 104a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * index. 105a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * 106a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * ** If a sample's MSB is greater than 23, it will be counted as 23. 107a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe */ 108a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 109a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#define FIO_IO_U_PLAT_BITS 6 110a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#define FIO_IO_U_PLAT_VAL (1 << FIO_IO_U_PLAT_BITS) 111a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#define FIO_IO_U_PLAT_GROUP_NR 19 112a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#define FIO_IO_U_PLAT_NR (FIO_IO_U_PLAT_GROUP_NR * FIO_IO_U_PLAT_VAL) 113a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#define FIO_IO_U_LIST_MAX_LEN 20 /* The size of the default and user-specified 114a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe list of percentiles */ 115a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 116eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes/* 117eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes * Trim cycle count measurements 118eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes */ 119eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes#define MAX_NR_BLOCK_INFOS 8192 120eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes#define BLOCK_INFO_STATE_SHIFT 29 121eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes#define BLOCK_INFO_TRIMS(block_info) \ 122eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes ((block_info) & ((1 << BLOCK_INFO_STATE_SHIFT) - 1)) 123eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes#define BLOCK_INFO_STATE(block_info) \ 124eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes ((block_info) >> BLOCK_INFO_STATE_SHIFT) 125eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes#define BLOCK_INFO(state, trim_cycles) \ 126eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes ((trim_cycles) | ((unsigned int) (state) << BLOCK_INFO_STATE_SHIFT)) 127eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes#define BLOCK_INFO_SET_STATE(block_info, state) \ 128eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes BLOCK_INFO(state, BLOCK_INFO_TRIMS(block_info)) 129eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesenum block_info_state { 130eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes BLOCK_STATE_UNINIT, 131eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes BLOCK_STATE_TRIMMED, 132eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes BLOCK_STATE_WRITTEN, 133eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes BLOCK_STATE_TRIM_FAILURE, 134eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes BLOCK_STATE_WRITE_FAILURE, 135eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes BLOCK_STATE_COUNT, 136eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes}; 137eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes 138a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#define MAX_PATTERN_SIZE 512 139a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#define FIO_JOBNAME_SIZE 128 1404e59d0f3a3ff569bddb31fe6927a9faf204ae9bfJens Axboe#define FIO_JOBDESC_SIZE 256 141a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#define FIO_VERROR_SIZE 128 142a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 143a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboestruct thread_stat { 144a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe char name[FIO_JOBNAME_SIZE]; 145a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe char verror[FIO_VERROR_SIZE]; 146ddcc0b69aa4ed04c8681f447a1a6274bb8837a14Jens Axboe uint32_t error; 1472f122b135b7319ff8dd04dadf31ff28b301051a3Jens Axboe uint32_t thread_number; 148ddcc0b69aa4ed04c8681f447a1a6274bb8837a14Jens Axboe uint32_t groupid; 149a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint32_t pid; 1504e59d0f3a3ff569bddb31fe6927a9faf204ae9bfJens Axboe char description[FIO_JOBDESC_SIZE]; 151a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint32_t members; 152771e58befea806d2d881953050c4e65329eee382Jens Axboe uint32_t unified_rw_rep; 153a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 154a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe /* 155a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * bandwidth and latency stats 156a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe */ 1576eaf09d6e9ca1f8accb057cdb18620b7e53ae33fShaohua Li struct io_stat clat_stat[DDIR_RWDIR_CNT]; /* completion latency */ 1586eaf09d6e9ca1f8accb057cdb18620b7e53ae33fShaohua Li struct io_stat slat_stat[DDIR_RWDIR_CNT]; /* submission latency */ 1596eaf09d6e9ca1f8accb057cdb18620b7e53ae33fShaohua Li struct io_stat lat_stat[DDIR_RWDIR_CNT]; /* total latency */ 1606eaf09d6e9ca1f8accb057cdb18620b7e53ae33fShaohua Li struct io_stat bw_stat[DDIR_RWDIR_CNT]; /* bandwidth stats */ 1616eaf09d6e9ca1f8accb057cdb18620b7e53ae33fShaohua Li struct io_stat iops_stat[DDIR_RWDIR_CNT]; /* IOPS stats */ 162a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 163a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe /* 164a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * fio system usage accounting 165a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe */ 166a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint64_t usr_time; 167a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint64_t sys_time; 168a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint64_t ctx; 169a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint64_t minf, majf; 170a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 171a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe /* 172a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * IO depth and latency stats 173a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe */ 174a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint64_t clat_percentiles; 175435d195a9da120c5a618129cdb73418f4748c20aVincent Kang Fu uint64_t percentile_precision; 176802ad4a83e92a30b5fdccf117d59fbb69068c054Jens Axboe fio_fp64_t percentile_list[FIO_IO_U_LIST_MAX_LEN]; 177a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 178a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint32_t io_u_map[FIO_IO_U_MAP_NR]; 179a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint32_t io_u_submit[FIO_IO_U_MAP_NR]; 180a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint32_t io_u_complete[FIO_IO_U_MAP_NR]; 181a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint32_t io_u_lat_u[FIO_IO_U_LAT_U_NR]; 182a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint32_t io_u_lat_m[FIO_IO_U_LAT_M_NR]; 1836eaf09d6e9ca1f8accb057cdb18620b7e53ae33fShaohua Li uint32_t io_u_plat[DDIR_RWDIR_CNT][FIO_IO_U_PLAT_NR]; 1844ffeb0addbb090160f2d4eb1e98a1f184ed9ac66Gwendal Grignou uint32_t pad; 1854ffeb0addbb090160f2d4eb1e98a1f184ed9ac66Gwendal Grignou 186eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t total_io_u[DDIR_RWDIR_CNT]; 187eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t short_io_u[DDIR_RWDIR_CNT]; 188eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t drop_io_u[DDIR_RWDIR_CNT]; 189a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint64_t total_submit; 190a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint64_t total_complete; 191a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 1926eaf09d6e9ca1f8accb057cdb18620b7e53ae33fShaohua Li uint64_t io_bytes[DDIR_RWDIR_CNT]; 1936eaf09d6e9ca1f8accb057cdb18620b7e53ae33fShaohua Li uint64_t runtime[DDIR_RWDIR_CNT]; 194a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint64_t total_run_time; 195a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 196a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe /* 197a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe * IO Error related stats 198a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe */ 1994ffeb0addbb090160f2d4eb1e98a1f184ed9ac66Gwendal Grignou union { 2004ffeb0addbb090160f2d4eb1e98a1f184ed9ac66Gwendal Grignou uint16_t continue_on_error; 201eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint32_t pad2; 2024ffeb0addbb090160f2d4eb1e98a1f184ed9ac66Gwendal Grignou }; 203ddcc0b69aa4ed04c8681f447a1a6274bb8837a14Jens Axboe uint32_t first_error; 204eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t total_err_count; 205eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes 206eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t nr_block_infos; 207eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint32_t block_infos[MAX_NR_BLOCK_INFOS]; 208a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 209a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe uint32_t kb_base; 210ad705bcb7e79a7cdb9891db17b4c40b13b6c30c3Steven Noonan uint32_t unit_base; 2113e260a46ea9a8de224c3d0a29a608da3440f284aJens Axboe 2123e260a46ea9a8de224c3d0a29a608da3440f284aJens Axboe uint32_t latency_depth; 213eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint32_t pad3; 2143e260a46ea9a8de224c3d0a29a608da3440f284aJens Axboe uint64_t latency_target; 2153e260a46ea9a8de224c3d0a29a608da3440f284aJens Axboe fio_fp64_t latency_percentile; 2163e260a46ea9a8de224c3d0a29a608da3440f284aJens Axboe uint64_t latency_window; 217eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes 218eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t ss_dur; 219eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint32_t ss_state; 220eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint32_t ss_head; 221eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes 222eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes fio_fp64_t ss_limit; 223eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes fio_fp64_t ss_slope; 224eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes fio_fp64_t ss_deviation; 225eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes fio_fp64_t ss_criterion; 226eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes 227eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes union { 228eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t *ss_iops_data; 229eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t pad4; 230eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes }; 231eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes 232eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes union { 233eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t *ss_bw_data; 234eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t pad5; 235eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes }; 236eb663201be7f38339e9177fbbd2b99da30f19e61Jens Axboe} __attribute__((packed)); 237a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe 238b75a394fd0e9455ab71912d4462aaae7e6e4366bJens Axboestruct jobs_eta { 239b75a394fd0e9455ab71912d4462aaae7e6e4366bJens Axboe uint32_t nr_running; 240b75a394fd0e9455ab71912d4462aaae7e6e4366bJens Axboe uint32_t nr_ramp; 241ce8ea6e7f0a08f282d06dd3f0890fe7128146f44Jens Axboe 242b75a394fd0e9455ab71912d4462aaae7e6e4366bJens Axboe uint32_t nr_pending; 243714e85f340194409d0abcf643cd2f154a7380a74Jens Axboe uint32_t nr_setting_up; 244ce8ea6e7f0a08f282d06dd3f0890fe7128146f44Jens Axboe 245b75a394fd0e9455ab71912d4462aaae7e6e4366bJens Axboe uint32_t files_open; 246ce8ea6e7f0a08f282d06dd3f0890fe7128146f44Jens Axboe 247eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t m_rate[DDIR_RWDIR_CNT], t_rate[DDIR_RWDIR_CNT]; 248d79db1222039e906dd49ae290daa59701f4e2385Jens Axboe uint32_t m_iops[DDIR_RWDIR_CNT], t_iops[DDIR_RWDIR_CNT]; 249eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes uint64_t rate[DDIR_RWDIR_CNT]; 2506eaf09d6e9ca1f8accb057cdb18620b7e53ae33fShaohua Li uint32_t iops[DDIR_RWDIR_CNT]; 251b75a394fd0e9455ab71912d4462aaae7e6e4366bJens Axboe uint64_t elapsed_sec; 252b75a394fd0e9455ab71912d4462aaae7e6e4366bJens Axboe uint64_t eta_sec; 253b7f05eb03c84bdc1259d1bb1c348328b16164430Jens Axboe uint32_t is_pow2; 254ad705bcb7e79a7cdb9891db17b4c40b13b6c30c3Steven Noonan uint32_t unit_base; 2551d1f45aec4bd2c1168ed5539174a821555db6f65Jens Axboe 2561d1f45aec4bd2c1168ed5539174a821555db6f65Jens Axboe /* 2571d1f45aec4bd2c1168ed5539174a821555db6f65Jens Axboe * Network 'copy' of run_str[] 2581d1f45aec4bd2c1168ed5539174a821555db6f65Jens Axboe */ 2591d1f45aec4bd2c1168ed5539174a821555db6f65Jens Axboe uint32_t nr_threads; 260372aecb9049618c1279a946b66f6b29066730951Jens Axboe uint8_t run_str[]; 261eb663201be7f38339e9177fbbd2b99da30f19e61Jens Axboe} __attribute__((packed)); 262b75a394fd0e9455ab71912d4462aaae7e6e4366bJens Axboe 263eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesstruct io_u_plat_entry { 264eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes struct flist_head list; 265eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes unsigned int io_u_plat[FIO_IO_U_PLAT_NR]; 266eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes}; 267eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes 268c38e38f16f77567a423f75c26e1929cbe4902e24Vasily Tarasovextern struct fio_mutex *stat_mutex; 269c38e38f16f77567a423f75c26e1929cbe4902e24Vasily Tarasov 270eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern struct jobs_eta *get_jobs_eta(bool force, size_t *size); 27161f6cced3dcde7e4a6fc9fca01783ec80ff269a4Jens Axboe 272cef9175e52e8a240117b9f45b228fdaa0f1c0572Jens Axboeextern void stat_init(void); 273cef9175e52e8a240117b9f45b228fdaa0f1c0572Jens Axboeextern void stat_exit(void); 274cef9175e52e8a240117b9f45b228fdaa0f1c0572Jens Axboe 275eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern struct json_object * show_thread_status(struct thread_stat *ts, struct group_run_stats *rs, struct flist_head *, struct buf_output *); 276eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern void show_group_stats(struct group_run_stats *rs, struct buf_output *); 277eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern bool calc_thread_status(struct jobs_eta *je, int force); 278cf451d1ede3bbbd2fed3619eb43def054d5b5a5aJens Axboeextern void display_thread_status(struct jobs_eta *je); 2795b9babb7fb9ac46c0e960ccd88c2d85ba3065c01Jens Axboeextern void show_run_stats(void); 2802e627243f7877cefb3606ef99ec24debe32ac98cJens Axboeextern void __show_run_stats(void); 2817fe36313273ef051670d16aa27953699fd5cdf06Jens Axboeextern void __show_running_run_stats(void); 282b852e7cf097cec1c7fb92305f9c3c6b394bb39adJens Axboeextern void show_running_run_stats(void); 28306464907159baf7a1eeac654a023743e33f28d86Jens Axboeextern void check_for_running_stats(void); 284eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, bool first); 28537f0c1ae23ad1716403d3d113c3dfdf41c47e329Jens Axboeextern void sum_group_stats(struct group_run_stats *dst, struct group_run_stats *src); 28637f0c1ae23ad1716403d3d113c3dfdf41c47e329Jens Axboeextern void init_thread_stat(struct thread_stat *ts); 28737f0c1ae23ad1716403d3d113c3dfdf41c47e329Jens Axboeextern void init_group_run_stat(struct group_run_stats *gs); 2883e47bd250cac5fb81a5c0ad578dfbe90c6ddf6deJens Axboeextern void eta_to_str(char *str, unsigned long eta_sec); 289eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern bool calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max, double *mean, double *dev); 290a269790cd25788dd4226641a3ceab1b3c8fda14bJens Axboeextern unsigned int calc_clat_percentiles(unsigned int *io_u_plat, unsigned long nr, fio_fp64_t *plist, unsigned int **output, unsigned int *maxv, unsigned int *minv); 291e5bd13470beaeed9c4a6835b7b92265fb94173a9Jens Axboeextern void stat_calc_lat_m(struct thread_stat *ts, double *io_u_lat); 292e5bd13470beaeed9c4a6835b7b92265fb94173a9Jens Axboeextern void stat_calc_lat_u(struct thread_stat *ts, double *io_u_lat); 2932e33101f218a1603eeecca969f5b7a0e98696a01Jens Axboeextern void stat_calc_dist(unsigned int *map, unsigned long total, double *io_u_dist); 2946bb58215842760895071d9f331da4dc2dfc16f30Jens Axboeextern void reset_io_stats(struct thread_data *); 295eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern void update_rusage_stat(struct thread_data *); 296eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern void clear_rusage_stat(struct thread_data *); 297eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes 298eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern void add_lat_sample(struct thread_data *, enum fio_ddir, unsigned long, 299eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes unsigned int, uint64_t); 300eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern void add_clat_sample(struct thread_data *, enum fio_ddir, unsigned long, 301eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes unsigned int, uint64_t); 302eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern void add_slat_sample(struct thread_data *, enum fio_ddir, unsigned long, 303eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes unsigned int, uint64_t); 304eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern void add_agg_sample(union io_sample_data, enum fio_ddir, unsigned int); 305eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern void add_iops_sample(struct thread_data *, struct io_u *, 306eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes unsigned int); 307eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern void add_bw_sample(struct thread_data *, struct io_u *, 308eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes unsigned int, unsigned long); 309eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern int calc_log_samples(void); 3102e33101f218a1603eeecca969f5b7a0e98696a01Jens Axboe 311eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern struct io_log *agg_io_log[DDIR_RWDIR_CNT]; 312eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesextern int write_bw_log; 313eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes 314eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesstatic inline bool usec_to_msec(unsigned long *min, unsigned long *max, 315eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes double *mean, double *dev) 316b29ad56266faa33326de00e315d2b34b735fb028Jens Axboe{ 317b29ad56266faa33326de00e315d2b34b735fb028Jens Axboe if (*min > 1000 && *max > 1000 && *mean > 1000.0 && *dev > 1000.0) { 318b29ad56266faa33326de00e315d2b34b735fb028Jens Axboe *min /= 1000; 319b29ad56266faa33326de00e315d2b34b735fb028Jens Axboe *max /= 1000; 320b29ad56266faa33326de00e315d2b34b735fb028Jens Axboe *mean /= 1000.0; 321b29ad56266faa33326de00e315d2b34b735fb028Jens Axboe *dev /= 1000.0; 322eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes return true; 323b29ad56266faa33326de00e315d2b34b735fb028Jens Axboe } 324b29ad56266faa33326de00e315d2b34b735fb028Jens Axboe 325eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes return false; 326b29ad56266faa33326de00e315d2b34b735fb028Jens Axboe} 32761f6cced3dcde7e4a6fc9fca01783ec80ff269a4Jens Axboe/* 32861f6cced3dcde7e4a6fc9fca01783ec80ff269a4Jens Axboe * Worst level condensing would be 1:5, so allow enough room for that 32961f6cced3dcde7e4a6fc9fca01783ec80ff269a4Jens Axboe */ 33061f6cced3dcde7e4a6fc9fca01783ec80ff269a4Jens Axboe#define __THREAD_RUNSTR_SZ(nr) ((nr) * 5) 3311814876d9e82b2b03b042581b5d2c743638726e5Jens Axboe#define THREAD_RUNSTR_SZ __THREAD_RUNSTR_SZ(thread_number) 3321814876d9e82b2b03b042581b5d2c743638726e5Jens Axboe 333eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughesuint32_t *io_u_block_info(struct thread_data *td, struct io_u *io_u); 334eda3a60699e1d96bb68875ef2169ca819eb8f4f9Elliott Hughes 335a64e88dad0c0e4a510ae8ab54cde1a20b99c59d1Jens Axboe#endif 336