From patchwork Fri May 18 13:03:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Pen X-Patchwork-Id: 10410611 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 13A82602CB for ; Fri, 18 May 2018 13:06:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0445E2897C for ; Fri, 18 May 2018 13:06:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC9C928984; Fri, 18 May 2018 13:06:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B2C92897C for ; Fri, 18 May 2018 13:06:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752201AbeERNGS (ORCPT ); Fri, 18 May 2018 09:06:18 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:51446 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752619AbeERNFm (ORCPT ); Fri, 18 May 2018 09:05:42 -0400 Received: by mail-wm0-f66.google.com with SMTP id j4-v6so14101723wme.1 for ; Fri, 18 May 2018 06:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6BQNy0rEjlGVmE/eCwRr7VYaJCilxhIjukHj+PIcgYw=; b=jkh9CbWKAVlwiFu45OgqD2EimRFJux+XhrvydnXvHQXieK29OAKES3DgDtidMItrVw U5CK1vW1OeM+ssnnvOWWL0NlUjaBDyOgsaS5VAbg7+o6My48PXjK0wFPycZJXUrLx99J jRqEJ+CyFO5LdEt/raQmseKtvXBObwkFyUmmjlntvf9yGIJOa7j7+qBprPVfoXrAh06X bd8p+AvQYVWnB8ilJDgt67S656IXmSu8hdzZb/xoYqXDNDJ5mGntENz66WroXKkz/ezr SlEKMWl23O1SWZq/Fr8VYkhuGFtV8vIc9O7Rs7cnERH5Dk2A70AUgw+JY0jh7VGmETzl 6pzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6BQNy0rEjlGVmE/eCwRr7VYaJCilxhIjukHj+PIcgYw=; b=Pk6UbGZCujUeD2CG+PZPwRwIZc0jQLvyzRe9H2Y2uRTtHCsukv2fwO+Bam5Qz6wG3Q cix+fL8GjDoL3KCj2GEd/twNmFtyw5+BngOUs17I6Fbz2DsqkGEzwlgbDLfMn6u0QUht htVfR0BHkMt7Xoz9VZkubAdjnZN0d6yzF1FhQ1yKQ/F+vLlxQ3vSava0r93n2iK+DgNF +SmG1WNy6QpzK4t6C8vMdwBlrvfpvqRhWt1a4XnmvGEyfUHpeGAqMeDD29BOXSnf1/P0 ubPQdBoC1oEfFTZ/uqMIG2YpPRD4VoLEN+dKqHmTKchXP6/ljV3vo1yNalabdVqhgE+w APdw== X-Gm-Message-State: ALKqPwfbr0J2N2y2iXL9nqdSBv4z2OQVoTX5VJmdedj5lWwkY6VCJZs6 oXknCFhuJWVlG99W/ObaE5nMa1wF X-Google-Smtp-Source: AB8JxZoYEq7lzDNzQM+Q+0EviX/pVGdcyUOIKqN9x/pzPM/xvNJRuy3ctWLWuh6XMarY8o2Go6urng== X-Received: by 2002:a1c:d046:: with SMTP id h67-v6mr4419710wmg.80.1526648740636; Fri, 18 May 2018 06:05:40 -0700 (PDT) Received: from pb.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id m35-v6sm7639980wrm.51.2018.05.18.06.05.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 May 2018 06:05:40 -0700 (PDT) From: Roman Pen To: linux-block@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Jens Axboe , Christoph Hellwig , Sagi Grimberg , Bart Van Assche , Or Gerlitz , Doug Ledford , Swapnil Ingle , Danil Kipnis , Jack Wang , Roman Pen Subject: [PATCH v2 12/26] ibtrs: server: statistics functions Date: Fri, 18 May 2018 15:03:59 +0200 Message-Id: <20180518130413.16997-13-roman.penyaev@profitbricks.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180518130413.16997-1-roman.penyaev@profitbricks.com> References: <20180518130413.16997-1-roman.penyaev@profitbricks.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This introduces set of functions used on server side to account statistics of RDMA data sent/received. Signed-off-by: Roman Pen Signed-off-by: Danil Kipnis Cc: Jack Wang --- 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 + * Jack Wang + * Kleber Souza + * Danil Kipnis + * Roman Penyaev + * Milind Dumbare + * + * Copyright (c) 2017 - 2018 ProfitBricks GmbH. All rights reserved. + * Authors: Danil Kipnis + * Roman Penyaev + * + * 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 . + */ + +#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; +}