From patchwork Tue Sep 21 13:07:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 12507805 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=-20.2 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 39D9DC433F5 for ; Tue, 21 Sep 2021 13:08:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EF4C61166 for ; Tue, 21 Sep 2021 13:08:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232920AbhIUNJi (ORCPT ); Tue, 21 Sep 2021 09:09:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52008 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232828AbhIUNJh (ORCPT ); Tue, 21 Sep 2021 09:09:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632229689; 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=94bxeY6gumFwJyEdsBeiulsS76oOAFB07V0I+tckFa8=; b=RTcn/5S7OGSUgfc2auqxIr3sTjVkcUi2n4kQNjOXFjSmT2qVF9tR0e43UMlLmTyUTQ/0/6 VVmrakv6sL76pd4F/nS5jNYFup0Yc33yF1R06XTfZkfUe4GocgfTMqm6MUXZjtDUABjrm1 s4gfyzKzIicCmm2xRbDdFdKUpZUKxQ0= Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-477-Cyt7gjyDNRqKvHN_cinwfg-1; Tue, 21 Sep 2021 09:08:08 -0400 X-MC-Unique: Cyt7gjyDNRqKvHN_cinwfg-1 Received: by mail-pg1-f200.google.com with SMTP id u7-20020a632347000000b0026722cd9defso18137078pgm.7 for ; Tue, 21 Sep 2021 06:08:07 -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=94bxeY6gumFwJyEdsBeiulsS76oOAFB07V0I+tckFa8=; b=dyXQlm14X9Yoq4DmX1gCdsuyxtjh280q6pnvolltd8WOVxg2luZFLtVn4TeT+h4wyh XKvIjIzP/ouE2k/8LntW+uZNhu+zobtC1WH2l18ZLT6TOU+Go/S2n0Q5vgXoqbX0ccg4 BLpkuBXYlpoWdd8F7HjAS5sjqOUFPmRXaWLQKvbuJfhqI6xT5Na8IOQmrvZLRSwdctn6 iqwykcAeXjPYt2Wg61+zvziwYHHIem0I2K3eVy6EeYJW/t49QGfcM9rg63IPWxa+qYqX fN21fk6LgNO0ziuT+1EyZhSr21F9O+S3YoD7FOCiUoVc9r4txzhI1tNc8xL5GCwJX0BB lksQ== X-Gm-Message-State: AOAM530B+qtO5SGNnalLg1OQrap2oZev+hQEEdJk50NIVaeTscHZBLgJ 8LAnmFz6Nrtaxl9GUooQsczit6eAIcdGWVtIlbqxQm+n3mSA5dmXeCrxmLN/jqTaHx2x39e36Tj BCcVC8kX8KbnyGPgW/f6hfQ== X-Received: by 2002:a17:90b:1809:: with SMTP id lw9mr2463113pjb.217.1632229682844; Tue, 21 Sep 2021 06:08:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQ0/ewjH1nBLv6y7j4Ip0I13CQ7R9Wh5Q2OqOwmowCgbXrUef23vm1ZdcySnGLjwoHcNbDmQ== X-Received: by 2002:a17:90b:1809:: with SMTP id lw9mr2462767pjb.217.1632229679152; Tue, 21 Sep 2021 06:07:59 -0700 (PDT) Received: from h3ckers-pride.redhat.com ([49.207.212.118]) by smtp.gmail.com with ESMTPSA id w5sm18473890pgp.79.2021.09.21.06.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 06:07:58 -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 v3 1/4] ceph: use "struct ceph_timespec" for r/w/m latencies Date: Tue, 21 Sep 2021 18:37:47 +0530 Message-Id: <20210921130750.31820-2-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210921130750.31820-1-vshankar@redhat.com> References: <20210921130750.31820-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 | 11 ++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c index 04d5df29bbbf..226dc38e2909 100644 --- a/fs/ceph/metric.c +++ b/fs/ceph/metric.c @@ -64,8 +64,8 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, read->header.data_len = cpu_to_le32(sizeof(*read) - header_len); 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 */ @@ -76,8 +76,8 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, write->header.data_len = cpu_to_le32(sizeof(*write) - header_len); 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 */ @@ -88,8 +88,8 @@ static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, meta->header.data_len = cpu_to_le32(sizeof(*meta) - header_len); 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 0133955a3c6a..103ed736f9d2 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 Sep 21 13:07:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 12507803 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=-17.4 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, UNWANTED_LANGUAGE_BODY,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 87BC2C433EF for ; Tue, 21 Sep 2021 13:08:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CF7561166 for ; Tue, 21 Sep 2021 13:08:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232905AbhIUNJh (ORCPT ); Tue, 21 Sep 2021 09:09:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22282 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232828AbhIUNJg (ORCPT ); Tue, 21 Sep 2021 09:09:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632229687; 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=/jpsnbT1BId0lAcyPCs8B7qUvWWy9dYCkSOGGJRA7rk=; b=XRdm2/9COA98isItMvoy5moGbPe+RLPaJ8eMnyKC0ZRKTmoL26jRpJK14hPHBDWW6FMdEj HnMeDtuZyWdQmEQvAPxcr0vPzIV3aNqfXNGHhS2207LGLkehjWjZCtfyDt/B+4ywLenpVB t1B+4ht1ndkee3LCm27Ew4oM8OfgiiU= Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-68-pEUy2_l0Of-jLYq3VBsiDQ-1; Tue, 21 Sep 2021 09:08:06 -0400 X-MC-Unique: pEUy2_l0Of-jLYq3VBsiDQ-1 Received: by mail-pl1-f200.google.com with SMTP id v7-20020a1709029a0700b0013daaeaa33eso3130900plp.5 for ; Tue, 21 Sep 2021 06:08:06 -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=/jpsnbT1BId0lAcyPCs8B7qUvWWy9dYCkSOGGJRA7rk=; b=CgxG4CDNGZLg24rgPzrZy2GL4KAPk5wTVlsiKMrLpLz6reu9/FRuQk2km36SE6I7fj kugp5qWFLh3l0/4gdxBPoZRxRjCrrkehNU3dMGky7ybNYtiXGUe9TkKxMxtHKeaouGVm IZDZaMwOCFIpwObywdaVbpC+jOmIGwfSwVoqGiXTG43ydhLs+SQXf5DzDgoGGj42yxn1 RowdzXi0aGgDtNHNkeui9u4iP380rnbVwzjJT5o3jcmiJuAnKUL/o2X2yoTt9vZJdnVy pGiGMWONkX07Y4f0FIRbpQzHjL0lCM9iFnq9Oyaf2a4jfvU3tCTJIupyW1YARS9TRyMp QbEg== X-Gm-Message-State: AOAM533mGT8/steL3JoihqIk9kXlL7GR5kO9M8EgVVK0LBiUGQI+bdOy ms90yBoLdv6yLooXXV9+3M/O57zSFRicV1Qv6aA0PVZ9X2KSBMJbA2Atego60OXhBHId+HMrbZa JRFw5M3l0OAkIT3d7v3+asQ== X-Received: by 2002:a63:e756:: with SMTP id j22mr27757352pgk.362.1632229685146; Tue, 21 Sep 2021 06:08:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx75Pe5cXDlgkZIL7uS8lqu9b4tKJazILO/UrXASOcVkZ6T7xp76TCzQnDfAsvOoHiI65YDVA== X-Received: by 2002:a63:e756:: with SMTP id j22mr27757338pgk.362.1632229684938; Tue, 21 Sep 2021 06:08:04 -0700 (PDT) Received: from h3ckers-pride.redhat.com ([49.207.212.118]) by smtp.gmail.com with ESMTPSA id w5sm18473890pgp.79.2021.09.21.06.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 06:08:04 -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 v3 2/4] ceph: track average/stdev r/w/m latency Date: Tue, 21 Sep 2021 18:37:48 +0530 Message-Id: <20210921130750.31820-3-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210921130750.31820-1-vshankar@redhat.com> References: <20210921130750.31820-1-vshankar@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Update the math involved to closely mimic how its done in user land. This does not make a lot of difference to the execution speed. Signed-off-by: Venky Shankar --- fs/ceph/metric.c | 63 +++++++++++++++++++++--------------------------- fs/ceph/metric.h | 3 +++ 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c index 226dc38e2909..ca758bff69ca 100644 --- a/fs/ceph/metric.c +++ b/fs/ceph/metric.c @@ -245,6 +245,7 @@ int ceph_metric_init(struct ceph_client_metric *m) spin_lock_init(&m->read_metric_lock); m->read_latency_sq_sum = 0; + m->avg_read_latency = 0; m->read_latency_min = KTIME_MAX; m->read_latency_max = 0; m->total_reads = 0; @@ -255,6 +256,7 @@ int ceph_metric_init(struct ceph_client_metric *m) spin_lock_init(&m->write_metric_lock); m->write_latency_sq_sum = 0; + m->avg_write_latency = 0; m->write_latency_min = KTIME_MAX; m->write_latency_max = 0; m->total_writes = 0; @@ -265,6 +267,7 @@ int ceph_metric_init(struct ceph_client_metric *m) spin_lock_init(&m->metadata_metric_lock); m->metadata_latency_sq_sum = 0; + m->avg_metadata_latency = 0; m->metadata_latency_min = KTIME_MAX; m->metadata_latency_max = 0; m->total_metadatas = 0; @@ -322,20 +325,25 @@ 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_latency(ktime_t *ctotal, ktime_t *lsum, + ktime_t *lavg, ktime_t *min, ktime_t *max, + ktime_t *sum_sq, ktime_t lat) { - ktime_t avg, sq; + ktime_t total, avg; - if (unlikely(total == 1)) - return; + total = ++(*ctotal); + *lsum += lat; + + METRIC_UPDATE_MIN_MAX(*min, *max, lat); - /* 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)) { + *lavg = lat; + *sum_sq = 0; + } else { + avg = *lavg + div64_s64(lat - *lavg, total); + *sum_sq += (lat - *lavg)*(lat - avg); + *lavg = avg; + } } void ceph_update_read_metrics(struct ceph_client_metric *m, @@ -343,23 +351,18 @@ void ceph_update_read_metrics(struct ceph_client_metric *m, unsigned int size, int rc) { ktime_t lat = ktime_sub(r_end, r_start); - ktime_t total; if (unlikely(rc < 0 && rc != -ENOENT && rc != -ETIMEDOUT)) return; spin_lock(&m->read_metric_lock); - total = ++m->total_reads; m->read_size_sum += size; - m->read_latency_sum += lat; METRIC_UPDATE_MIN_MAX(m->read_size_min, m->read_size_max, size); - METRIC_UPDATE_MIN_MAX(m->read_latency_min, - m->read_latency_max, - lat); - __update_stdev(total, m->read_latency_sum, - &m->read_latency_sq_sum, lat); + __update_latency(&m->total_reads, &m->read_latency_sum, + &m->avg_read_latency, &m->read_latency_min, + &m->read_latency_max, &m->read_latency_sq_sum, lat); spin_unlock(&m->read_metric_lock); } @@ -368,23 +371,18 @@ void ceph_update_write_metrics(struct ceph_client_metric *m, unsigned int size, int rc) { ktime_t lat = ktime_sub(r_end, r_start); - ktime_t total; if (unlikely(rc && rc != -ETIMEDOUT)) return; spin_lock(&m->write_metric_lock); - total = ++m->total_writes; m->write_size_sum += size; - m->write_latency_sum += lat; METRIC_UPDATE_MIN_MAX(m->write_size_min, m->write_size_max, size); - METRIC_UPDATE_MIN_MAX(m->write_latency_min, - m->write_latency_max, - lat); - __update_stdev(total, m->write_latency_sum, - &m->write_latency_sq_sum, lat); + __update_latency(&m->total_writes, &m->write_latency_sum, + &m->avg_write_latency, &m->write_latency_min, + &m->write_latency_max, &m->write_latency_sq_sum, lat); spin_unlock(&m->write_metric_lock); } @@ -393,18 +391,13 @@ void ceph_update_metadata_metrics(struct ceph_client_metric *m, int rc) { ktime_t lat = ktime_sub(r_end, r_start); - ktime_t total; if (unlikely(rc && rc != -ENOENT)) return; spin_lock(&m->metadata_metric_lock); - total = ++m->total_metadatas; - m->metadata_latency_sum += lat; - METRIC_UPDATE_MIN_MAX(m->metadata_latency_min, - m->metadata_latency_max, - lat); - __update_stdev(total, m->metadata_latency_sum, - &m->metadata_latency_sq_sum, lat); + __update_latency(&m->total_metadatas, &m->metadata_latency_sum, + &m->avg_metadata_latency, &m->metadata_latency_min, + &m->metadata_latency_max, &m->metadata_latency_sq_sum, lat); spin_unlock(&m->metadata_metric_lock); } diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h index 103ed736f9d2..0af02e212033 100644 --- a/fs/ceph/metric.h +++ b/fs/ceph/metric.h @@ -138,6 +138,7 @@ struct ceph_client_metric { u64 read_size_min; u64 read_size_max; ktime_t read_latency_sum; + ktime_t avg_read_latency; ktime_t read_latency_sq_sum; ktime_t read_latency_min; ktime_t read_latency_max; @@ -148,6 +149,7 @@ struct ceph_client_metric { u64 write_size_min; u64 write_size_max; ktime_t write_latency_sum; + ktime_t avg_write_latency; ktime_t write_latency_sq_sum; ktime_t write_latency_min; ktime_t write_latency_max; @@ -155,6 +157,7 @@ struct ceph_client_metric { spinlock_t metadata_metric_lock; u64 total_metadatas; ktime_t metadata_latency_sum; + ktime_t avg_metadata_latency; ktime_t metadata_latency_sq_sum; ktime_t metadata_latency_min; ktime_t metadata_latency_max; From patchwork Tue Sep 21 13:07:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 12507807 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=-20.2 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 E8763C433F5 for ; Tue, 21 Sep 2021 13:08:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCBA861166 for ; Tue, 21 Sep 2021 13:08:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232923AbhIUNJm (ORCPT ); Tue, 21 Sep 2021 09:09:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34376 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232828AbhIUNJl (ORCPT ); Tue, 21 Sep 2021 09:09:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632229692; 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=J1v01UpNH72I4V1y6xq9G6q0UPA384QwI1P98DnTJo0=; b=J4QNCanWj850vb6A6flA6tZFJ5TXImTnE+wUA+Sw5YCN2C2STzIaLWJMm7ndzuXeuTwb29 ABZbdX0m8UQf6WcFiM8dTJ+G9vFBOl2VprQ1H7jXLkhncccj2PlOCfSOG9JAcc3zSVL7LY hKC06taqAegm13+ZUQrX/9+yIsUuxU4= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-10-pI4PIY8qMWWqx33UE1XItQ-1; Tue, 21 Sep 2021 09:08:10 -0400 X-MC-Unique: pI4PIY8qMWWqx33UE1XItQ-1 Received: by mail-pf1-f200.google.com with SMTP id k206-20020a6284d7000000b004380af887afso15984996pfd.17 for ; Tue, 21 Sep 2021 06:08:10 -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=J1v01UpNH72I4V1y6xq9G6q0UPA384QwI1P98DnTJo0=; b=1AodYcWWG6EMsJdGpEX3FnWzsLipE5sBn4Ndt3NzqmMZTS7CV8u5a4t+T8G8P3N2I4 3CW/ISKsS+ReXQZdMLGsYait8FRbezuPsfFVufH9rtuEeYdHFaCF/lrZ3sscqs4sKrRO 3/3QAPHwaOikOlJaGgKyP8cSaTGQlhZucvyiXmgwm68FvP0HeNmDJ/jlkMnO0Bd8O3l5 ylYL5857o8whK1w8eU9kD/1BIuD3l7fcU+C/gfIfTJI5WR43/n8SrUPNtsw0ficzxDBZ DJFDrnCNWa3REtWqXYNHqCkyMrLIq9wklGX0cee/TyBgthlRIQl9bki8KOMFrp9jqPHc fxcA== X-Gm-Message-State: AOAM532q12H2O26MyXJLcFrw+R9iq+DxnmTbNfXuIZMPriP4WclCId9F PNsJCF1WwqOozXJ3qQ+EU01UciehmZehRguFVHBXCzgcMWHJs9ToGu8go1dIrEbnYS/WY2Iq2c+ ozS+Antc5gcbSuTllAxlEhw== X-Received: by 2002:a17:90b:3805:: with SMTP id mq5mr5149593pjb.143.1632229688683; Tue, 21 Sep 2021 06:08:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweL4w1GloJlWB2jlyWsFjDbMMR/xDPohQZXYxmEIcFWGpU7k2QbpHpYDOk/EVdg3slVHoNxA== X-Received: by 2002:a17:90b:3805:: with SMTP id mq5mr5149575pjb.143.1632229688460; Tue, 21 Sep 2021 06:08:08 -0700 (PDT) Received: from h3ckers-pride.redhat.com ([49.207.212.118]) by smtp.gmail.com with ESMTPSA id w5sm18473890pgp.79.2021.09.21.06.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 06:08:07 -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 v3 3/4] ceph: include average/stddev r/w/m latency in mds metrics Date: Tue, 21 Sep 2021 18:37:49 +0530 Message-Id: <20210921130750.31820-4-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210921130750.31820-1-vshankar@redhat.com> References: <20210921130750.31820-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 | 46 ++++++++++++++++++++++++++++++---------------- fs/ceph/metric.h | 48 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 63 insertions(+), 31 deletions(-) diff --git a/fs/ceph/metric.c b/fs/ceph/metric.c index ca758bff69ca..04ba98286382 100644 --- a/fs/ceph/metric.c +++ b/fs/ceph/metric.c @@ -8,6 +8,20 @@ #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 ktime_t calc_stdev(ktime_t sq_sum, u64 total) +{ + if (total > 1) + return int_sqrt64(DIV64_U64_ROUND_CLOSEST(sq_sum, total - 1)); + return 0; +} + static bool ceph_mdsc_send_metrics(struct ceph_mds_client *mdsc, struct ceph_mds_session *s) { @@ -26,10 +40,10 @@ 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; + ktime_t stdev; len = sizeof(*head) + sizeof(*cap) + sizeof(*read) + sizeof(*write) + sizeof(*meta) + sizeof(*dlease) + sizeof(*files) @@ -59,37 +73,37 @@ 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->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); + stdev = calc_stdev(m->read_latency_sq_sum, m->total_reads); + to_ceph_timespec(&read->stdev, stdev); 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->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); + stdev = calc_stdev(m->write_latency_sq_sum, m->total_writes); + to_ceph_timespec(&write->stdev, stdev); 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->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); + stdev = calc_stdev(m->metadata_latency_sq_sum, m->total_metadatas); + to_ceph_timespec(&meta->stdev, stdev); items++; /* encode the dentry lease metric */ diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h index 0af02e212033..028c5fbc6299 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,24 @@ struct ceph_metric_cap { struct ceph_metric_read_latency { struct ceph_metric_header header; struct ceph_timespec lat; + struct ceph_timespec avg; + struct ceph_timespec stdev; } __packed; /* metric write latency header */ struct ceph_metric_write_latency { struct ceph_metric_header header; struct ceph_timespec lat; + struct ceph_timespec avg; + struct ceph_timespec stdev; } __packed; /* metric metadata latency header */ struct ceph_metric_metadata_latency { struct ceph_metric_header header; struct ceph_timespec lat; + struct ceph_timespec avg; + struct ceph_timespec stdev; } __packed; /* metric dentry lease header */ From patchwork Tue Sep 21 13:07:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venky Shankar X-Patchwork-Id: 12507809 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=-20.2 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 CCE59C433EF for ; Tue, 21 Sep 2021 13:08:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B497C61166 for ; Tue, 21 Sep 2021 13:08:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232344AbhIUNJn (ORCPT ); Tue, 21 Sep 2021 09:09:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59535 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232921AbhIUNJm (ORCPT ); Tue, 21 Sep 2021 09:09:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632229693; 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=9+p3P1OJI635czKUJqe6d5EEYbb5iEr7WLQFszSq5lQ=; b=XkthDUC7hTlFDOSN80XUffGedwduU6QfNO10pKlC0dugI7LzSD1wIBp0yARIzcrexn0+qP bSR0yjih9cvZM7ZGUTmnfJks+KZuPojUEKHe0la88eUtn7Ob4tUrgwNIGvcyxiH/shKTh1 bPAOH74ThqGYNgSO4xELOLLclREP2C8= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-SpRi9TU9Pwa_GWYl2LxWFw-1; Tue, 21 Sep 2021 09:08:12 -0400 X-MC-Unique: SpRi9TU9Pwa_GWYl2LxWFw-1 Received: by mail-pg1-f197.google.com with SMTP id u5-20020a63d3450000b029023a5f6e6f9bso18108867pgi.21 for ; Tue, 21 Sep 2021 06:08:12 -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=9+p3P1OJI635czKUJqe6d5EEYbb5iEr7WLQFszSq5lQ=; b=GXitLBHSf4rAb+YXGwLNT49NJXfJWWuBFhLnze+fyEErY+u4U4YEXik7iS+w+/w8bu NmFT6csiuDQD8pV1pY+jtoM5ncMCLmrUxdRdh3FScar2h4oghJx8RkgpZEQ5yladsFWT 9c+Q/cW2Bt+C21+erPFVBP21X/Nco6BSatbqCXYa2KPCYXA50jz8MrdEFSTvFz/QpqUI uNTVMS2iqVrvqcBbYL0WVUPUJrLvAz2AgQLDPx6h8pGoqaIYuaHh065nrW5g0cRwPj0C 1lpxirOosgYPvNhl64z6KlkMNdi0ayGUXmBe0jgC0XP31zImEyppp079KkZBWdJjQ+Ui inww== X-Gm-Message-State: AOAM533HrEFUwnSzPwcQAzJ/pIyTiCE1eLusOCsZ5FPN08mH9U99OqrV eGDmQZCm6Lp61LlYtSVMIMWTVfuSgSK4Cs5w3M0PVicR7V2JlMDhb4/SsNz/bWKVWvCWpufqENI ynLf5XLCJkz7Y5C8n70airA== X-Received: by 2002:a63:4b4c:: with SMTP id k12mr27929660pgl.172.1632229691671; Tue, 21 Sep 2021 06:08:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzGVnnMp30wbAIL26xx5VXyXDL3P8I5NbX637VS3jUHjMYzUPUWs+fA5XMkohHEkLd3oEG9g== X-Received: by 2002:a63:4b4c:: with SMTP id k12mr27929640pgl.172.1632229691479; Tue, 21 Sep 2021 06:08:11 -0700 (PDT) Received: from h3ckers-pride.redhat.com ([49.207.212.118]) by smtp.gmail.com with ESMTPSA id w5sm18473890pgp.79.2021.09.21.06.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 06:08:10 -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 v3 4/4] ceph: use tracked average r/w/m latencies to display metrics in debugfs Date: Tue, 21 Sep 2021 18:37:50 +0530 Message-Id: <20210921130750.31820-5-vshankar@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210921130750.31820-1-vshankar@redhat.com> References: <20210921130750.31820-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 38b78b45811f..f6972853dc48 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c @@ -172,7 +172,7 @@ static int metric_show(struct seq_file *s, void *p) spin_lock(&m->read_metric_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_sq_sum; @@ -182,7 +182,7 @@ static int metric_show(struct seq_file *s, void *p) spin_lock(&m->write_metric_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_sq_sum; @@ -192,7 +192,7 @@ static int metric_show(struct seq_file *s, void *p) spin_lock(&m->metadata_metric_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_sq_sum;