From patchwork Tue Mar 8 12:42:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 12773731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CC0AC433EF for ; Tue, 8 Mar 2022 12:42:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235685AbiCHMnd (ORCPT ); Tue, 8 Mar 2022 07:43:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234873AbiCHMnb (ORCPT ); Tue, 8 Mar 2022 07:43:31 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8036610FEF for ; Tue, 8 Mar 2022 04:42:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646743353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IOQlc/yPzXYf7B6+it55mF2WuN4GBRT97ljjsOSVJj4=; b=HQI84KgmcgT7pDHW9GMX0fkpM4Qb1/dJsZkVOpqwwjOGc2NkipA6MoNm/DbiNfZgUxSMhb zB69xk9ImEMxYhlrcx7j6I0B68XQ+STfwgKTTamOlL/UzM5wZTCdizDFofwjU6kcAKvX9d LGhcxjEmzSNBLa79i5hNZ2aDjBdtYyA= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-246-I4OBplF1MKaRkpksYQYjYg-1; Tue, 08 Mar 2022 07:42:32 -0500 X-MC-Unique: I4OBplF1MKaRkpksYQYjYg-1 Received: by mail-pj1-f70.google.com with SMTP id t12-20020a17090a448c00b001b9cbac9c43so1434778pjg.2 for ; Tue, 08 Mar 2022 04:42:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IOQlc/yPzXYf7B6+it55mF2WuN4GBRT97ljjsOSVJj4=; b=ph/kHD6RrI2zTVI5w7PeDLJX5DyTQCo2kGOxmj/dnrbo7FKK+T+XjCCgiCI3l15Cpb sVL7Dy4YKTBdzqEmvFXpCH70GjbvP6NegNFzxCALR6hO4WDiKuyZO1iCwPvEmYiYGaPv BE1/qSHoFqkBD/bve3uDr5rDx0hWXn+DdnV+kQd8/lyZyg2mITI0EU1DAqnTWCqDmSEc Sj/c/TjZVJnCXHhAN3CAmkHxfvi/bjRPuVaGw/W8YOkFZ5Jg8D/XZPZsq4qL/jE++Bjq c+KV/fVAartjqD1jGFQff6Y8oxAaYycTaqb1ONdztMT2VI+adDYxyDhBaicg5ZugDjKg XUOw== X-Gm-Message-State: AOAM533aKxBX0GgIUnwDaBypwAPx7AaT6hbyjn4XpWjhVZZVOW2zEesd feUKgCz6kbz1Td2J53SfW2oIKVRoMaOyOvyAgPVWAMGl5kNH3qSHTOItfhuJqqGd0uY2iSUOEv1 TI5/POy8xDbQ/LVj/hg35mg== X-Received: by 2002:a05:6a00:1705:b0:4f6:e1e4:447e with SMTP id h5-20020a056a00170500b004f6e1e4447emr15367808pfc.16.1646743350987; Tue, 08 Mar 2022 04:42:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJznr2mO3RwSKcIWYvuJy4Hpzo2o5MW3cZR5y06XcaqXiGrd6z4rIJIAy7jplT9DOuNxnbWMnQ== X-Received: by 2002:a05:6a00:1705:b0:4f6:e1e4:447e with SMTP id h5-20020a056a00170500b004f6e1e4447emr15367782pfc.16.1646743350692; Tue, 08 Mar 2022 04:42:30 -0800 (PST) Received: from localhost.localdomain ([124.123.80.180]) by smtp.gmail.com with ESMTPSA id o185-20020a6341c2000000b0036fb987b25fsm15344959pga.38.2022.03.08.04.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 04:42:29 -0800 (PST) From: Venky Shankar To: jlayton@redhat.com, idryomov@gmail.com Cc: xiubli@redhat.com, ceph-devel@vger.kernel.org, Venky Shankar Subject: [PATCH v2 1/4] ceph: use ktime_to_timespec64() rather than jiffies_to_timespec64() Date: Tue, 8 Mar 2022 07:42:16 -0500 Message-Id: <20220308124219.771527-2-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220308124219.771527-1-vshankar@redhat.com> References: <20220308124219.771527-1-vshankar@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Latencies are of type ktime_t, coverting from jiffies is incorrect. Also, switch to "struct ceph_timespec" for r/w/m latencies. Signed-off-by: Venky Shankar --- fs/ceph/metric.c | 19 +++++++++---------- fs/ceph/metric.h | 11 ++++------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c index 0fcba68f9a99..454d2c93208e 100644 --- a/fs/ceph/metric.c +++ b/fs/ceph/metric.c @@ -8,6 +8,12 @@ #include "metric.h" #include "mds_client.h" +static void ktime_to_ceph_timespec(struct ceph_timespec *ts, ktime_t val) +{ + struct timespec64 t = ktime_to_timespec64(val); + ceph_encode_timespec64(ts, &t); +} + static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, struct ceph_mds_session *s) { @@ -26,7 +32,6 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, u64 nr_caps = atomic64_read(&m->total_caps); u32 header_len = sizeof(struct ceph_metric_header); struct ceph_msg *msg; - struct timespec64 ts; s64 sum; s32 items = 0; s32 len; @@ -63,9 +68,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, read->header.compat = 1; read->header.data_len = cpu_to_le32(sizeof(*read) - header_len); sum = m->metric[METRIC_READ].latency_sum; - jiffies_to_timespec64(sum, &ts); - read->sec = cpu_to_le32(ts.tv_sec); - read->nsec = cpu_to_le32(ts.tv_nsec); + ktime_to_ceph_timespec(&read->lat, sum); items++; /* encode the write latency metric */ @@ -75,9 +78,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, write->header.compat = 1; write->header.data_len = cpu_to_le32(sizeof(*write) - header_len); sum = m->metric[METRIC_WRITE].latency_sum; - jiffies_to_timespec64(sum, &ts); - write->sec = cpu_to_le32(ts.tv_sec); - write->nsec = cpu_to_le32(ts.tv_nsec); + ktime_to_ceph_timespec(&write->lat, sum); items++; /* encode the metadata latency metric */ @@ -87,9 +88,7 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, meta->header.compat = 1; meta->header.data_len = cpu_to_le32(sizeof(*meta) - header_len); sum = m->metric[METRIC_METADATA].latency_sum; - jiffies_to_timespec64(sum, &ts); - meta->sec = cpu_to_le32(ts.tv_sec); - meta->nsec = cpu_to_le32(ts.tv_nsec); + ktime_to_ceph_timespec(&meta->lat, sum); items++; /* encode the dentry lease metric */ diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h index bb45608181e7..5b2bb2897056 100644 --- a/fs/ceph/metric.h +++ b/fs/ceph/metric.h @@ -2,7 +2,7 @@ #ifndef _FS_CEPH_MDS_METRIC_H #define _FS_CEPH_MDS_METRIC_H -#include +#include #include #include @@ -60,22 +60,19 @@ struct ceph_metric_cap { /* metric read latency header */ struct ceph_metric_read_latency { struct ceph_metric_header header; - __le32 sec; - __le32 nsec; + struct ceph_timespec lat; } __packed; /* metric write latency header */ struct ceph_metric_write_latency { struct ceph_metric_header header; - __le32 sec; - __le32 nsec; + struct ceph_timespec lat; } __packed; /* metric metadata latency header */ struct ceph_metric_metadata_latency { struct ceph_metric_header header; - __le32 sec; - __le32 nsec; + struct ceph_timespec lat; } __packed; /* metric dentry lease header */ From patchwork Tue Mar 8 12:42:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 12773732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28503C433F5 for ; Tue, 8 Mar 2022 12:42:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240651AbiCHMnm (ORCPT ); Tue, 8 Mar 2022 07:43:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238005AbiCHMnl (ORCPT ); Tue, 8 Mar 2022 07:43:41 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8E3171EC43 for ; Tue, 8 Mar 2022 04:42:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646743360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JmRgxHI8dk3jXbaAznquSLBTy6hZLdGcKiB3fZRikQo=; b=A/xbeFZzcyuy2bk9nP8t3wPOJrDlJD5CEBwRms8JVqRCxjHdfMHQjjO4inrZXezLXvk1oO mZkAjg6/EG3KbvMGbmarbGnxCmtYCm0WtF5YgZZb502cBvsYfKqS1DPd1zLqmaQqgf8A7o kS4DcDQCmallQ/AOwTvHW8dJroCN3v4= Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-176-1rUmHKscOlitLtaJWW_wqg-1; Tue, 08 Mar 2022 07:42:39 -0500 X-MC-Unique: 1rUmHKscOlitLtaJWW_wqg-1 Received: by mail-pg1-f198.google.com with SMTP id v4-20020a63f844000000b003745fd0919aso10251758pgj.20 for ; Tue, 08 Mar 2022 04:42:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JmRgxHI8dk3jXbaAznquSLBTy6hZLdGcKiB3fZRikQo=; b=4aq3AEpGP1x/dtTbwUKfoihqQcZw1Hr1kp2S32046+9yPljQwY6Pe668xobZWgvQJC yp2YYzE+YzPl/EMvO4C3kBVr/Wic4ncvlI8B2CWl5KQ9nok/gw6MqCI6zJQeh5Xn38oR nC+41JPGHOIxdfJ6GmLJy8+INcn4f6la1zp2Z9qW2AGuLNgpVp3RQ9au5xF/wa9afnZ+ YyfuhJb3ULySpuTgeh8kGCG+t47zaer92ToM2HpatAVw1CCPQVb9Wpb6v+5mgzCX9lGV EqRqZhPwUaBYEs6BxyY+OqtvA6OUyMtKOyxJ5c2XCojtr3gu54bA8x+ovISgAiOkE5Ty PMMg== X-Gm-Message-State: AOAM531HfBAkdecxV5gm1Nbvbjz33eB3NKBWYUWSbtSYW9O/P0TmeTts 7ed/bcPNio+qwpyBVcvPr0Bv9KdY/WOEN6+epabvtAW0MF0d2HiXwTsknS2gEBBpbjrMZMhl3te TrjRdTcpF3Q7y2nPXvUftJQ== X-Received: by 2002:a17:90a:a892:b0:1be:f420:bd1e with SMTP id h18-20020a17090aa89200b001bef420bd1emr4476246pjq.58.1646743358010; Tue, 08 Mar 2022 04:42:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJx67qn1voSPjVrWvwqo42VJoJIA1qvUnTEagZdrEEfNzr4hMawrZbgijxs7loKLypAlz9FbCg== X-Received: by 2002:a17:90a:a892:b0:1be:f420:bd1e with SMTP id h18-20020a17090aa89200b001bef420bd1emr4476223pjq.58.1646743357707; Tue, 08 Mar 2022 04:42:37 -0800 (PST) Received: from localhost.localdomain ([124.123.80.180]) by smtp.gmail.com with ESMTPSA id o185-20020a6341c2000000b0036fb987b25fsm15344959pga.38.2022.03.08.04.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 04:42:37 -0800 (PST) From: Venky Shankar To: jlayton@redhat.com, idryomov@gmail.com Cc: xiubli@redhat.com, ceph-devel@vger.kernel.org, Venky Shankar Subject: [PATCH v2 2/4] ceph: track average r/w/m latency Date: Tue, 8 Mar 2022 07:42:17 -0500 Message-Id: <20220308124219.771527-3-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220308124219.771527-1-vshankar@redhat.com> References: <20220308124219.771527-1-vshankar@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Make the math a bit simpler to understand (should not effect execution speeds). Signed-off-by: Venky Shankar --- fs/ceph/metric.c | 29 +++++++++++++++-------------- fs/ceph/metric.h | 1 + 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c index 454d2c93208e..14b6af48b611 100644 --- a/fs/ceph/metric.c +++ b/fs/ceph/metric.c @@ -249,6 +249,7 @@ int ceph_metric_init(struct ceph_client_metric *m) metric->size_max = 0; metric->total = 0; metric->latency_sum = 0; + metric->latency_avg = 0; metric->latency_sq_sum = 0; metric->latency_min = KTIME_MAX; metric->latency_max = 0; @@ -306,20 +307,19 @@ void ceph_metric_destroy(struct ceph_client_metric *m) max = new; \ } -static inline void __update_stdev(ktime_t total, ktime_t lsum, - ktime_t *sq_sump, ktime_t lat) +static inline void __update_mean_and_stdev(ktime_t total, ktime_t *lavg, + ktime_t *sq_sump, ktime_t lat) { - ktime_t avg, sq; - - if (unlikely(total == 1)) - return; - - /* the sq is (lat - old_avg) * (lat - new_avg) */ - avg = DIV64_U64_ROUND_CLOSEST((lsum - lat), (total - 1)); - sq = lat - avg; - avg = DIV64_U64_ROUND_CLOSEST(lsum, total); - sq = sq * (lat - avg); - *sq_sump += sq; + ktime_t avg; + + if (unlikely(total == 1)) { + *lavg = lat; + } else { + /* the sq is (lat - old_avg) * (lat - new_avg) */ + avg = *lavg + div64_s64(lat - *lavg, total); + *sq_sump += (lat - *lavg)*(lat - avg); + *lavg = avg; + } } void ceph_update_metrics(struct ceph_metric *m, @@ -338,6 +338,7 @@ void ceph_update_metrics(struct ceph_metric *m, METRIC_UPDATE_MIN_MAX(m->size_min, m->size_max, size); m->latency_sum += lat; METRIC_UPDATE_MIN_MAX(m->latency_min, m->latency_max, lat); - __update_stdev(total, m->latency_sum, &m->latency_sq_sum, lat); + __update_mean_and_stdev(total, &m->latency_avg, &m->latency_sq_sum, + lat); spin_unlock(&m->lock); } diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h index 5b2bb2897056..c47ba0074e49 100644 --- a/fs/ceph/metric.h +++ b/fs/ceph/metric.h @@ -137,6 +137,7 @@ struct ceph_metric { u64 size_min; u64 size_max; ktime_t latency_sum; + ktime_t latency_avg; ktime_t latency_sq_sum; ktime_t latency_min; ktime_t latency_max; From patchwork Tue Mar 8 12:42:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 12773733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E73AC433EF for ; Tue, 8 Mar 2022 12:42:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239109AbiCHMnn (ORCPT ); Tue, 8 Mar 2022 07:43:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240492AbiCHMnl (ORCPT ); Tue, 8 Mar 2022 07:43:41 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 908AA1FA7C for ; Tue, 8 Mar 2022 04:42:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646743363; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r5zWP/uPpqwhYHaqMbF3TyI7Imw51wJg0i6kZ1qbLOA=; b=XpbMlqZs7kVbrxQORyG02ETSjak/qc7XpAQ2U7NUzRoqCaniouZd7rF26/wgRIi1htUBaT DdYgF6v5UJcQjhNUI4pProLFDFRZxZWnx65bwP0GcmsPn7bYLGMiJXzqmcDV4DV/QzOwLo N8jf2vHjPtd+yv6vcp/22LZd8tmIBms= Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-312-u9wOAiesOmqRbY9xBSqhrA-1; Tue, 08 Mar 2022 07:42:41 -0500 X-MC-Unique: u9wOAiesOmqRbY9xBSqhrA-1 Received: by mail-pl1-f198.google.com with SMTP id q8-20020a170902f78800b00151cc484688so2187798pln.20 for ; Tue, 08 Mar 2022 04:42:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r5zWP/uPpqwhYHaqMbF3TyI7Imw51wJg0i6kZ1qbLOA=; b=FroNfcHRwI8zi3/F7oDbqIKCHWdbWLy2DD3DiYJ7vhiAfUC/fqnBegP3vEfpEMS1t/ 2c6ZGztJJIbVnm4O74/pV3Oqql3O3jsp0IDDtGtL4LMOUf4ZNNEEiKk9T8o8T5p4jdkC ZzKfzZ/V3TN6CusQ3WVF2ntqo77WV/9QohY8BdBd0uywaRt+Vckwdn83odBBrW42IYcw 8a+3SBU4pZ5xhLAEYciO0D1kyszhCGZrFWFETH0FNWbloH7d2dCGy6MOzHcpoVbm6FD/ HMYeKvtHWVbQeT7AFkGhVzLDw3fDAMRbowHoABZCViAfaXvXMAKCOh8FyJDeV2yCQwWq KIpQ== X-Gm-Message-State: AOAM532iNu55wXde9RHoOCbJdjUFZZ9s+mTPICxaH6+u7EnYlwBoOCuf rSVHMrXsZXSufVr+kMAGv+Ej5fgJ+r6gNmVTBxkYlG6RKb/Colnms/0V9aINnXXGn5jDB69+08f stfQjR/1Wf9rE4tNHL9ENlg== X-Received: by 2002:a63:e817:0:b0:373:8abb:2c51 with SMTP id s23-20020a63e817000000b003738abb2c51mr13999325pgh.185.1646743360817; Tue, 08 Mar 2022 04:42:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTrLZXoGzmOApsAfWrntD+niQNM5ynrN2IhGCqKrh/NPkxBMy7kPyx+PXL0Xr17eP5KN5oyA== X-Received: by 2002:a63:e817:0:b0:373:8abb:2c51 with SMTP id s23-20020a63e817000000b003738abb2c51mr13999313pgh.185.1646743360577; Tue, 08 Mar 2022 04:42:40 -0800 (PST) Received: from localhost.localdomain ([124.123.80.180]) by smtp.gmail.com with ESMTPSA id o185-20020a6341c2000000b0036fb987b25fsm15344959pga.38.2022.03.08.04.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 04:42:39 -0800 (PST) From: Venky Shankar To: jlayton@redhat.com, idryomov@gmail.com Cc: xiubli@redhat.com, ceph-devel@vger.kernel.org, Venky Shankar Subject: [PATCH v2 3/4] ceph: include average/stdev r/w/m latency in mds metrics Date: Tue, 8 Mar 2022 07:42:18 -0500 Message-Id: <20220308124219.771527-4-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220308124219.771527-1-vshankar@redhat.com> References: <20220308124219.771527-1-vshankar@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org stdev is computed in `cephfs-top` tool - clients forward square of sums and IO count required to calculate stdev. Signed-off-by: Venky Shankar --- fs/ceph/metric.c | 15 +++++++++++--- fs/ceph/metric.h | 51 ++++++++++++++++++++++++++++++++++-------------- 2 files changed, 48 insertions(+), 18 deletions(-) diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c index 14b6af48b611..c47347d2e84e 100644 --- a/fs/ceph/metric.c +++ b/fs/ceph/metric.c @@ -64,31 +64,40 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, /* encode the read latency metric */ read = (struct ceph_metric_read_latency *)(cap + 1); read->header.type = cpu_to_le32(CLIENT_METRIC_TYPE_READ_LATENCY); - read->header.ver = 1; + read->header.ver = 2; read->header.compat = 1; read->header.data_len = cpu_to_le32(sizeof(*read) - header_len); sum = m->metric[METRIC_READ].latency_sum; ktime_to_ceph_timespec(&read->lat, sum); + ktime_to_ceph_timespec(&read->avg, m->metric[METRIC_READ].latency_avg); + read->sq_sum = cpu_to_le64(m->metric[METRIC_READ].latency_sq_sum); + read->count = cpu_to_le64(m->metric[METRIC_READ].total); items++; /* encode the write latency metric */ write = (struct ceph_metric_write_latency *)(read + 1); write->header.type = cpu_to_le32(CLIENT_METRIC_TYPE_WRITE_LATENCY); - write->header.ver = 1; + write->header.ver = 2; write->header.compat = 1; write->header.data_len = cpu_to_le32(sizeof(*write) - header_len); sum = m->metric[METRIC_WRITE].latency_sum; ktime_to_ceph_timespec(&write->lat, sum); + ktime_to_ceph_timespec(&write->avg, m->metric[METRIC_WRITE].latency_avg); + write->sq_sum = cpu_to_le64(m->metric[METRIC_WRITE].latency_sq_sum); + write->count = cpu_to_le64(m->metric[METRIC_WRITE].total); items++; /* encode the metadata latency metric */ meta = (struct ceph_metric_metadata_latency *)(write + 1); meta->header.type = cpu_to_le32(CLIENT_METRIC_TYPE_METADATA_LATENCY); - meta->header.ver = 1; + meta->header.ver = 2; meta->header.compat = 1; meta->header.data_len = cpu_to_le32(sizeof(*meta) - header_len); sum = m->metric[METRIC_METADATA].latency_sum; ktime_to_ceph_timespec(&meta->lat, sum); + ktime_to_ceph_timespec(&meta->avg, m->metric[METRIC_METADATA].latency_avg); + meta->sq_sum = cpu_to_le64(m->metric[METRIC_METADATA].latency_sq_sum); + meta->count = cpu_to_le64(m->metric[METRIC_METADATA].total); items++; /* encode the dentry lease metric */ diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h index c47ba0074e49..0d0c44bd3332 100644 --- a/fs/ceph/metric.h +++ b/fs/ceph/metric.h @@ -19,27 +19,39 @@ enum ceph_metric_type { CLIENT_METRIC_TYPE_OPENED_INODES, CLIENT_METRIC_TYPE_READ_IO_SIZES, CLIENT_METRIC_TYPE_WRITE_IO_SIZES, - - CLIENT_METRIC_TYPE_MAX = CLIENT_METRIC_TYPE_WRITE_IO_SIZES, + CLIENT_METRIC_TYPE_AVG_READ_LATENCY, + CLIENT_METRIC_TYPE_STDEV_READ_LATENCY, + CLIENT_METRIC_TYPE_AVG_WRITE_LATENCY, + CLIENT_METRIC_TYPE_STDEV_WRITE_LATENCY, + CLIENT_METRIC_TYPE_AVG_METADATA_LATENCY, + CLIENT_METRIC_TYPE_STDEV_METADATA_LATENCY, + + CLIENT_METRIC_TYPE_MAX = CLIENT_METRIC_TYPE_STDEV_METADATA_LATENCY, }; /* * This will always have the highest metric bit value * as the last element of the array. */ -#define CEPHFS_METRIC_SPEC_CLIENT_SUPPORTED { \ - CLIENT_METRIC_TYPE_CAP_INFO, \ - CLIENT_METRIC_TYPE_READ_LATENCY, \ - CLIENT_METRIC_TYPE_WRITE_LATENCY, \ - CLIENT_METRIC_TYPE_METADATA_LATENCY, \ - CLIENT_METRIC_TYPE_DENTRY_LEASE, \ - CLIENT_METRIC_TYPE_OPENED_FILES, \ - CLIENT_METRIC_TYPE_PINNED_ICAPS, \ - CLIENT_METRIC_TYPE_OPENED_INODES, \ - CLIENT_METRIC_TYPE_READ_IO_SIZES, \ - CLIENT_METRIC_TYPE_WRITE_IO_SIZES, \ - \ - CLIENT_METRIC_TYPE_MAX, \ +#define CEPHFS_METRIC_SPEC_CLIENT_SUPPORTED { \ + CLIENT_METRIC_TYPE_CAP_INFO, \ + CLIENT_METRIC_TYPE_READ_LATENCY, \ + CLIENT_METRIC_TYPE_WRITE_LATENCY, \ + CLIENT_METRIC_TYPE_METADATA_LATENCY, \ + CLIENT_METRIC_TYPE_DENTRY_LEASE, \ + CLIENT_METRIC_TYPE_OPENED_FILES, \ + CLIENT_METRIC_TYPE_PINNED_ICAPS, \ + CLIENT_METRIC_TYPE_OPENED_INODES, \ + CLIENT_METRIC_TYPE_READ_IO_SIZES, \ + CLIENT_METRIC_TYPE_WRITE_IO_SIZES, \ + CLIENT_METRIC_TYPE_AVG_READ_LATENCY, \ + CLIENT_METRIC_TYPE_STDEV_READ_LATENCY, \ + CLIENT_METRIC_TYPE_AVG_WRITE_LATENCY, \ + CLIENT_METRIC_TYPE_STDEV_WRITE_LATENCY, \ + CLIENT_METRIC_TYPE_AVG_METADATA_LATENCY, \ + CLIENT_METRIC_TYPE_STDEV_METADATA_LATENCY, \ + \ + CLIENT_METRIC_TYPE_MAX, \ } struct ceph_metric_header { @@ -61,18 +73,27 @@ struct ceph_metric_cap { struct ceph_metric_read_latency { struct ceph_metric_header header; struct ceph_timespec lat; + struct ceph_timespec avg; + __le64 sq_sum; + __le64 count; } __packed; /* metric write latency header */ struct ceph_metric_write_latency { struct ceph_metric_header header; struct ceph_timespec lat; + struct ceph_timespec avg; + __le64 sq_sum; + __le64 count; } __packed; /* metric metadata latency header */ struct ceph_metric_metadata_latency { struct ceph_metric_header header; struct ceph_timespec lat; + struct ceph_timespec avg; + __le64 sq_sum; + __le64 count; } __packed; /* metric dentry lease header */ From patchwork Tue Mar 8 12:42:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 12773734 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C73F1C433EF for ; Tue, 8 Mar 2022 12:42:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241585AbiCHMnq (ORCPT ); Tue, 8 Mar 2022 07:43:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241126AbiCHMno (ORCPT ); Tue, 8 Mar 2022 07:43:44 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 32DC11E3EE for ; Tue, 8 Mar 2022 04:42:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646743366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WotjeOfBoLZmaV1cNxMIZ0cNLzdyzUIuJOrPCewLsIw=; b=NuoyWWcvJ1AQQnfzAXGwWWS/QFEesAy2v73XSheiKrZoEetKqS7wNj+MM4HL/frSgmNz89 FbqmOu4y5Kml0EJD0cjdfigv0Iv5sTy/QhHe/5+ivoJILFu4wLDd0fir//8OBPlSfJ/yZy jDIfkr5VMnuZlbhX+GwcPVHDo9gOUQA= Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-319-3LACKSI9OMOn9IhMMdxgSg-1; Tue, 08 Mar 2022 07:42:44 -0500 X-MC-Unique: 3LACKSI9OMOn9IhMMdxgSg-1 Received: by mail-pl1-f199.google.com with SMTP id e7-20020a170902ef4700b00151de30039bso3563916plx.17 for ; Tue, 08 Mar 2022 04:42:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WotjeOfBoLZmaV1cNxMIZ0cNLzdyzUIuJOrPCewLsIw=; b=06X2XJOyXuSJYqWzeu4cfZ3jmPHoLR+C+2bEPFKnK9zi2lkIdQNydrplt6E6COV8SC KdhJ9n1HSLQ/BFWsiI9iU0UphsJSOZpisMbqCvJn5xRu9hd4vKd6MBzPLCNXfUfYC9mG ZipTE7RPFyVHuXaK1kmfyq7VTkRKZTR3VIFOHW27DEtrhboQTo+U3HKhKFiseMvIj2kZ VND2CUD0T7Kufa9RXZv1JD7f+HwKIfncF97MYQtTcRv4DvBus3W7ZIIzSYmEi4aItG+M p0HhoUx/p92EJgB1NkYPkyfnDW58Vr3GWUrA966qavFb71yTkyRr0hhQtwnF9Q09OaGZ y0XQ== X-Gm-Message-State: AOAM533XAEbjfsd6lR2dWxvD9yMXD74yQg6zxIGW37rQx5QNXd0FuTy2 /IUh75z3KM9pUu4fsguQJnHawNQD49UtqLwab/IQ1Uu9J/LSd0VUpnluS9vY/emZreOeJKVcvqz JIP344s+iD6tl3j4g6CeXxA== X-Received: by 2002:a05:6a00:2166:b0:4f6:67fe:a336 with SMTP id r6-20020a056a00216600b004f667fea336mr18095908pff.17.1646743363379; Tue, 08 Mar 2022 04:42:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQLasYQ22pf7bcJBD2sIhD0nEWseu4HYIylhfXjoT83xjIAxbeHdkCnA1qYp6l8OH3HXwcgA== X-Received: by 2002:a05:6a00:2166:b0:4f6:67fe:a336 with SMTP id r6-20020a056a00216600b004f667fea336mr18095892pff.17.1646743363146; Tue, 08 Mar 2022 04:42:43 -0800 (PST) Received: from localhost.localdomain ([124.123.80.180]) by smtp.gmail.com with ESMTPSA id o185-20020a6341c2000000b0036fb987b25fsm15344959pga.38.2022.03.08.04.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 04:42:42 -0800 (PST) From: Venky Shankar To: jlayton@redhat.com, idryomov@gmail.com Cc: xiubli@redhat.com, ceph-devel@vger.kernel.org, Venky Shankar Subject: [PATCH v2 4/4] ceph: use tracked average r/w/m latencies to display metrics in debugfs Date: Tue, 8 Mar 2022 07:42:19 -0500 Message-Id: <20220308124219.771527-5-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220308124219.771527-1-vshankar@redhat.com> References: <20220308124219.771527-1-vshankar@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org [ jlayton: remove now-unused "sum" variable ] Signed-off-by: Venky Shankar --- fs/ceph/debugfs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index 3cf7c9c1085b..bec3c4549c07 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c @@ -175,7 +175,7 @@ static int metrics_latency_show(struct seq_file *s, void *p) struct ceph_fs_client *fsc = s->private; struct ceph_client_metric *cm = &fsc->mdsc->metric; struct ceph_metric *m; - s64 total, sum, avg, min, max, sq; + s64 total, avg, min, max, sq; int i; seq_printf(s, "item total avg_lat(us) min_lat(us) max_lat(us) stdev(us)\n"); @@ -185,8 +185,7 @@ static int metrics_latency_show(struct seq_file *s, void *p) m = &cm->metric[i]; spin_lock(&m->lock); total = m->total; - sum = m->latency_sum; - avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0; + avg = m->latency_avg; min = m->latency_min; max = m->latency_max; sq = m->latency_sq_sum;