Skip to contentSkip to conversation

block latency histogram

PATCH Superseded Vladimir Sementsov-Ogievskiy 2 participants 7 messages Mar 9, 2018 Block layer

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover block latency histogram

v4:

Move block_latency_histogram_set from block/accounting.c to blockdev.c, as it uses qapi type uint64List and this fact breaks build.

v3:

- semantics, naming and wording changed a lot
- x prefixes added to new qapi names
- bug fixed about calculation of new_size (new_nbins now)
- drop g_renew
- in _clear() set nbinst to zero too

v2:

01: add block_latency_histogram_clear()
02: fix spelling (sorry =()
some rewordings
remove histogram if latency parameter unspecified

Vladimir Sementsov-Ogievskiy (2):
block/accounting: introduce latency histogram
qapi: add block latency histogram interface

 qapi/block-core.json       | 111 ++++++++++++++++++++++++++++++++++++++++++++-
 include/block/accounting.h |  32 +++++++++++++
 block/accounting.c         |  59 ++++++++++++++++++++++++
 block/qapi.c               |  41 +++++++++++++++++
 blockdev.c                 |  76 +++++++++++++++++++++++++++++++
 5 files changed, 318 insertions(+), 1 deletion(-)
Signature · 1 line
2.11.1
#1 lore raw

PATCH v4 1/2 block/accounting: introduce latency histogram

Introduce latency histogram statics for block devices. For each accounted operation type latency region [0, +inf) is divided into subregions by several points. Then, calculate hits for each subregion.

---
 include/block/accounting.h | 32 +++++++++++++++++++++++++
 block/accounting.c         | 59 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+)
include/block/accounting.h +32 -0
index b833d26d6c..e23951619e 100644
@@ -45,6 +45,36 @@ struct BlockAcctTimedStats {
     QSLIST_ENTRY(BlockAcctTimedStats) entries;
 };
 
+typedef struct BlockLatencyHistogram {
+    /* The following histogram is represented like this:
+     *
+     * 5|           *
+     * 4|           *
+     * 3| *         *
+     * 2| *         *    *
+     * 1| *    *    *    *
+     *  +------------------
+     *      10   50   100
+     *
+     * BlockLatencyHistogram histogram = {
+     *     .nbins = 4,
+     *     .boundaries = {10, 50, 100},
+     *     .bins = {3, 1, 5, 2},
+     * };
+     *
+     * @boundaries array define histogram intervals as follows:
+     * [0, boundaries[0]), [boundaries[0], boundaries[1]), ...
+     * [boundaries[nbins-2], +inf)
+     *
+     * So, for example above, histogram intervals are:
+     * [0, 10), [10, 50), [50, 100), [100, +inf)
+     */
+    int nbins;
+    uint64_t *boundaries; /* @nbins-1 numbers here
+                             (all boundaries, except 0 and +inf) */
+    uint64_t *bins;
+} BlockLatencyHistogram;
+
 struct BlockAcctStats {
     QemuMutex lock;
     uint64_t nr_bytes[BLOCK_MAX_IOTYPE];
@@ -57,6 +87,7 @@ struct BlockAcctStats {
     QSLIST_HEAD(, BlockAcctTimedStats) intervals;
     bool account_invalid;
     bool account_failed;
+    BlockLatencyHistogram latency_histogram[BLOCK_MAX_IOTYPE];
 };
 
 typedef struct BlockAcctCookie {
@@ -82,5 +113,6 @@ void block_acct_merge_done(BlockAcctStats *stats, enum BlockAcctType type,
 int64_t block_acct_idle_time_ns(BlockAcctStats *stats);
 double block_acct_queue_depth(BlockAcctTimedStats *stats,
                               enum BlockAcctType type);
+void block_latency_histograms_clear(BlockAcctStats *stats);
 
 #endif
block/accounting.c +59 -0

71 lines not on this page · raw message

Signature · 1 line
2.11.1
#2 lore raw

PATCH v4 2/2 qapi: add block latency histogram interface

In reply to Vladimir Sementsov-Ogievskiy

Set (and clear) histogram through new command block-latency-histogram-set and show new statistics in query-blockstats results.

---
 qapi/block-core.json | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 block/qapi.c         |  41 +++++++++++++++++++
 blockdev.c           |  76 +++++++++++++++++++++++++++++++++++
 3 files changed, 227 insertions(+), 1 deletion(-)
qapi/block-core.json +110 -1
index 8225308904..fd4c13ad8a 100644
@@ -451,6 +451,106 @@
            'status': 'DirtyBitmapStatus'} }
 
 ##
+# @XBlockLatencyHistogramInfo:
+#
+# Block latency histogram.
+#
+# @boundaries: list of interval boundary values in nanoseconds, all greater
+#              than zero and in ascending order.
+#              For example, the list [10, 50, 100] produces the following
+#              histogram intervals: [0, 10), [10, 50), [50, 100), [100, +inf).
+#
+# @bins: list of io request counts corresponding to histogram intervals.
+#        len(@bins) = len(@boundaries) + 1
+#        For the example above, @bins may be something like [3, 1, 5, 2],
+#        and corresponding histogram looks like:
+#
+#        5|           *
+#        4|           *
+#        3| *         *
+#        2| *         *    *
+#        1| *    *    *    *
+#         +------------------
+#             10   50   100
+#
+# Since: 2.12
+##
+{ 'struct': 'XBlockLatencyHistogramInfo',
+  'data': {'boundaries': ['uint64'], 'bins': ['uint64'] } }
+
+##
+# @x-block-latency-histogram-set:
+#
+# Manage read, write and flush latency histograms for the device.
+#
+# If only @device parameter is specified, remove all present latency histograms
+# for the device. Otherwise, add/reset some of (or all) latency histograms.
+#
+# @device: device name to set latency histogram for.
+#
+# @boundaries: list of interval boundary values (see description in
+#              XBlockLatencyHistogramInfo definition). If specified, all
+#              latency histograms are removed, and empty ones created for all
+#              io types with intervals corresponding to @boundaries (except for
+#              io types, for which specific boundaries are set through the
+#              following parameters).
+#
+# @boundaries-read: list of interval boundary values for read latency
+#                   histogram. If specified, old read latency histogram is
+#                   removed, and empty one created with interavals
+#                   corresponding to @boundaries-read. The parameter has higher
+#                   priority then @boundaries.
+#
+# @boundaries-write: list of interaval boundary values for write latency
+#                    histogram.
+#
+# @boundaries-flush: list of interaval boundary values for flush latency
+#                    histogram.
+#
+# Returns: error if device is not found or @boundaries* arrays are invalid.
+#
+# Since: 2.12
+#
+# Example: set new histograms for all io types with intervals
+# [0, 10), [10, 50), [50, 100), [100, +inf):
+#
+# -> { "execute": "block-latency-histogram-set",
+#      "arguments": { "device": "drive0",
+#                     "boundaries": [10, 50, 100] } }
+# <- { "return": {} }
+#
+# Example: set new histogram only for write, other histograms will remain
+# not changed (or not created):
+#
+# -> { "execute": "block-latency-histogram-set",
+#      "arguments": { "device": "drive0",
+#                     "boundaries-write": [10, 50, 100] } }
+# <- { "return": {} }
+#
+# Example: set new histograms with the following intervals:
+#   read, flush: [0, 10), [10, 50), [50, 100), [100, +inf)
+#   write: [0, 1000), [1000, 5000), [5000, +inf)
+#
+# -> { "execute": "block-latency-histogram-set",
+#      "arguments": { "device": "drive0",
+#                     "boundaries": [10, 50, 100],
+#                     "boundaries-write": [1000, 5000] } }
+# <- { "return": {} }
+#
+# Example: remove all latency histograms:
+#
+# -> { "execute": "block-latency-histogram-set",
+#      "arguments": { "device": "drive0" } }
+# <- { "return": {} }
+##
+{ 'command': 'x-block-latency-histogram-set',
+  'data': {'device': 'str',
+           '*boundaries': ['uint64'],
+           '*boundaries-read': ['uint64'],
+           '*boundaries-write': ['uint64'],
+           '*boundaries-flush': ['uint64'] } }
+
+##
 # @BlockInfo:
 #
 # Block device information.  This structure describes a virtual device and
@@ -730,6 +830,12 @@
 # @timed_stats: Statistics specific to the set of previously defined
 #               intervals of time (Since 2.5)
 #
+# @x_rd_latency_histogram: @BlockLatencyHistogramInfo. (Since 2.12)
+#
+# @x_wr_latency_histogram: @BlockLatencyHistogramInfo. (Since 2.12)
+#
+# @x_flush_latency_histogram: @BlockLatencyHistogramInfo. (Since 2.12)
+#
 # Since: 0.14.0
 ##
 { 'struct': 'BlockDeviceStats',
@@ -742,7 +848,10 @@
            'failed_flush_operations': 'int', 'invalid_rd_operations': 'int',
            'invalid_wr_operations': 'int', 'invalid_flush_operations': 'int',
            'account_invalid': 'bool', 'account_failed': 'bool',
-           'timed_stats': ['BlockDeviceTimedStats'] } }
+           'timed_stats': ['BlockDeviceTimedStats'],
+           '*x_rd_latency_histogram': 'XBlockLatencyHistogramInfo',
+           '*x_wr_latency_histogram': 'XBlockLatencyHistogramInfo',
+           '*x_flush_latency_histogram': 'XBlockLatencyHistogramInfo' } }
 
 ##
 # @BlockStats:
block/qapi.c +41 -0

53 lines not on this page · raw message

blockdev.c +76 -0

82 lines not on this page · raw message

Signature · 1 line
2.11.1
#3 lore raw
In reply to Vladimir Sementsov-Ogievskiy
Quoted 5 lines · Vladimir Sementsov-Ogievskiy

v4:

Move block_latency_histogram_set from block/accounting.c to blockdev.c, as it uses qapi type uint64List and this fact breaks build.

Was the cross file motion necessary, or could you just fix the #includes according to the recent qapi header refactoring?

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#4 lore raw
Quoted 9 lines · Eric Blake
Quoted 5 lines · Vladimir Sementsov-Ogievskiy

v4:

Move block_latency_histogram_set from block/accounting.c to blockdev.c, as it uses qapi type uint64List and this fact breaks build.

Was the cross file motion necessary, or could you just fix the #includes according to the recent qapi header refactoring?

Looks like it's not as simple..

/tmp/qemu-test/src/include/block/accounting.h:30:10: fatal error: qapi-types.h: No such file or directory
#include "qapi-types.h

what to do now? Looks like qapi-types are not generated for some builds. So, this version (v4) should take place.

Signature · 2 lines
Best regards,
Vladimir
#5 lore raw
Quoted 11 lines · Vladimir Sementsov-Ogievskiy
Quoted 9 lines · Eric Blake
Quoted 5 lines · Vladimir Sementsov-Ogievskiy

v4:

Move block_latency_histogram_set from block/accounting.c to blockdev.c, as it uses qapi type uint64List and this fact breaks build.

Was the cross file motion necessary, or could you just fix the #includes according to the recent qapi header refactoring?

Quoted 7 lines

Looks like it's not as simple..

/tmp/qemu-test/src/include/block/accounting.h:30:10: fatal error: qapi-types.h: No such file or directory
 #include "qapi-types.h

what to do now? Looks like qapi-types are not generated for some builds. So, this version (v4) should take place.

top-level qapi-types.h was replaced by lots of qapi/qapi*.h modular headers. Unfortunately, incremental builds don't delete the stale qapi-types.h that was left in tree from the point prior to the qapi header refactoring.

To get uint64List, use qapi/qapi-builtin-types.h. To get any type defined in a qapi/MODULE.json file, use qapi/qapi-MODULE-types.h.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#6 lore raw
Quoted 18 lines · Eric Blake
Quoted 17 lines · Vladimir Sementsov-Ogievskiy
Quoted 9 lines · Eric Blake
Quoted 5 lines · Vladimir Sementsov-Ogievskiy

v4:

Move block_latency_histogram_set from block/accounting.c to blockdev.c, as it uses qapi type uint64List and this fact breaks build.

Was the cross file motion necessary, or could you just fix the #includes according to the recent qapi header refactoring?

Looks like it's not as simple..

/tmp/qemu-test/src/include/block/accounting.h:30:10: fatal error: qapi-types.h: No such file or directory #include "qapi-types.h

Quoted 6 lines
Quoted 1 line

what to do now? Looks like qapi-types are not generated for some builds. So, this version (v4) should take place.

top-level qapi-types.h was replaced by lots of qapi/qapi*.h modular headers.  Unfortunately, incremental builds don't delete the stale qapi-types.h that was left in tree from the point prior to the qapi header refactoring.

To get uint64List, use qapi/qapi-builtin-types.h.  To get any type defined in a qapi/MODULE.json file, use qapi/qapi-MODULE-types.h.

thanks, now it works, after git clean..

Signature · 2 lines
Best regards,
Vladimir