From patchwork Tue Jan 28 13:02:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiubo Li X-Patchwork-Id: 11354231 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 772F4138C for ; Tue, 28 Jan 2020 13:03:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5601D24683 for ; Tue, 28 Jan 2020 13:03:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Sf3Wuqxg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725937AbgA1NDb (ORCPT ); Tue, 28 Jan 2020 08:03:31 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:40465 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725852AbgA1NDb (ORCPT ); Tue, 28 Jan 2020 08:03:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580216610; 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=pZyMP45G5kXP8v419o76iOuhS2F62vcSL96XsFjFBMQ=; b=Sf3WuqxgLFyKW9rFCuUScSYCPqzaOEqG8VFmflL8BZ+qtZRhGE0hCoV5vNlkMTRZKIiLGB Dv/LOGb6fYEH+LrBQr52smcGHJSWeWSTaEM0Pty3UU/Svf0xGoW8iqDxpeEZrS3onVu/A9 3b86lvf7djwzuGpBkUdVIniliQlzF30= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-379-gmAWtRz8MLOFHw-9l2y7IQ-1; Tue, 28 Jan 2020 08:03:27 -0500 X-MC-Unique: gmAWtRz8MLOFHw-9l2y7IQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6A199107ACCA; Tue, 28 Jan 2020 13:03:26 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-34.pek2.redhat.com [10.72.12.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id C21FD863D3; Tue, 28 Jan 2020 13:03:22 +0000 (UTC) From: xiubli@redhat.com To: jlayton@kernel.org, idryomov@gmail.com, zyan@redhat.com Cc: sage@redhat.com, pdonnell@redhat.com, ceph-devel@vger.kernel.org, Xiubo Li Subject: [PATCH v5 06/10] ceph: add global metadata perf metric support Date: Tue, 28 Jan 2020 08:02:44 -0500 Message-Id: <20200128130248.4266-7-xiubli@redhat.com> In-Reply-To: <20200128130248.4266-1-xiubli@redhat.com> References: <20200128130248.4266-1-xiubli@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Xiubo Li item total sum_lat(us) avg_lat(us) ----------------------------------------------------- metadata 1288 24506000 19026 URL: https://tracker.ceph.com/issues/43215 Signed-off-by: Xiubo Li --- fs/ceph/debugfs.c | 6 ++++++ fs/ceph/mds_client.c | 25 +++++++++++++++++++++++++ fs/ceph/metric.h | 13 +++++++++++++ 3 files changed, 44 insertions(+) diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index 3d27f2e6f556..7fd031c18309 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c @@ -146,6 +146,12 @@ static int metric_show(struct seq_file *s, void *p) seq_printf(s, "%-14s%-12lld%-16lld%lld\n", "write", total, sum / NSEC_PER_USEC, avg / NSEC_PER_USEC); + total = percpu_counter_sum(&mdsc->metric.total_metadatas); + sum = percpu_counter_sum(&mdsc->metric.metadata_latency_sum); + avg = total ? sum / total : 0; + seq_printf(s, "%-14s%-12lld%-16lld%lld\n", "metadata", + total, sum / NSEC_PER_USEC, avg / NSEC_PER_USEC); + seq_printf(s, "\n"); seq_printf(s, "item total miss hit\n"); seq_printf(s, "-------------------------------------------------\n"); diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index d072cab77ab2..92a933810a79 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -2772,6 +2772,12 @@ static int ceph_mdsc_wait_request(struct ceph_mds_client *mdsc, else err = timeleft; /* killed */ } + + if (!err || err == -EIO) { + s64 latency = jiffies - req->r_started; + ceph_update_metadata_latency(&mdsc->metric, latency); + } + dout("do_request waited, got %d\n", err); mutex_lock(&mdsc->mutex); @@ -3033,6 +3039,11 @@ static void handle_reply(struct ceph_mds_session *session, struct ceph_msg *msg) /* kick calling process */ complete_request(mdsc, req); + + if (!result || result == -ENOENT) { + s64 latency = jiffies - req->r_started; + ceph_update_metadata_latency(&mdsc->metric, latency); + } out: ceph_mdsc_put_request(req); return; @@ -4203,7 +4214,19 @@ static int ceph_mdsc_metric_init(struct ceph_client_metric *metric) if (ret) goto err_write_latency_sum; + ret = percpu_counter_init(&metric->total_metadatas, 0, GFP_KERNEL); + if (ret) + goto err_total_metadatas; + + ret = percpu_counter_init(&metric->metadata_latency_sum, 0, GFP_KERNEL); + if (ret) + goto err_metadata_latency_sum; + return ret; +err_metadata_latency_sum: + percpu_counter_destroy(&metric->total_metadatas); +err_total_metadatas: + percpu_counter_destroy(&metric->write_latency_sum); err_write_latency_sum: percpu_counter_destroy(&metric->total_writes); err_total_writes: @@ -4555,6 +4578,8 @@ void ceph_mdsc_destroy(struct ceph_fs_client *fsc) ceph_mdsc_stop(mdsc); + percpu_counter_destroy(&mdsc->metric.metadata_latency_sum); + percpu_counter_destroy(&mdsc->metric.total_metadatas); percpu_counter_destroy(&mdsc->metric.write_latency_sum); percpu_counter_destroy(&mdsc->metric.total_writes); percpu_counter_destroy(&mdsc->metric.read_latency_sum); diff --git a/fs/ceph/metric.h b/fs/ceph/metric.h index 49546961eeed..3cda616ba594 100644 --- a/fs/ceph/metric.h +++ b/fs/ceph/metric.h @@ -15,6 +15,9 @@ struct ceph_client_metric { struct percpu_counter total_writes; struct percpu_counter write_latency_sum; + + struct percpu_counter total_metadatas; + struct percpu_counter metadata_latency_sum; }; static inline void ceph_update_read_latency(struct ceph_client_metric *m, @@ -44,4 +47,14 @@ static inline void ceph_update_write_latency(struct ceph_client_metric *m, percpu_counter_add(&m->write_latency_sum, latency); } } + +static inline void ceph_update_metadata_latency(struct ceph_client_metric *m, + s64 latency) +{ + if (!m) + return; + + percpu_counter_inc(&m->total_metadatas); + percpu_counter_add(&m->metadata_latency_sum, latency); +} #endif