From patchwork Mon Sep 13 13:13:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 12489115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97210C433FE for ; Mon, 13 Sep 2021 13:13:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81B9460E9B for ; Mon, 13 Sep 2021 13:13:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238817AbhIMNOy (ORCPT ); Mon, 13 Sep 2021 09:14:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35349 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240466AbhIMNOl (ORCPT ); Mon, 13 Sep 2021 09:14:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631538805; 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=8T+3wLr4Q6eT/3BEGDvDJvh9VRXgD3Yl/eQxQ5rSuZo=; b=PUav+PH9p6+fERpufzj/MfQz+XZFCmdcmip/MuYID8BrKcMFVitWU9ik7chxeOqK20HZiz 4j2NTdfcomk8LQ80ZSGiTQSEkwQCiHECas5Csude9o7CVidvDstuLNnMIhpW8PYQrVB+jP BlnCNdJ1wbAle8sO33t5Tyzy5+8tKwU= Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-571--5c-srjBMjCYe41KZ_rPzQ-1; Mon, 13 Sep 2021 09:13:24 -0400 X-MC-Unique: -5c-srjBMjCYe41KZ_rPzQ-1 Received: by mail-pl1-f197.google.com with SMTP id f9-20020a1709028609b0290128bcba6be7so3200165plo.18 for ; Mon, 13 Sep 2021 06:13:24 -0700 (PDT) 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=8T+3wLr4Q6eT/3BEGDvDJvh9VRXgD3Yl/eQxQ5rSuZo=; b=bT/PxgJUPnBeFq1BxIhcu00aO8ijU8WH6AS71SjDX4o9CDMBesghDJIcq5G6otKpvq +7Ba7/0VZ0N1sxlzetjQYZjiEIwZEWs/GyS0up5Nil0iR10XNnnu9t0Cs4vZZuPFDzZh 0drvlrsl0D6Ac+qWZiZxlnV8nOZprEG3O9uzd6zFngJ+TO3u3qAOQ3qSZbbCCHMBQLOM a5umOhB28+zDgBUK6qAG7cLQf4w3Nxq/c15p3WiLIXfk6oTclM2q0SOXL825DlITQtv9 2WaDdhHj8fNeRVItQAKrFrDbLj7d6UzmRdbAfEA7BZHYmgFRC3a1HL6rbzOUxr1uX0mA 6wwg== X-Gm-Message-State: AOAM531uGqFkETqYXp7S9Uj7Yria82fqJ9rrVG7Xs9vigPmNUECDLXLn PRGfxPWN4UapInAMG3UcPaZcVbhRPs0WUVSdQxAcXh7q3VKzdWaJEQo+c+XL9XpvXHEBB48sgYS lvGhuKi7qMHYzKyFTpd3atg== X-Received: by 2002:a63:33cb:: with SMTP id z194mr11182443pgz.380.1631538803536; Mon, 13 Sep 2021 06:13:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVB9xLDbuf8mwD02dpnbpTGt3WWgoBQrqpcw3ZSYlGGyBn/dtVZ9cqC4s0/vp6klqWDEyohg== X-Received: by 2002:a63:33cb:: with SMTP id z194mr11182421pgz.380.1631538803300; Mon, 13 Sep 2021 06:13:23 -0700 (PDT) Received: from h3ckers-pride.redhat.com ([49.207.198.118]) by smtp.gmail.com with ESMTPSA id i10sm7362010pfk.151.2021.09.13.06.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 06:13:22 -0700 (PDT) From: Venky Shankar To: jlayton@redhat.com, pdonnell@redhat.com, xiubli@redhat.com Cc: ceph-devel@vger.kernel.org, Venky Shankar Subject: [PATCH v1 1/4] ceph: use "struct ceph_timespec" for r/w/m latencies Date: Mon, 13 Sep 2021 18:43:08 +0530 Message-Id: <20210913131311.1347903-2-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913131311.1347903-1-vshankar@redhat.com> References: <20210913131311.1347903-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/metric.c | 12 ++++++------ fs/ceph/metric.h | 17 +++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c index 5ec94bd4c1de..19bca20cf7e1 100644 --- a/fs/ceph/metric.c +++ b/fs/ceph/metric.c @@ -56,8 +56,8 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, read->data_len = cpu_to_le32(sizeof(*read) - 10); sum = m->read_latency_sum; jiffies_to_timespec64(sum, &ts); - read->sec = cpu_to_le32(ts.tv_sec); - read->nsec = cpu_to_le32(ts.tv_nsec); + read->lat.tv_sec = cpu_to_le32(ts.tv_sec); + read->lat.tv_nsec = cpu_to_le32(ts.tv_nsec); items++; /* encode the write latency metric */ @@ -68,8 +68,8 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, write->data_len = cpu_to_le32(sizeof(*write) - 10); sum = m->write_latency_sum; jiffies_to_timespec64(sum, &ts); - write->sec = cpu_to_le32(ts.tv_sec); - write->nsec = cpu_to_le32(ts.tv_nsec); + write->lat.tv_sec = cpu_to_le32(ts.tv_sec); + write->lat.tv_nsec = cpu_to_le32(ts.tv_nsec); items++; /* encode the metadata latency metric */ @@ -80,8 +80,8 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, meta->data_len = cpu_to_le32(sizeof(*meta) - 10); sum = m->metadata_latency_sum; jiffies_to_timespec64(sum, &ts); - meta->sec = cpu_to_le32(ts.tv_sec); - meta->nsec = cpu_to_le32(ts.tv_nsec); + meta->lat.tv_sec = cpu_to_le32(ts.tv_sec); + meta->lat.tv_nsec = cpu_to_le32(ts.tv_nsec); items++; /* encode the dentry lease metric */ diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h index af6038ff39d4..1151d64dbcbc 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 @@ -52,9 +52,8 @@ struct ceph_metric_read_latency { __u8 ver; __u8 compat; - __le32 data_len; /* length of sizeof(sec + nsec) */ - __le32 sec; - __le32 nsec; + __le32 data_len; /* length of sizeof(lat) */ + struct ceph_timespec lat; } __packed; /* metric write latency header */ @@ -64,9 +63,8 @@ struct ceph_metric_write_latency { __u8 ver; __u8 compat; - __le32 data_len; /* length of sizeof(sec + nsec) */ - __le32 sec; - __le32 nsec; + __le32 data_len; /* length of sizeof(lat) */ + struct ceph_timespec lat; } __packed; /* metric metadata latency header */ @@ -76,9 +74,8 @@ struct ceph_metric_metadata_latency { __u8 ver; __u8 compat; - __le32 data_len; /* length of sizeof(sec + nsec) */ - __le32 sec; - __le32 nsec; + __le32 data_len; /* length of sizeof(lat) */ + struct ceph_timespec lat; } __packed; /* metric dentry lease header */ From patchwork Mon Sep 13 13:13:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 12489117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B0D2C433EF for ; Mon, 13 Sep 2021 13:13:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7366860FA0 for ; Mon, 13 Sep 2021 13:13:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239005AbhIMNO4 (ORCPT ); Mon, 13 Sep 2021 09:14:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60618 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240536AbhIMNOq (ORCPT ); Mon, 13 Sep 2021 09:14:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631538810; 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=Cjed6zVninWiVUPwaQXiHwMycCtQNHfeegV2xHfcplQ=; b=PlFAvmWIgSYqOFiohfCvkbzWEZHuOJtiTQVsrx5LGQDNpYV+Jw1CAv5NR+o/f7hsGTlbJp xY9zyHKcgvMWf1JY9kZ492B2akYcn+bU6KsluUWNrUpwDBcH4gX/WoRKJNxtZaQQt34JJU 5eYI2svMT2hI+83I3hqPKYckDe1BJLc= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-K3gQIHYaNc6Mztc3inYH8A-1; Mon, 13 Sep 2021 09:13:29 -0400 X-MC-Unique: K3gQIHYaNc6Mztc3inYH8A-1 Received: by mail-pf1-f198.google.com with SMTP id h14-20020a62b40e0000b02903131bc4a1acso6238901pfn.4 for ; Mon, 13 Sep 2021 06:13:28 -0700 (PDT) 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=Cjed6zVninWiVUPwaQXiHwMycCtQNHfeegV2xHfcplQ=; b=l19Q77m7MJSba5RxTs92bvL7XaJbqF3kSemE1WUPb0wtgxaZ1+bU7e1Cw/p5HWroq7 2Q0uhmVMICT8zilTRox+nBcchW0+MLX5fhjHnjzTt5XhKUqigMr3QjIjldiothY5rS8I DzWNQ/7tL8jPQUVD6skcQmE3gg/nI1fSaKBApc0fbBLGa+2S1MtOwdmBI4K7R7msxYrz J666cHfiHXu3ejRzNs7earEw69hdeGrkmVFcn7ac9Dpbs7wZDjfa7QdQBgtkI2lyEfGp kYlVl3JHly5+zR7Tp+nhmcUpEf2Rh6DZulRIBcOHIVJ+CxQtbvZH6c9OWtnAe5gtj9S4 Qakg== X-Gm-Message-State: AOAM531N054a4fYqZpHxc/7qnW9lIQ4ulPnuggiMGHF9Hs1NKhK3SV+J +huxlpMP/zm4rWE/G6bzgJOP5qfzat5uBXQYVNgg/YZG2csSgfPHUJp2aSYqroNp1GyNKWnxFue 4aIwz77b4tO6z1FmOHl5kCg== X-Received: by 2002:a05:6a00:a94:b029:384:1dc6:7012 with SMTP id b20-20020a056a000a94b02903841dc67012mr10986393pfl.53.1631538807382; Mon, 13 Sep 2021 06:13:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuAVKrtJNHJqzo1tV9dxT7m1LWbxAXW1bXkk+O+fo+uUPkhiPo4evsH/AJwJtZqwoczIapJQ== X-Received: by 2002:a05:6a00:a94:b029:384:1dc6:7012 with SMTP id b20-20020a056a000a94b02903841dc67012mr10986375pfl.53.1631538807158; Mon, 13 Sep 2021 06:13:27 -0700 (PDT) Received: from h3ckers-pride.redhat.com ([49.207.198.118]) by smtp.gmail.com with ESMTPSA id i10sm7362010pfk.151.2021.09.13.06.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 06:13:26 -0700 (PDT) From: Venky Shankar To: jlayton@redhat.com, pdonnell@redhat.com, xiubli@redhat.com Cc: ceph-devel@vger.kernel.org, Venky Shankar Subject: [PATCH v1 2/4] ceph: track average/stdev r/w/m latency Date: Mon, 13 Sep 2021 18:43:09 +0530 Message-Id: <20210913131311.1347903-3-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913131311.1347903-1-vshankar@redhat.com> References: <20210913131311.1347903-1-vshankar@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org The math involved in tracking average and standard deviation for r/w/m latencies looks incorrect. Fix that up. Also, change the variable name that tracks standard deviation (*_sq_sum) to *_stdev. Signed-off-by: Venky Shankar --- fs/ceph/debugfs.c | 6 +++--- fs/ceph/metric.c | 45 ++++++++++++++++++++++++--------------------- fs/ceph/metric.h | 9 ++++++--- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index f9ff70704423..9153bc233e08 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c @@ -176,7 +176,7 @@ static int metric_show(struct seq_file *s, void *p) avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0; min = m->read_latency_min; max = m->read_latency_max; - sq = m->read_latency_sq_sum; + sq = m->read_latency_stdev; spin_unlock(&m->read_latency_lock); CEPH_METRIC_SHOW("read", total, avg, min, max, sq); @@ -186,7 +186,7 @@ static int metric_show(struct seq_file *s, void *p) avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0; min = m->write_latency_min; max = m->write_latency_max; - sq = m->write_latency_sq_sum; + sq = m->write_latency_stdev; spin_unlock(&m->write_latency_lock); CEPH_METRIC_SHOW("write", total, avg, min, max, sq); @@ -196,7 +196,7 @@ static int metric_show(struct seq_file *s, void *p) avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0; min = m->metadata_latency_min; max = m->metadata_latency_max; - sq = m->metadata_latency_sq_sum; + sq = m->metadata_latency_stdev; spin_unlock(&m->metadata_latency_lock); CEPH_METRIC_SHOW("metadata", total, avg, min, max, sq); diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c index 19bca20cf7e1..e00b1c2ce25b 100644 --- a/fs/ceph/metric.c +++ b/fs/ceph/metric.c @@ -184,21 +184,24 @@ int ceph_metric_init(struct ceph_client_metric *m) goto err_i_caps_mis; spin_lock_init(&m->read_latency_lock); - m->read_latency_sq_sum = 0; + m->read_latency_stdev = 0; + m->avg_read_latency = 0; m->read_latency_min = KTIME_MAX; m->read_latency_max = 0; m->total_reads = 0; m->read_latency_sum = 0; spin_lock_init(&m->write_latency_lock); - m->write_latency_sq_sum = 0; + m->write_latency_stdev = 0; + m->avg_write_latency = 0; m->write_latency_min = KTIME_MAX; m->write_latency_max = 0; m->total_writes = 0; m->write_latency_sum = 0; spin_lock_init(&m->metadata_latency_lock); - m->metadata_latency_sq_sum = 0; + m->metadata_latency_stdev = 0; + m->avg_metadata_latency = 0; m->metadata_latency_min = KTIME_MAX; m->metadata_latency_max = 0; m->total_metadatas = 0; @@ -250,10 +253,10 @@ void ceph_metric_destroy(struct ceph_client_metric *m) } static inline void __update_latency(ktime_t *totalp, ktime_t *lsump, - ktime_t *min, ktime_t *max, - ktime_t *sq_sump, ktime_t lat) + ktime_t *lavgp, ktime_t *min, ktime_t *max, + ktime_t *lstdev, ktime_t lat) { - ktime_t total, avg, sq, lsum; + ktime_t total, avg, stdev, lsum; total = ++(*totalp); lsum = (*lsump += lat); @@ -263,15 +266,15 @@ static inline void __update_latency(ktime_t *totalp, ktime_t *lsump, if (unlikely(lat > *max)) *max = lat; - 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; + if (unlikely(total == 1)) { + *lavgp = lat; + *lstdev = 0; + } else { + avg = *lavgp + div64_s64(lat - *lavgp, total); + stdev = *lstdev + (lat - *lavgp)*(lat - avg); + *lstdev = int_sqrt(div64_u64(stdev, total - 1)); + *lavgp = avg; + } } void ceph_update_read_latency(struct ceph_client_metric *m, @@ -285,8 +288,8 @@ void ceph_update_read_latency(struct ceph_client_metric *m, spin_lock(&m->read_latency_lock); __update_latency(&m->total_reads, &m->read_latency_sum, - &m->read_latency_min, &m->read_latency_max, - &m->read_latency_sq_sum, lat); + &m->avg_read_latency, &m->read_latency_min, + &m->read_latency_max, &m->read_latency_stdev, lat); spin_unlock(&m->read_latency_lock); } @@ -301,8 +304,8 @@ void ceph_update_write_latency(struct ceph_client_metric *m, spin_lock(&m->write_latency_lock); __update_latency(&m->total_writes, &m->write_latency_sum, - &m->write_latency_min, &m->write_latency_max, - &m->write_latency_sq_sum, lat); + &m->avg_write_latency, &m->write_latency_min, + &m->write_latency_max, &m->write_latency_stdev, lat); spin_unlock(&m->write_latency_lock); } @@ -317,7 +320,7 @@ void ceph_update_metadata_latency(struct ceph_client_metric *m, spin_lock(&m->metadata_latency_lock); __update_latency(&m->total_metadatas, &m->metadata_latency_sum, - &m->metadata_latency_min, &m->metadata_latency_max, - &m->metadata_latency_sq_sum, lat); + &m->avg_metadata_latency, &m->metadata_latency_min, + &m->metadata_latency_max, &m->metadata_latency_stdev, lat); spin_unlock(&m->metadata_latency_lock); } diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h index 1151d64dbcbc..136689fa0aec 100644 --- a/fs/ceph/metric.h +++ b/fs/ceph/metric.h @@ -108,21 +108,24 @@ struct ceph_client_metric { spinlock_t read_latency_lock; u64 total_reads; ktime_t read_latency_sum; - ktime_t read_latency_sq_sum; + ktime_t avg_read_latency; + ktime_t read_latency_stdev; ktime_t read_latency_min; ktime_t read_latency_max; spinlock_t write_latency_lock; u64 total_writes; ktime_t write_latency_sum; - ktime_t write_latency_sq_sum; + ktime_t avg_write_latency; + ktime_t write_latency_stdev; ktime_t write_latency_min; ktime_t write_latency_max; spinlock_t metadata_latency_lock; u64 total_metadatas; ktime_t metadata_latency_sum; - ktime_t metadata_latency_sq_sum; + ktime_t avg_metadata_latency; + ktime_t metadata_latency_stdev; ktime_t metadata_latency_min; ktime_t metadata_latency_max; From patchwork Mon Sep 13 13:13:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 12489119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACDB0C433EF for ; Mon, 13 Sep 2021 13:13:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93F7060E9B for ; Mon, 13 Sep 2021 13:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239080AbhIMNO5 (ORCPT ); Mon, 13 Sep 2021 09:14:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28896 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240575AbhIMNOt (ORCPT ); Mon, 13 Sep 2021 09:14:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631538813; 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=EQQxvFd6889UTgxl8qWsgkpLFA8tU2Z7/AK1LVBrCSE=; b=GyfdMlnFU1CSttSiopqnsDoUEiJxkIHQsbR888w/otnhW20XXSuDyFrNw0L5FMGxXrEunh eqOz4/GGJaAmAdYF096eoj5GONq3B5RXvEpP353nOjc19CIJr33R8xPwLETR5HEtfJpeab CxQCcftPbxf6F9KOAibqEvMkXDVL6Oc= Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-485-3RE7VB-QMdGub888qeXPBA-1; Mon, 13 Sep 2021 09:13:33 -0400 X-MC-Unique: 3RE7VB-QMdGub888qeXPBA-1 Received: by mail-pg1-f198.google.com with SMTP id b5-20020a6541c5000000b002661347cfbcso7383949pgq.1 for ; Mon, 13 Sep 2021 06:13:32 -0700 (PDT) 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=EQQxvFd6889UTgxl8qWsgkpLFA8tU2Z7/AK1LVBrCSE=; b=k5WWUYNTM9A+ONrM+K0KL6O9Gh4y+36X5WiTdQvK6NmfSMVXYpNqFgZeMLo9TgmtXP OBv19giNwky35K2AS0oZyEWDXLmXYU+S4bLYP292+2NbncjxCzh1sJUhSQa6NO1VK8ST 1KepZR+6zaGkRykZlw/cy4jsHhkREy0xvrXDO3Yt8FAE2nc3AwSHHY2bWLkBvasOpjO9 WycYtXiHFMT+RHQn2HbL2S8VfgyEAN6VTRHEW/RxTRSD5rwOpc+w0h3O1cCnDPzxE4Xz wr4OeNRNtGiDPhPXH2V/QmEL1yQRoiuD9KHvhJFfbmq7EjyAFdJ0AJ2c48m71wMp+8iy dx1A== X-Gm-Message-State: AOAM5331Ix3gIB8qRbWPzCqV49Fg0S7yNmy+hW44iZADS1MB8t4OPlbk t23OUrDsvp75C+82nlqn8hLUcUPWPJXcXGTx9oy3DbGhyLSD36igvvzL3I06mDz376GtFSsDV1B Fu/E83W0AzDFllQQXr9j9sA== X-Received: by 2002:a62:1683:0:b0:3f3:814f:4367 with SMTP id 125-20020a621683000000b003f3814f4367mr11120030pfw.68.1631538811628; Mon, 13 Sep 2021 06:13:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL3TyulkpqpqoTi8f6pFGDl+0KEyjvp0zid+YdzhzQ21fkhT/RRpEAIcpHzgbr5THpV0YB0g== X-Received: by 2002:a62:1683:0:b0:3f3:814f:4367 with SMTP id 125-20020a621683000000b003f3814f4367mr11120006pfw.68.1631538811345; Mon, 13 Sep 2021 06:13:31 -0700 (PDT) Received: from h3ckers-pride.redhat.com ([49.207.198.118]) by smtp.gmail.com with ESMTPSA id i10sm7362010pfk.151.2021.09.13.06.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 06:13:30 -0700 (PDT) From: Venky Shankar To: jlayton@redhat.com, pdonnell@redhat.com, xiubli@redhat.com Cc: ceph-devel@vger.kernel.org, Venky Shankar Subject: [PATCH v1 3/4] ceph: include average/stddev r/w/m latency in mds metrics Date: Mon, 13 Sep 2021 18:43:10 +0530 Message-Id: <20210913131311.1347903-4-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913131311.1347903-1-vshankar@redhat.com> References: <20210913131311.1347903-1-vshankar@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org The use of `jiffies_to_timespec64()` seems incorrect too, switch that to `ktime_to_timespec64()`. Signed-off-by: Venky Shankar --- fs/ceph/metric.c | 36 +++++++++++++++++++----------------- fs/ceph/metric.h | 44 +++++++++++++++++++++++++++++++------------- 2 files changed, 50 insertions(+), 30 deletions(-) diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c index e00b1c2ce25b..cb332ae2411f 100644 --- a/fs/ceph/metric.c +++ b/fs/ceph/metric.c @@ -8,6 +8,13 @@ #include "metric.h" #include "mds_client.h" +static void to_ceph_timespec(struct ceph_timespec *ts, ktime_t val) +{ + struct timespec64 t = ktime_to_timespec64(val); + ts->tv_sec = cpu_to_le32(t.tv_sec); + ts->tv_nsec = cpu_to_le32(t.tv_nsec); +} + static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, struct ceph_mds_session *s) { @@ -20,8 +27,6 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, struct ceph_client_metric *m = &mdsc->metric; u64 nr_caps = atomic64_read(&m->total_caps); struct ceph_msg *msg; - struct timespec64 ts; - s64 sum; s32 items = 0; s32 len; @@ -51,37 +56,34 @@ 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->type = cpu_to_le32(CLIENT_METRIC_TYPE_READ_LATENCY); - read->ver = 1; + read->ver = 2; read->compat = 1; read->data_len = cpu_to_le32(sizeof(*read) - 10); - sum = m->read_latency_sum; - jiffies_to_timespec64(sum, &ts); - read->lat.tv_sec = cpu_to_le32(ts.tv_sec); - read->lat.tv_nsec = cpu_to_le32(ts.tv_nsec); + to_ceph_timespec(&read->lat, m->read_latency_sum); + to_ceph_timespec(&read->avg, m->avg_read_latency); + to_ceph_timespec(&read->stdev, m->read_latency_stdev); items++; /* encode the write latency metric */ write = (struct ceph_metric_write_latency *)(read + 1); write->type = cpu_to_le32(CLIENT_METRIC_TYPE_WRITE_LATENCY); - write->ver = 1; + write->ver = 2; write->compat = 1; write->data_len = cpu_to_le32(sizeof(*write) - 10); - sum = m->write_latency_sum; - jiffies_to_timespec64(sum, &ts); - write->lat.tv_sec = cpu_to_le32(ts.tv_sec); - write->lat.tv_nsec = cpu_to_le32(ts.tv_nsec); + to_ceph_timespec(&write->lat, m->write_latency_sum); + to_ceph_timespec(&write->avg, m->avg_write_latency); + to_ceph_timespec(&write->stdev, m->write_latency_stdev); items++; /* encode the metadata latency metric */ meta = (struct ceph_metric_metadata_latency *)(write + 1); meta->type = cpu_to_le32(CLIENT_METRIC_TYPE_METADATA_LATENCY); - meta->ver = 1; + meta->ver = 2; meta->compat = 1; meta->data_len = cpu_to_le32(sizeof(*meta) - 10); - sum = m->metadata_latency_sum; - jiffies_to_timespec64(sum, &ts); - meta->lat.tv_sec = cpu_to_le32(ts.tv_sec); - meta->lat.tv_nsec = cpu_to_le32(ts.tv_nsec); + to_ceph_timespec(&meta->lat, m->metadata_latency_sum); + to_ceph_timespec(&meta->avg, m->avg_metadata_latency); + to_ceph_timespec(&meta->stdev, m->metadata_latency_stdev); items++; /* encode the dentry lease metric */ diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h index 136689fa0aec..b68927378e59 100644 --- a/fs/ceph/metric.h +++ b/fs/ceph/metric.h @@ -14,22 +14,34 @@ enum ceph_metric_type { CLIENT_METRIC_TYPE_WRITE_LATENCY, CLIENT_METRIC_TYPE_METADATA_LATENCY, CLIENT_METRIC_TYPE_DENTRY_LEASE, - - CLIENT_METRIC_TYPE_MAX = CLIENT_METRIC_TYPE_DENTRY_LEASE, + 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_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_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, \ } /* metric caps header */ @@ -52,8 +64,10 @@ struct ceph_metric_read_latency { __u8 ver; __u8 compat; - __le32 data_len; /* length of sizeof(lat) */ + __le32 data_len; /* length of sizeof(lat+avg+stdev) */ struct ceph_timespec lat; + struct ceph_timespec avg; + struct ceph_timespec stdev; } __packed; /* metric write latency header */ @@ -63,8 +77,10 @@ struct ceph_metric_write_latency { __u8 ver; __u8 compat; - __le32 data_len; /* length of sizeof(lat) */ + __le32 data_len; /* length of sizeof(lat_avg_stdev) */ struct ceph_timespec lat; + struct ceph_timespec avg; + struct ceph_timespec stdev; } __packed; /* metric metadata latency header */ @@ -74,8 +90,10 @@ struct ceph_metric_metadata_latency { __u8 ver; __u8 compat; - __le32 data_len; /* length of sizeof(lat) */ + __le32 data_len; /* length of sizeof(lat+avg+stdev) */ struct ceph_timespec lat; + struct ceph_timespec avg; + struct ceph_timespec stdev; } __packed; /* metric dentry lease header */ From patchwork Mon Sep 13 13:13:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 12489121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69992C433EF for ; Mon, 13 Sep 2021 13:13:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FF9760FA0 for ; Mon, 13 Sep 2021 13:13:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239986AbhIMNPD (ORCPT ); Mon, 13 Sep 2021 09:15:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46308 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230042AbhIMNOx (ORCPT ); Mon, 13 Sep 2021 09:14:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631538817; 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=/w2YwygMjuD8v3YdAaT+84vzymftMz0naG1pDb7N/Ik=; b=DmxDpjJ/ePm+NSsFbu/saNtqBxRxwfJt5FtK3aX3yrT/3lguiN0tefLChlqJWN+rOnlRq4 PKfQXJMrLGtLwq5srThaGETmO5p8wdx8oYUBH55JVoENCYV/0/Etx8JDeHGvBOpWn+zMug 2gC3iUnJfEMAg1g34ZGM4h5JNsWq+zk= Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-580-540BM-u4MfaFORVHsT3JaA-1; Mon, 13 Sep 2021 09:13:36 -0400 X-MC-Unique: 540BM-u4MfaFORVHsT3JaA-1 Received: by mail-pl1-f198.google.com with SMTP id c4-20020a170902848400b0013a24e27075so3207112plo.16 for ; Mon, 13 Sep 2021 06:13:36 -0700 (PDT) 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=/w2YwygMjuD8v3YdAaT+84vzymftMz0naG1pDb7N/Ik=; b=RY6fN29KLp65d1KM61lBOrVI+RYJJWgPtLDWPs2TEE2+uc88uso8oXUv4E8Jml2URq qAsTFgWwtTm6u3o5f09HJDogbWDVwvoxuXq1FthZBziqpOazkyaySjhdbuxntZ+nNqVn BiVw5yVna4khJ/CS2kN5rWHb5bwzGQfd+qLV92guhOXYD9OigrNR1y5ph7otttBCSUOp o3KJrPsUBTW7yr4I1rLAtrDHbqxuSlC9ThRyBy941Xb1PaU+5eXYI2f6C4qNU3X/DxDv MPe6CdWZiwix6HeYPZwWQS15YjEppdZ4BQS0M6U5owIfeSoY0fPe7m+bO2c7U8C1/h9R jNJQ== X-Gm-Message-State: AOAM531bZuAvGozz+4b3Ht+1zIfbWjTZnLDARG5Z8o9rTgyWnLtIWh3G lZGhRNrwUG+2R82kyvPGC/8JDhVXyFKiEg0A+yMFe8kQEXXzLQ9sqg4RndxPLer/BE5BRMvftmm oGNbe66jW2z7Uu/WSO27b1Q== X-Received: by 2002:a62:82c6:0:b0:410:afa1:6028 with SMTP id w189-20020a6282c6000000b00410afa16028mr11399238pfd.35.1631538815033; Mon, 13 Sep 2021 06:13:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDTFyJsJTLTl/eBDbRMZrFxtxIWt7vM3/3IbrHSPfDh1+TedB7lNfaXP7jQVINrmYJ4NHWIA== X-Received: by 2002:a62:82c6:0:b0:410:afa1:6028 with SMTP id w189-20020a6282c6000000b00410afa16028mr11399223pfd.35.1631538814834; Mon, 13 Sep 2021 06:13:34 -0700 (PDT) Received: from h3ckers-pride.redhat.com ([49.207.198.118]) by smtp.gmail.com with ESMTPSA id i10sm7362010pfk.151.2021.09.13.06.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 06:13:34 -0700 (PDT) From: Venky Shankar To: jlayton@redhat.com, pdonnell@redhat.com, xiubli@redhat.com Cc: ceph-devel@vger.kernel.org, Venky Shankar Subject: [PATCH v1 4/4] ceph: use tracked average r/w/m latencies to display metrics in debugfs Date: Mon, 13 Sep 2021 18:43:11 +0530 Message-Id: <20210913131311.1347903-5-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210913131311.1347903-1-vshankar@redhat.com> References: <20210913131311.1347903-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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index 9153bc233e08..e3fccf7c6fb5 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c @@ -173,7 +173,7 @@ static int metric_show(struct seq_file *s, void *p) spin_lock(&m->read_latency_lock); total = m->total_reads; sum = m->read_latency_sum; - avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0; + avg = m->avg_read_latency; min = m->read_latency_min; max = m->read_latency_max; sq = m->read_latency_stdev; @@ -183,7 +183,7 @@ static int metric_show(struct seq_file *s, void *p) spin_lock(&m->write_latency_lock); total = m->total_writes; sum = m->write_latency_sum; - avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0; + avg = m->avg_write_latency; min = m->write_latency_min; max = m->write_latency_max; sq = m->write_latency_stdev; @@ -193,7 +193,7 @@ static int metric_show(struct seq_file *s, void *p) spin_lock(&m->metadata_latency_lock); total = m->total_metadatas; sum = m->metadata_latency_sum; - avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0; + avg = m->avg_metadata_latency; min = m->metadata_latency_min; max = m->metadata_latency_max; sq = m->metadata_latency_stdev;