From patchwork Fri Feb 2 14:08:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Pen X-Patchwork-Id: 10196815 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 6F34760467 for ; Fri, 2 Feb 2018 14:11:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E88428E7B for ; Fri, 2 Feb 2018 14:11:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C15B28E61; Fri, 2 Feb 2018 14:11:10 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 2D28B28E78 for ; Fri, 2 Feb 2018 14:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752134AbeBBOLH (ORCPT ); Fri, 2 Feb 2018 09:11:07 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:36831 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752050AbeBBOKz (ORCPT ); Fri, 2 Feb 2018 09:10:55 -0500 Received: by mail-wr0-f193.google.com with SMTP id y3so12850824wrh.3 for ; Fri, 02 Feb 2018 06:10:54 -0800 (PST) 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=kRmkYHBcznDuWDm3baALchbR87FYB+D5pAjhBnTRo6Y=; b=hwshEnWTpfPB70cIT19OAowWK0epiqoqtxGNyNmD9OuuyvOlCAzRILlwhB1Rjq+sMD PfcCznvLhhFaOpNJZFoaTu+YfOqg1Be7EL+AXLWtgJZ9z6BKs8k0mxr1XxzaAhzTHaIr HthqRGiyfzsZ4m+WJqapOndOsNYjVDTLtk57Yf2VPpLz5gXer0JVku1OxJFee1ez++se WIQL/b2TZEyil/G5CBPWXtQNyOS6QWt0BSmtbxOBh3bspRQbK3Kk6iF1oySKEiYzHKeP IknDRDHuWN15pE+GH2CCsqe0hsviA0p6KpzcbikGf3+1Lis9Vmk7Ed02gUVASCEyO2l8 bmLA== 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=kRmkYHBcznDuWDm3baALchbR87FYB+D5pAjhBnTRo6Y=; b=ewBXttVAI/nR3aOF6VyPM+1WB/1NlD3Fo7LbzkkM6DdwadqDkyNAK/+6owe1OwDX4q iPU8okiunXeHdyeZ3YLYQ5MIi8IOCT740bvjtujJOGRjI54p5936UjQWbxQwvaOpAxv0 L7wNh4SPw81WcLFvIpmuTRAR6w2K6n1v9Qud+GxHu895LdVdMdKGzqsxyFesTt8W6rk3 fU7AZtiWaZMfwwkqv6NR2Shs8ylbTYnN+mZr/jBz9mAtoCqVGq2pVm6e4/Sa/8TyoInd K/bvNoFacfhIFdPmM228VuXDmKdPm1HIddjdNBP8iO9WAvGCsiDMkLOg5h1GSYMUSAg4 Rscg== X-Gm-Message-State: AKwxyteUYsS7VFIxPZeEK8yBIizEL1+rsNzLZIk0Rh5/CKs/QZqpHky2 vv2NR/CEfiASwr0M8gw4pC4bJGEs X-Google-Smtp-Source: AH8x224rpYaSiJ2I1Cc/LiKBJv03fLfLWnq40MxODNwi0WEBeiP/1CodLKa/Ei5am2jJ+7rfEibrFA== X-Received: by 10.223.196.78 with SMTP id a14mr17684716wrg.251.1517580653647; Fri, 02 Feb 2018 06:10:53 -0800 (PST) Received: from pb.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id v186sm798819wmf.17.2018.02.02.06.10.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 06:10:53 -0800 (PST) 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 , Roman Pen , Danil Kipnis , Jack Wang Subject: [PATCH 10/24] ibtrs: server: statistics functions Date: Fri, 2 Feb 2018 15:08:50 +0100 Message-Id: <20180202140904.2017-11-roman.penyaev@profitbricks.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180202140904.2017-1-roman.penyaev@profitbricks.com> References: <20180202140904.2017-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(+) 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..441b07fdf44a --- /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, "%ld %ld %ld %ld %u\n", + atomic64_read(&r->dir[READ].cnt), + atomic64_read(&r->dir[READ].size_total), + atomic64_read(&r->dir[WRITE].cnt), + 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, "%ld %ld\n", + atomic64_read(&stats->wc_comp.total_wc_cnt), + 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; +}