From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>, Jason Gunthorpe <jgg@mellanox.com>
Cc: Leon Romanovsky <leonro@mellanox.com>,
RDMA mailing list <linux-rdma@vger.kernel.org>,
Erez Alfasi <ereza@mellanox.com>
Subject: [PATCH rdma-next 6/6] RDMA/nldev: Provide MR statistics
Date: Wed, 7 Aug 2019 13:34:03 +0300 [thread overview]
Message-ID: <20190807103403.8102-7-leon@kernel.org> (raw)
In-Reply-To: <20190807103403.8102-1-leon@kernel.org>
From: Erez Alfasi <ereza@mellanox.com>
Add RDMA nldev netlink interface for dumping MR
statistics information.
Output example:
ereza@dev~$: ./ibv_rc_pingpong -o -P -s 500000000
local address: LID 0x0001, QPN 0x00008a, PSN 0xf81096, GID ::
ereza@dev~$: rdma stat show mr
dev mlx5_0 mrn 2 page_faults 122071 page_invalidations 0
prefetched_pages 122071
Signed-off-by: Erez Alfasi <ereza@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/core/nldev.c | 51 +++++++++++++++++++++++++++++++--
1 file changed, 49 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index 694ded552687..23a686dbc7cd 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -756,6 +756,47 @@ static int fill_stat_hwcounter_entry(struct sk_buff *msg,
return -EMSGSIZE;
}
+static int fill_stat_mr_entry(struct sk_buff *msg, bool has_cap_net_admin,
+ struct rdma_restrack_entry *res, uint32_t port)
+{
+ struct ib_mr *mr = container_of(res, struct ib_mr, res);
+ struct ib_device *dev = mr->pd->device;
+ struct ib_umem_odp *umem_odp;
+ struct nlattr *table_attr;
+
+ if (nla_put_u32(msg, RDMA_NLDEV_ATTR_RES_MRN, res->id))
+ goto err;
+
+ if (fill_res_entry(dev, msg, res))
+ goto err;
+
+ if (!mr->umem->is_odp)
+ return 0;
+
+ umem_odp = to_ib_umem_odp(mr->umem);
+ table_attr = nla_nest_start(msg,
+ RDMA_NLDEV_ATTR_STAT_HWCOUNTERS);
+
+ if (!table_attr)
+ return -EMSGSIZE;
+
+ if (fill_stat_hwcounter_entry(msg, "page_faults",
+ umem_odp->odp_stats.faults))
+ goto err;
+ if (fill_stat_hwcounter_entry(msg, "page_invalidations",
+ umem_odp->odp_stats.invalidations))
+ goto err;
+ if (fill_stat_hwcounter_entry(msg, "prefetched_pages",
+ umem_odp->odp_stats.prefetched))
+ goto err;
+
+ nla_nest_end(msg, table_attr);
+
+ return 0;
+
+err: return -EMSGSIZE;
+}
+
static int fill_stat_counter_hwcounters(struct sk_buff *msg,
struct rdma_counter *counter)
{
@@ -2012,7 +2053,10 @@ static int nldev_stat_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
case RDMA_NLDEV_ATTR_RES_QP:
ret = stat_get_doit_qp(skb, nlh, extack, tb);
break;
-
+ case RDMA_NLDEV_ATTR_RES_MR:
+ ret = res_get_common_doit(skb, nlh, extack, RDMA_RESTRACK_MR,
+ fill_stat_mr_entry);
+ break;
default:
ret = -EINVAL;
break;
@@ -2036,7 +2080,10 @@ static int nldev_stat_get_dumpit(struct sk_buff *skb,
case RDMA_NLDEV_ATTR_RES_QP:
ret = nldev_res_get_counter_dumpit(skb, cb);
break;
-
+ case RDMA_NLDEV_ATTR_RES_MR:
+ ret = res_get_common_dumpit(skb, cb, RDMA_RESTRACK_MR,
+ fill_stat_mr_entry);
+ break;
default:
ret = -EINVAL;
break;
--
2.20.1
prev parent reply other threads:[~2019-08-07 10:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-07 10:33 [PATCH rdma-next 0/6] ODP information and statistics Leon Romanovsky
2019-08-07 10:33 ` [PATCH rdma-next 1/6] RDMA: Embed umem within core MR Leon Romanovsky
2019-08-14 9:33 ` Devesh Sharma
2019-08-07 10:33 ` [PATCH rdma-next 2/6] RDMA/umem: Add ODP type indicator within ib_umem_odp Leon Romanovsky
2019-08-07 11:23 ` Gal Pressman
2019-08-07 11:44 ` Jason Gunthorpe
2019-08-07 11:49 ` Gal Pressman
2019-08-07 11:44 ` Jason Gunthorpe
2019-08-07 12:13 ` Leon Romanovsky
2019-08-07 12:35 ` Jason Gunthorpe
2019-08-07 13:12 ` Leon Romanovsky
2019-08-12 10:53 ` Leon Romanovsky
2019-08-12 12:11 ` Jason Gunthorpe
2019-08-12 13:32 ` Leon Romanovsky
2019-08-07 10:34 ` [PATCH rdma-next 3/6] RDMA/nldev: Return ODP type per MR Leon Romanovsky
2019-08-07 10:34 ` [PATCH rdma-next 4/6] IB/mlx5: Introduce ODP diagnostic counters Leon Romanovsky
2019-08-07 10:34 ` [PATCH rdma-next 5/6] RDMA/nldev: Allow different fill function per resource Leon Romanovsky
2019-08-07 10:34 ` Leon Romanovsky [this message]
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=20190807103403.8102-7-leon@kernel.org \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=ereza@mellanox.com \
--cc=jgg@mellanox.com \
--cc=leonro@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).