[Devel] [PATCH RHEL10 COMMIT] drivers/md/dm-stats: add rd_histogram option
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jul 31 15:11:49 MSK 2026
The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.1.vz10
------>
commit ecd0dbc260e03cc02f2027925b0a11b2d763dd0c
Author: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Date: Mon Jul 27 19:32:50 2026 +0300
drivers/md/dm-stats: add rd_histogram option
Allow a region to collect a latency histogram that only accounts
reads.
It can be combined with the existing "histogram:" argument within
one region.
https://virtuozzo.atlassian.net/browse/VSTOR-103846
Feature: dm-stats: latency and histogram enhancements
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Reviewed-by: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
.../admin-guide/device-mapper/statistics.rst | 10 ++++++++--
drivers/md/dm-stats.c | 21 +++++++++++++++++++--
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/Documentation/admin-guide/device-mapper/statistics.rst b/Documentation/admin-guide/device-mapper/statistics.rst
index d5b1b1013c087..28e2f9c49ddcb 100644
--- a/Documentation/admin-guide/device-mapper/statistics.rst
+++ b/Documentation/admin-guide/device-mapper/statistics.rst
@@ -95,6 +95,12 @@ Messages
that took 10-20 ms to complete, c is the number of requests
that took 20-30 ms to complete and d is the number of
requests that took more than 30 ms to complete.
+ rd_histogram:n1,n2,n3,n4,...
+ collect a latency histogram like "histogram", but only
+ account read requests.
+ Multiple histogram arguments may be specified for one region;
+ each histogram is reported as an additional counter set in the
+ @stats_print output, in the order the histograms were specified.
<program_id>
An optional parameter. A name that uniquely identifies
@@ -139,8 +145,8 @@ Messages
precise_timestamps hist_total_latency histogram:n1,n2,n3,...
The strings "precise_timestamps", "hist_total_latency" and
- "histogram" are printed only if they were specified when creating
- the region.
+ "histogram" (also "rd_histogram") are printed only if they were
+ specified when creating the region.
@stats_print <region_id> [<starting_line> <number_of_lines>]
Print counters for each step-sized area of a region.
diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
index e55b821fb9a34..46d4468294197 100644
--- a/drivers/md/dm-stats.c
+++ b/drivers/md/dm-stats.c
@@ -52,7 +52,7 @@ enum {
#define DM_STAT_CLASSES_DATA ((1 << DM_STAT_CLASS_READ) | \
(1 << DM_STAT_CLASS_WRITE))
-#define DM_STAT_MAX_HISTOGRAMS 1
+#define DM_STAT_MAX_HISTOGRAMS 2
struct dm_stat_histogram {
unsigned int class_mask; /* classes this histogram accounts */
@@ -541,6 +541,16 @@ static int dm_stats_delete(struct dm_stats *stats, int id)
return 0;
}
+static const char *dm_stat_histogram_name(unsigned int class_mask)
+{
+ switch (class_mask) {
+ case 1 << DM_STAT_CLASS_READ:
+ return "rd_histogram";
+ default:
+ return "histogram";
+ }
+}
+
static int dm_stats_list(struct dm_stats *stats, const char *program,
char *result, unsigned int maxlen)
{
@@ -572,7 +582,8 @@ static int dm_stats_list(struct dm_stats *stats, const char *program,
struct dm_stat_histogram *h = &s->histograms[hn];
unsigned int i;
- DMEMIT(" histogram:");
+ DMEMIT(" %s:",
+ dm_stat_histogram_name(h->class_mask));
for (i = 0; i < h->n_entries; i++) {
if (i)
DMEMIT(",");
@@ -1188,6 +1199,12 @@ static int message_stats_create(struct mapped_device *md,
DM_STAT_CLASSES_DATA, a + 10);
if (r)
goto ret;
+ } else if (!strncasecmp(a, "rd_histogram:", 13)) {
+ r = add_histogram(histograms, &n_histograms,
+ 1 << DM_STAT_CLASS_READ,
+ a + 13);
+ if (r)
+ goto ret;
} else
goto ret_einval;
}
More information about the Devel
mailing list