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 4/6] IB/mlx5: Introduce ODP diagnostic counters
Date: Wed, 7 Aug 2019 13:34:01 +0300 [thread overview]
Message-ID: <20190807103403.8102-5-leon@kernel.org> (raw)
In-Reply-To: <20190807103403.8102-1-leon@kernel.org>
From: Erez Alfasi <ereza@mellanox.com>
Introduce ODP diagnostic counters and count the following
per MR within IB/mlx5 driver:
1) Page faults:
Total number of faulted pages.
2) Page invalidations:
Total number of pages invalidated by the OS during all
invalidation events. The translations can be no longer
valid due to either non-present pages or mapping changes.
3) Prefetched pages:
When prefetching a page, page fault is generated
in order to bring the page to the main memory.
The prefetched pages counter will be updated
during a page fault flow only if it was derived
from prefetching operation.
Signed-off-by: Erez Alfasi <ereza@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
---
drivers/infiniband/hw/mlx5/odp.c | 17 +++++++++++++++++
include/rdma/ib_umem_odp.h | 14 ++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/odp.c
index 673d18b0b743..c651c684a656 100644
--- a/drivers/infiniband/hw/mlx5/odp.c
+++ b/drivers/infiniband/hw/mlx5/odp.c
@@ -287,6 +287,10 @@ void mlx5_ib_invalidate_range(struct ib_umem_odp *umem_odp, unsigned long start,
ib_umem_odp_unmap_dma_pages(umem_odp, start, end);
+ /* Count page invalidations */
+ ib_update_odp_stats(mr->ibmr, invalidations,
+ (end - start)/BIT(umem_odp->page_shift));
+
if (unlikely(!umem_odp->npages && mr->parent &&
!umem_odp->dying)) {
WRITE_ONCE(umem_odp->dying, 1);
@@ -830,6 +834,19 @@ static int pagefault_single_data_segment(struct mlx5_ib_dev *dev,
if (ret < 0)
goto srcu_unlock;
+ /*
+ * When prefetching a page, page fault is generated
+ * in order to bring the page to the main memory.
+ * In the current flow, page faults are being counted.
+ * Prefetched pages counter will be updated as well
+ * only if the current page fault flow was derived
+ * from prefetching flow.
+ */
+ ib_update_odp_stats(mr->ibmr, faults, ret);
+
+ if (prefetch)
+ ib_update_odp_stats(mr->ibmr, prefetched, ret);
+
npages += ret;
ret = 0;
break;
diff --git a/include/rdma/ib_umem_odp.h b/include/rdma/ib_umem_odp.h
index 81dc53a2848c..ebc6074c8dc7 100644
--- a/include/rdma/ib_umem_odp.h
+++ b/include/rdma/ib_umem_odp.h
@@ -42,6 +42,12 @@ struct umem_odp_node {
struct rb_node rb;
};
+struct ib_odp_counters {
+ u64 faults;
+ u64 invalidations;
+ u64 prefetched;
+};
+
struct ib_umem_odp {
struct ib_umem umem;
struct ib_ucontext_per_mm *per_mm;
@@ -72,6 +78,11 @@ struct ib_umem_odp {
*/
u8 type;
+ /*
+ * ODP diagnostic counters.
+ */
+ struct ib_odp_counters odp_stats;
+
int notifiers_seq;
int notifiers_count;
int npages;
@@ -118,6 +129,9 @@ static inline void ib_umem_odp_set_type(struct ib_umem_odp *umem_odp,
umem_odp->type = IB_ODP_TYPE_EXPLICIT;
}
+#define ib_update_odp_stats(mr, counter_name, value) \
+ (to_ib_umem_odp(mr.umem)->odp_stats.counter_name += value)
+
/*
* The lower 2 bits of the DMA address signal the R/W permissions for
* the entry. To upgrade the permissions, provide the appropriate
--
2.20.1
next 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 ` Leon Romanovsky [this message]
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 ` [PATCH rdma-next 6/6] RDMA/nldev: Provide MR statistics Leon Romanovsky
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-5-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).