From c1e43cf8e0bdfb3901588b486e561db87454727a Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Fri, 18 Feb 2022 11:39:12 +0300 Subject: [PATCH] LU-15564 osd: add allocation time histogram add block mapping/allocation histogram to brw stats to debug mballoc related issues. $ lctl get_param osd*.*OST*.brw_stats read | write block maps msec maps % cum % | maps % cum % 1: 1522360 100 100 | 49272 99 99 2: 0 0 100 | 1 0 99 4: 0 0 100 | 1 0 99 8: 0 0 100 | 0 0 99 16: 0 0 100 | 0 0 99 32: 0 0 100 | 0 0 99 64: 0 0 100 | 1 0 100 Lustre-change: https://review.whamcloud.com/46550 Lustre-commit: f97ce54357bc91f7b1285febfc50d6087dd94c13 Signed-off-by: Alex Zhuravlev Change-Id: I1185386adc64e844de71e25a4e439e493e5e5bc5 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52767 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/include/lprocfs_status.h | 2 ++ lustre/obdclass/lprocfs_status_server.c | 3 +++ lustre/osd-ldiskfs/osd_io.c | 13 ++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index ce38b0d..32ce0e8 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -394,6 +394,8 @@ enum brw_rw_stats { BRW_W_IO_TIME, BRW_R_DISK_IOSIZE, BRW_W_DISK_IOSIZE, + BRW_MAP_TIME, + BRW_ALLOC_TIME, BRW_RW_STATS_NUM, }; diff --git a/lustre/obdclass/lprocfs_status_server.c b/lustre/obdclass/lprocfs_status_server.c index f5afac2..d785c50 100644 --- a/lustre/obdclass/lprocfs_status_server.c +++ b/lustre/obdclass/lprocfs_status_server.c @@ -735,6 +735,9 @@ static const struct brw_stats_props brw_props[] = { { .bsp_name = "disk I/O size", .bsp_units = "ios", .bsp_scale = true }, + { .bsp_name = "block maps msec", + .bsp_units = "maps", + .bsp_scale = true, }, }; static int brw_stats_seq_show(struct seq_file *seq, void *v) diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 9ba4b10..831406d 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1121,6 +1121,7 @@ static int osd_ldiskfs_map_inode_pages(struct inode *inode, while (i < pages) { long blen, total = 0, previous_total = 0; struct ldiskfs_map_blocks map = { 0 }; + ktime_t time; if (fp == NULL) { /* start new extent */ fp = *page++; @@ -1176,9 +1177,19 @@ cont_map: if (osd->od_extents_dense && compressed) create |= LDISKFS_GET_BLOCKS_VERY_DENSE; #endif + + time = ktime_get(); rc = ldiskfs_map_blocks(handle, inode, &map, create); + time = ktime_sub(ktime_get(), time); + if (rc >= 0) { - int c = 0; + struct brw_stats *h = &osd->od_brw_stats; + int idx, c = 0; + + idx = map.m_flags & LDISKFS_MAP_NEW ? + BRW_ALLOC_TIME : BRW_MAP_TIME; + lprocfs_oh_tally_log2(&h->bs_hist[idx], + ktime_to_ms(time)); for (; total < blen && c < map.m_len; c++, total++) { if (rc == 0) { -- 1.8.3.1