All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roman Pen <roman.penyaev@profitbricks.com>
To: linux-block@vger.kernel.org, linux-rdma@vger.kernel.org
Cc: Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@infradead.org>,
	Sagi Grimberg <sagi@grimberg.me>,
	Bart Van Assche <bart.vanassche@sandisk.com>,
	Or Gerlitz <ogerlitz@mellanox.com>,
	Doug Ledford <dledford@redhat.com>,
	Danil Kipnis <danil.kipnis@profitbricks.com>,
	Jack Wang <jinpu.wang@profitbricks.com>,
	Roman Pen <roman.penyaev@profitbricks.com>
Subject: [PATCH v3 11/25] ibtrs: server: statistics functions
Date: Wed,  6 Jun 2018 17:25:01 +0200	[thread overview]
Message-ID: <20180606152515.25807-12-roman.penyaev@profitbricks.com> (raw)
In-Reply-To: <20180606152515.25807-1-roman.penyaev@profitbricks.com>

This introduces set of functions used on server side to account
statistics of RDMA data sent/received.

Signed-off-by: Roman Pen <roman.penyaev@profitbricks.com>
Signed-off-by: Danil Kipnis <danil.kipnis@profitbricks.com>
Cc: Jack Wang <jinpu.wang@profitbricks.com>
---
 drivers/infiniband/ulp/ibtrs/ibtrs-srv-stats.c | 110 +++++++++++++++++++++++++
 1 file changed, 110 insertions(+)
 create mode 100644 drivers/infiniband/ulp/ibtrs/ibtrs-srv-stats.c

diff --git a/drivers/infiniband/ulp/ibtrs/ibtrs-srv-stats.c b/drivers/infiniband/ulp/ibtrs/ibtrs-srv-stats.c
new file mode 100644
index 000000000000..5933cfc03f95
--- /dev/null
+++ b/drivers/infiniband/ulp/ibtrs/ibtrs-srv-stats.c
@@ -0,0 +1,110 @@
+/*
+ * InfiniBand Transport Layer
+ *
+ * Copyright (c) 2014 - 2017 ProfitBricks GmbH. All rights reserved.
+ * Authors: Fabian Holler <mail@fholler.de>
+ *          Jack Wang <jinpu.wang@profitbricks.com>
+ *          Kleber Souza <kleber.souza@profitbricks.com>
+ *          Danil Kipnis <danil.kipnis@profitbricks.com>
+ *          Roman Penyaev <roman.penyaev@profitbricks.com>
+ *          Milind Dumbare <Milind.dumbare@gmail.com>
+ *
+ * Copyright (c) 2017 - 2018 ProfitBricks GmbH. All rights reserved.
+ * Authors: Danil Kipnis <danil.kipnis@profitbricks.com>
+ *          Roman Penyaev <roman.penyaev@profitbricks.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#undef pr_fmt
+#define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt
+
+#include "ibtrs-srv.h"
+
+void ibtrs_srv_update_rdma_stats(struct ibtrs_srv_stats *s,
+				 size_t size, int d)
+{
+	atomic64_inc(&s->rdma_stats.dir[d].cnt);
+	atomic64_add(size, &s->rdma_stats.dir[d].size_total);
+}
+
+void ibtrs_srv_update_wc_stats(struct ibtrs_srv_stats *s)
+{
+	atomic64_inc(&s->wc_comp.calls);
+	atomic64_inc(&s->wc_comp.total_wc_cnt);
+}
+
+int ibtrs_srv_reset_rdma_stats(struct ibtrs_srv_stats *stats, bool enable)
+{
+	if (enable) {
+		struct ibtrs_srv_stats_rdma_stats *r = &stats->rdma_stats;
+
+		memset(r, 0, sizeof(*r));
+		return 0;
+	}
+
+	return -EINVAL;
+}
+
+ssize_t ibtrs_srv_stats_rdma_to_str(struct ibtrs_srv_stats *stats,
+				    char *page, size_t len)
+{
+	struct ibtrs_srv_stats_rdma_stats *r = &stats->rdma_stats;
+	struct ibtrs_srv_sess *sess;
+
+	sess = container_of(stats, typeof(*sess), stats);
+
+	return scnprintf(page, len, "%lld %lld %lld %lld %u\n",
+			 (s64)atomic64_read(&r->dir[READ].cnt),
+			 (s64)atomic64_read(&r->dir[READ].size_total),
+			 (s64)atomic64_read(&r->dir[WRITE].cnt),
+			 (s64)atomic64_read(&r->dir[WRITE].size_total),
+			 atomic_read(&sess->ids_inflight));
+}
+
+int ibtrs_srv_reset_wc_completion_stats(struct ibtrs_srv_stats *stats,
+					bool enable)
+{
+	if (enable) {
+		memset(&stats->wc_comp, 0, sizeof(stats->wc_comp));
+		return 0;
+	}
+
+	return -EINVAL;
+}
+
+int ibtrs_srv_stats_wc_completion_to_str(struct ibtrs_srv_stats *stats,
+					 char *buf, size_t len)
+{
+	return snprintf(buf, len, "%lld %lld\n",
+			(s64)atomic64_read(&stats->wc_comp.total_wc_cnt),
+			(s64)atomic64_read(&stats->wc_comp.calls));
+}
+
+ssize_t ibtrs_srv_reset_all_help(struct ibtrs_srv_stats *stats,
+				 char *page, size_t len)
+{
+	return scnprintf(page, PAGE_SIZE, "echo 1 to reset all statistics\n");
+}
+
+int ibtrs_srv_reset_all_stats(struct ibtrs_srv_stats *stats, bool enable)
+{
+	if (enable) {
+		ibtrs_srv_reset_wc_completion_stats(stats, enable);
+		ibtrs_srv_reset_rdma_stats(stats, enable);
+		return 0;
+	}
+
+	return -EINVAL;
+}
-- 
2.13.1

  parent reply	other threads:[~2018-06-06 15:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-06 15:24 [PATCH v3 00/25] InfiniBand Transport (IBTRS) and Network Block Device (IBNBD) Roman Pen
2018-06-06 15:24 ` [PATCH v3 01/25] sysfs: export sysfs_remove_file_self() Roman Pen
2018-06-06 15:24 ` [PATCH v3 02/25] ibtrs: public interface header to establish RDMA connections Roman Pen
2018-06-06 15:24 ` [PATCH v3 03/25] ibtrs: private headers with IBTRS protocol structs and helpers Roman Pen
2018-06-06 15:24 ` [PATCH v3 04/25] ibtrs: core: lib functions shared between client and server modules Roman Pen
2018-06-06 15:24 ` [PATCH v3 05/25] ibtrs: client: private header with client structs and functions Roman Pen
2018-06-06 15:24 ` [PATCH v3 06/25] ibtrs: client: main functionality Roman Pen
2018-06-06 15:24 ` [PATCH v3 07/25] ibtrs: client: statistics functions Roman Pen
2018-06-06 15:24 ` [PATCH v3 08/25] ibtrs: client: sysfs interface functions Roman Pen
2018-06-06 15:24 ` [PATCH v3 09/25] ibtrs: server: private header with server structs and functions Roman Pen
2018-06-06 15:25 ` [PATCH v3 10/25] ibtrs: server: main functionality Roman Pen
2018-06-06 15:25 ` Roman Pen [this message]
2018-06-06 15:25 ` [PATCH v3 12/25] ibtrs: server: sysfs interface functions Roman Pen
2018-06-06 15:25 ` [PATCH v3 13/25] ibtrs: include client and server modules into kernel compilation Roman Pen
2018-06-06 15:25 ` [PATCH v3 14/25] ibtrs: a bit of documentation Roman Pen
2018-06-06 15:25 ` [PATCH v3 15/25] ibnbd: private headers with IBNBD protocol structs and helpers Roman Pen
2018-06-06 15:25 ` [PATCH v3 16/25] ibnbd: client: private header with client structs and functions Roman Pen
2018-06-06 15:25 ` [PATCH v3 17/25] ibnbd: client: main functionality Roman Pen
2018-06-06 15:25 ` [PATCH v3 18/25] ibnbd: client: sysfs interface functions Roman Pen
2018-06-06 15:25 ` [PATCH v3 19/25] ibnbd: server: private header with server structs and functions Roman Pen
2018-06-06 15:25 ` [PATCH v3 20/25] ibnbd: server: main functionality Roman Pen
2018-06-06 15:25 ` [PATCH v3 21/25] ibnbd: server: functionality for IO submission to file or block dev Roman Pen
2018-06-06 15:25 ` [PATCH v3 22/25] ibnbd: server: sysfs interface functions Roman Pen
2018-06-06 15:25 ` [PATCH v3 23/25] ibnbd: include client and server modules into kernel compilation Roman Pen
2018-06-06 15:25 ` [PATCH v3 24/25] ibnbd: a bit of documentation Roman Pen
2018-06-06 15:25 ` [PATCH v3 25/25] MAINTAINERS: Add maintainer for IBNBD/IBTRS modules Roman Pen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180606152515.25807-12-roman.penyaev@profitbricks.com \
    --to=roman.penyaev@profitbricks.com \
    --cc=axboe@kernel.dk \
    --cc=bart.vanassche@sandisk.com \
    --cc=danil.kipnis@profitbricks.com \
    --cc=dledford@redhat.com \
    --cc=hch@infradead.org \
    --cc=jinpu.wang@profitbricks.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.