From patchwork Wed Jun 6 15:25:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Pen X-Patchwork-Id: 10450447 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 410F660146 for ; Wed, 6 Jun 2018 15:26:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33771297A8 for ; Wed, 6 Jun 2018 15:26:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28413297CC; Wed, 6 Jun 2018 15:26:00 +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=ham 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 460E1297BC for ; Wed, 6 Jun 2018 15:25:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752112AbeFFPZ5 (ORCPT ); Wed, 6 Jun 2018 11:25:57 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:54512 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932252AbeFFPZo (ORCPT ); Wed, 6 Jun 2018 11:25:44 -0400 Received: by mail-wm0-f67.google.com with SMTP id o13-v6so12239334wmf.4 for ; Wed, 06 Jun 2018 08:25:43 -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=nrGsl97n1UfDfDi91Lkbc3OO0AEGu4+Z8zhmSOt+hbwWh6E2Ok09kMcz0BMfK+JnMI LVzZ4jbmfS4bAifsLoY5vUkr3+b/KUiwGQsg/vwCsiZCZv8G1uOrKsosCCZS7GkB5bmZ Thmc7yp6Ngqku/JSdyoricAAIV/vCrhAWG57ICj3+FVr4wUpS+l9Oke85aGpEkCWaZuU 6otte/2Uo/Y8dz13Q5un0AAtnDk+0kEiqHxp9bJ5C+OBtNz7z+m3DySoJisVDjCgyFTO OXotIXoTGGHkCs92fsdcBF2CFjTSY9USyqvahaVms4hBcF4sUT2OMjMaE/twOiud68IM u/OQ== 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=l4Jkq8M1rqUvw5McwFxTqPXqhjFYVXsUD9L8gdQCqsv8QY90Kd4OasDc40URCemyIG Dd7H7iXwmIVMaU9AOqwGrLvQwIqQA73puIhPCwB1Sjbm5o2g4DfyUAj3dfPwQeYJnsPK wlCc+ThF6j+5OsBx0W5ZPPRnPXqU5DCmeAN2NRG/ieKwJAbP/cD7StXatGQruAPRkV0M JIfS2dvSjU1nkIVwnxHTdt31blznUxGFbYdPPG+1YAgCzgS9XaeK3qHPYXnQiYhdqJrt l3Vg7mhfZI110M4jYKbXAgCW7FhVPkhTs9D2jKZZk82zFkWhhbYDSfKDRiES6DfYsY8/ mzLQ== X-Gm-Message-State: APt69E2GAxyDnCs8LTaEIcpk2SAPbe4C4vyBpGXzPHa798JNpJJUp/l6 2SaJ+sBLaVoNA5XxWDuR4VXJ5pl9V5I= X-Google-Smtp-Source: ADUXVKKc4D/JszZsJD9Ht4ySjLdU5cII/GijnHodPqpjx309SQnnrpGYZgFEdYCq1yjw40RgiucTIw== X-Received: by 2002:a1c:6f50:: with SMTP id k77-v6mr1981676wmc.38.1528298742411; Wed, 06 Jun 2018 08:25:42 -0700 (PDT) Received: from pb.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id n11-v6sm18645834wro.13.2018.06.06.08.25.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 08:25: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 , Danil Kipnis , Jack Wang , Roman Pen Subject: [PATCH v3 11/25] ibtrs: server: statistics functions Date: Wed, 6 Jun 2018 17:25:01 +0200 Message-Id: <20180606152515.25807-12-roman.penyaev@profitbricks.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180606152515.25807-1-roman.penyaev@profitbricks.com> References: <20180606152515.25807-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; +}