From patchwork Tue Feb 15 09:16:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 542806 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 8B877C433EF for ; Tue, 15 Feb 2022 09:17:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235754AbiBOJRT (ORCPT ); Tue, 15 Feb 2022 04:17:19 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:44974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235753AbiBOJRT (ORCPT ); Tue, 15 Feb 2022 04:17:19 -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 0881AAE6F for ; Tue, 15 Feb 2022 01:17:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644916629; 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=Eiu+Fs9WTha6ja/10Sm+YNnaJJVJZmbeDmhwpLOfjS8=; b=aOuFsUtL1447G8AgfZJfSSv7F0Z6w0kgjBSVuZkDBig2UbCJc7kQGwgrhXRwPcrSREOhLd YJd4aDa02yDnjTOuOIzGXTC4lGl+RRzy2QNDVB+mnczgGV27tF4f0Fu04TNaujqpSZFr/L UKneUVaqSNr41VIhgQHvXO35gELlaBw= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-fk6E_0HUMCmqcSJNx5zUuQ-1; Tue, 15 Feb 2022 04:17:08 -0500 X-MC-Unique: fk6E_0HUMCmqcSJNx5zUuQ-1 Received: by mail-pj1-f71.google.com with SMTP id q40-20020a17090a17ab00b001bafa89b70aso636060pja.2 for ; Tue, 15 Feb 2022 01:17:07 -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=Eiu+Fs9WTha6ja/10Sm+YNnaJJVJZmbeDmhwpLOfjS8=; b=R4wmpNHvPlv5GjbPN9e9sOtboo89spOzmZQcw1RpNt4pUyia1TAXHgycxfDsL9we8r l6wmfwUlWNI2Q9xexwu6MZCrhgxUVauOd6wGh7OlsRD3R41xZF54jVJ6CQC7O79Gqb27 zTz5qjfuCmct9MemdvPr2pkgBlJDZl57X1w4Yx0qGmRYdu/aQ3JSyE+Fc++aHxDSvVfi eR4NdUl81H+OSVIKy3Dqazwh8V9XUjDXEreab3zpTd4AzcMK/a0YBanwdH1DwOPN8aYU 6UqTMAcZyTkEd+LD9ovhDXw043YZauUlzCNL+R9VLT+ZNP5AASUYl47wyNS2Zx0kDB4A UfMA== X-Gm-Message-State: AOAM530wZIDdgubquVhZPLOWTDPo3DcZcOVVKHGmIB3Im2Fso1zJNwOi iOIqZlqd39Re8B+0A3UEXu8R+9VjeTo1LeSUddfGrVY43xSVqD2RR0aVCV3vavSsPssaCj0hAO6 OSu/jSyv3nanDWDqEBNh+Qg== X-Received: by 2002:a17:902:c40b:: with SMTP id k11mr3230575plk.58.1644916626653; Tue, 15 Feb 2022 01:17:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJzx29bGiHjkeGNXKvV+ch5hYkiSOUz7ifGwfDHdmyFhvbG/k/nAb0WuHowQlpAsB/GVADJTTA== X-Received: by 2002:a17:902:c40b:: with SMTP id k11mr3230554plk.58.1644916626401; Tue, 15 Feb 2022 01:17:06 -0800 (PST) Received: from h3ckers-pride.redhat.com ([124.123.80.180]) by smtp.gmail.com with ESMTPSA id kk14sm16569550pjb.26.2022.02.15.01.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 01:17:05 -0800 (PST) From: Venky Shankar To: jlayton@redhat.com, xiubli@redhat.com Cc: ceph-devel@vger.kernel.org, Venky Shankar Subject: [PATCH 1/3] ceph: track average r/w/m latency Date: Tue, 15 Feb 2022 14:46:55 +0530 Message-Id: <20220215091657.104079-2-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220215091657.104079-1-vshankar@redhat.com> References: <20220215091657.104079-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 a9cd23561a0d..73e98d45442a 100644 --- a/fs/ceph/metric.c +++ b/fs/ceph/metric.c @@ -250,6 +250,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; @@ -307,20 +308,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, @@ -339,6 +339,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 Feb 15 09:16:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 542805 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 483DDC433F5 for ; Tue, 15 Feb 2022 09:17:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235761AbiBOJR3 (ORCPT ); Tue, 15 Feb 2022 04:17:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235756AbiBOJR1 (ORCPT ); Tue, 15 Feb 2022 04:17:27 -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 2A625AE6F for ; Tue, 15 Feb 2022 01:17:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644916637; 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=l2r1jag2B8h4t60u9CLI6iIx/Tf0zjMI4sQzIQznIOc=; b=Psh51opM3HYZO84qGTUkCLYooewneQBIcWewPlxSxAqfXpZZYaG6BimCaKcJtLve50b5TD nuisbX9mzZYd3Qt8vj3UIQ98K6flOG8koIcnYFh1VmdhHT7c4FdO69UvhpMZLJHQlQcpCE 8SIDT6Z1afce9UcPlxbJd7O6rhIrOTo= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-640-OgJk7zinOyqvGvdxxyKaQQ-1; Tue, 15 Feb 2022 04:17:16 -0500 X-MC-Unique: OgJk7zinOyqvGvdxxyKaQQ-1 Received: by mail-pj1-f71.google.com with SMTP id 62-20020a17090a09c400b001b80b0742b0so12714017pjo.8 for ; Tue, 15 Feb 2022 01:17:15 -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=l2r1jag2B8h4t60u9CLI6iIx/Tf0zjMI4sQzIQznIOc=; b=OZnhrI+1B11lYKlLk5E7tTZqHUhsMHDDq2hSWRj1attlAg2prMM4ZDZ2X+Svqp1n3m YR20gU8RmdxLAV6K704gHZ59mkrtDhs+KmP/0aLE6/NJ6sYclMoQcdKJMkrM3GblKOX9 0GkacidxAdydciXc7KXlUsuRtIOWd3i9fUmbwjgmNOP0CT8/TIK0FWJSpGAUPi7taLwM h37rtEzBvLS1SEMtwwIRqCpDwnVFoFaAAFabApq+m5wUcP0BaGlgwzjVbdAWgQSq5xCY qXd6bT5weIJm9U/MiHLrmnPoeagTKibkfEwVulKwnGFzMEkO6Y8xEjMnrqNV3i5y0CIC ou5A== X-Gm-Message-State: AOAM533B5dzmDpVcNEDZ8uWBwbqsH5CNZERv9l7EjoV2XpvtssCLP/kq IHHLmEyFi0713SCsZx8fCMXGwRrruTRwPTEZ0x1C5n8Tc6QsMU3GKx99WS09HMqci9gqx7sw1g2 zuafUlR3m7Cy4PIAGsO//dg== X-Received: by 2002:a17:90b:4d86:b0:1b9:c571:53a0 with SMTP id oj6-20020a17090b4d8600b001b9c57153a0mr3344822pjb.242.1644916634757; Tue, 15 Feb 2022 01:17:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJsKDdglWW3zCEKG7G41eYJIjaFmWe3oVFO470/l9BWIiHaqUpmvOLyKYAQNtiAy6qu9MFjg== X-Received: by 2002:a17:90b:4d86:b0:1b9:c571:53a0 with SMTP id oj6-20020a17090b4d8600b001b9c57153a0mr3344810pjb.242.1644916634511; Tue, 15 Feb 2022 01:17:14 -0800 (PST) Received: from h3ckers-pride.redhat.com ([124.123.80.180]) by smtp.gmail.com with ESMTPSA id kk14sm16569550pjb.26.2022.02.15.01.17.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 01:17:13 -0800 (PST) From: Venky Shankar To: jlayton@redhat.com, xiubli@redhat.com Cc: ceph-devel@vger.kernel.org, Venky Shankar Subject: [PATCH 3/3] ceph: use tracked average r/w/m latencies to display metrics in debugfs Date: Tue, 15 Feb 2022 14:46:57 +0530 Message-Id: <20220215091657.104079-4-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220215091657.104079-1-vshankar@redhat.com> References: <20220215091657.104079-1-vshankar@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Signed-off-by: Venky Shankar --- fs/ceph/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index 3cf7c9c1085b..acc5cb3ad0ef 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c @@ -186,7 +186,7 @@ static int metrics_latency_show(struct seq_file *s, void *p) 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;