[Devel] [PATCH VZ10 v2 08/11] drivers/md/dm-stats: add wr_histogram option

Andrey Zhadchenko andrey.zhadchenko at virtuozzo.com
Mon Jul 27 19:32:51 MSK 2026


Allow a region to collect a latency histogram that only accounts
writes.

https://virtuozzo.atlassian.net/browse/VSTOR-103846
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
 Documentation/admin-guide/device-mapper/statistics.rst |  7 +++++--
 drivers/md/dm-stats.c                                  | 10 +++++++++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/Documentation/admin-guide/device-mapper/statistics.rst b/Documentation/admin-guide/device-mapper/statistics.rst
index 28e2f9c49ddcb..99b8ad45d47fd 100644
--- a/Documentation/admin-guide/device-mapper/statistics.rst
+++ b/Documentation/admin-guide/device-mapper/statistics.rst
@@ -98,6 +98,9 @@ Messages
 	  rd_histogram:n1,n2,n3,n4,...
 		collect a latency histogram like "histogram", but only
 		account read requests.
+	  wr_histogram:n1,n2,n3,n4,...
+		collect a latency histogram like "histogram", but only
+		account write 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.
@@ -145,8 +148,8 @@ Messages
 	        precise_timestamps hist_total_latency histogram:n1,n2,n3,...
 
 	The strings "precise_timestamps", "hist_total_latency" and
-	"histogram" (also "rd_histogram") are printed only if they were
-	specified when creating the region.
+	"histogram" (also "rd_histogram" and "wr_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 46d4468294197..9c2f290843bae 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		2
+#define DM_STAT_MAX_HISTOGRAMS		3
 
 struct dm_stat_histogram {
 	unsigned int class_mask;	/* classes this histogram accounts */
@@ -546,6 +546,8 @@ static const char *dm_stat_histogram_name(unsigned int class_mask)
 	switch (class_mask) {
 	case 1 << DM_STAT_CLASS_READ:
 		return "rd_histogram";
+	case 1 << DM_STAT_CLASS_WRITE:
+		return "wr_histogram";
 	default:
 		return "histogram";
 	}
@@ -1205,6 +1207,12 @@ static int message_stats_create(struct mapped_device *md,
 						  a + 13);
 				if (r)
 					goto ret;
+			} else if (!strncasecmp(a, "wr_histogram:", 13)) {
+				r = add_histogram(histograms, &n_histograms,
+						  1 << DM_STAT_CLASS_WRITE,
+						  a + 13);
+				if (r)
+					goto ret;
 			} else
 				goto ret_einval;
 		}
-- 
2.43.5



More information about the Devel mailing list