Revision c488c7f6

b/block.c
1916 1916
                        " rd_operations=%" PRId64
1917 1917
                        " wr_operations=%" PRId64
1918 1918
                        " flush_operations=%" PRId64
1919
                        " wr_total_time_ns=%" PRId64
1920
                        " rd_total_time_ns=%" PRId64
1921
                        " flush_total_time_ns=%" PRId64
1919 1922
                        "\n",
1920 1923
                        qdict_get_int(qdict, "rd_bytes"),
1921 1924
                        qdict_get_int(qdict, "wr_bytes"),
1922 1925
                        qdict_get_int(qdict, "rd_operations"),
1923 1926
                        qdict_get_int(qdict, "wr_operations"),
1924
                        qdict_get_int(qdict, "flush_operations"));
1927
                        qdict_get_int(qdict, "flush_operations"),
1928
                        qdict_get_int(qdict, "wr_total_time_ns"),
1929
                        qdict_get_int(qdict, "rd_total_time_ns"),
1930
                        qdict_get_int(qdict, "flush_total_time_ns"));
1925 1931
}
1926 1932

  
1927 1933
void bdrv_stats_print(Monitor *mon, const QObject *data)
......
1940 1946
                             "'rd_operations': %" PRId64 ","
1941 1947
                             "'wr_operations': %" PRId64 ","
1942 1948
                             "'wr_highest_offset': %" PRId64 ","
1943
                             "'flush_operations': %" PRId64
1949
                             "'flush_operations': %" PRId64 ","
1950
                             "'wr_total_time_ns': %" PRId64 ","
1951
                             "'rd_total_time_ns': %" PRId64 ","
1952
                             "'flush_total_time_ns': %" PRId64
1944 1953
                             "} }",
1945 1954
                             bs->nr_bytes[BDRV_ACCT_READ],
1946 1955
                             bs->nr_bytes[BDRV_ACCT_WRITE],
......
1948 1957
                             bs->nr_ops[BDRV_ACCT_WRITE],
1949 1958
                             bs->wr_highest_sector *
1950 1959
                             (uint64_t)BDRV_SECTOR_SIZE,
1951
                             bs->nr_ops[BDRV_ACCT_FLUSH]);
1960
                             bs->nr_ops[BDRV_ACCT_FLUSH],
1961
                             bs->total_time_ns[BDRV_ACCT_WRITE],
1962
                             bs->total_time_ns[BDRV_ACCT_READ],
1963
                             bs->total_time_ns[BDRV_ACCT_FLUSH]);
1952 1964
    dict  = qobject_to_qdict(res);
1953 1965

  
1954 1966
    if (*bs->device_name) {
......
3160 3172
    assert(type < BDRV_MAX_IOTYPE);
3161 3173

  
3162 3174
    cookie->bytes = bytes;
3175
    cookie->start_time_ns = get_clock();
3163 3176
    cookie->type = type;
3164 3177
}
3165 3178

  
......
3170 3183

  
3171 3184
    bs->nr_bytes[cookie->type] += cookie->bytes;
3172 3185
    bs->nr_ops[cookie->type]++;
3186
    bs->total_time_ns[cookie->type] += get_clock() - cookie->start_time_ns;
3173 3187
}
3174 3188

  
3175 3189
int bdrv_img_create(const char *filename, const char *fmt,
b/block.h
264 264

  
265 265
typedef struct BlockAcctCookie {
266 266
    int64_t bytes;
267
    int64_t start_time_ns;
267 268
    enum BlockAcctType type;
268 269
} BlockAcctCookie;
269 270

  
b/block_int.h
28 28
#include "qemu-option.h"
29 29
#include "qemu-queue.h"
30 30
#include "qemu-coroutine.h"
31
#include "qemu-timer.h"
31 32

  
32 33
#define BLOCK_FLAG_ENCRYPT	1
33 34
#define BLOCK_FLAG_COMPAT6	4
......
186 187
    /* I/O stats (display with "info blockstats"). */
187 188
    uint64_t nr_bytes[BDRV_MAX_IOTYPE];
188 189
    uint64_t nr_ops[BDRV_MAX_IOTYPE];
190
    uint64_t total_time_ns[BDRV_MAX_IOTYPE];
189 191
    uint64_t wr_highest_sector;
190 192

  
191 193
    /* Whether the disk can expand beyond total_sectors */
b/qmp-commands.hx
1202 1202
    - "rd_operations": read operations (json-int)
1203 1203
    - "wr_operations": write operations (json-int)
1204 1204
    - "flush_operations": cache flush operations (json-int)
1205
    - "wr_total_time_ns": total time spend on writes in nano-seconds (json-int)
1206
    - "rd_total_time_ns": total time spend on reads in nano-seconds (json-int)
1207
    - "flush_total_time_ns": total time spend on cache flushes in nano-seconds (json-int)
1205 1208
    - "wr_highest_offset": Highest offset of a sector written since the
1206 1209
                           BlockDriverState has been opened (json-int)
1207 1210
- "parent": Contains recursively the statistics of the underlying
......
1223 1226
                  "wr_operations":751,
1224 1227
                  "rd_bytes":122567168,
1225 1228
                  "rd_operations":36772
1229
                  "wr_total_times_ns":313253456
1230
                  "rd_total_times_ns":3465673657
1231
                  "flush_total_times_ns":49653
1226 1232
                  "flush_operations":61,
1227 1233
               }
1228 1234
            },
......
1233 1239
               "rd_bytes":122739200,
1234 1240
               "rd_operations":36604
1235 1241
               "flush_operations":51,
1242
               "wr_total_times_ns":313253456
1243
               "rd_total_times_ns":3465673657
1244
               "flush_total_times_ns":49653
1236 1245
            }
1237 1246
         },
1238 1247
         {
......
1244 1253
               "rd_bytes":0,
1245 1254
               "rd_operations":0
1246 1255
               "flush_operations":0,
1256
               "wr_total_times_ns":0
1257
               "rd_total_times_ns":0
1258
               "flush_total_times_ns":0
1247 1259
            }
1248 1260
         },
1249 1261
         {
......
1255 1267
               "rd_bytes":0,
1256 1268
               "rd_operations":0
1257 1269
               "flush_operations":0,
1270
               "wr_total_times_ns":0
1271
               "rd_total_times_ns":0
1272
               "flush_total_times_ns":0
1258 1273
            }
1259 1274
         },
1260 1275
         {
......
1266 1281
               "rd_bytes":0,
1267 1282
               "rd_operations":0
1268 1283
               "flush_operations":0,
1284
               "wr_total_times_ns":0
1285
               "rd_total_times_ns":0
1286
               "flush_total_times_ns":0
1269 1287
            }
1270 1288
         }
1271 1289
      ]

Also available in: Unified diff