From: Daisuke Matsuda <matsuda-daisuke@fujitsu.com>
To: linux-rdma@vger.kernel.org, leon@kernel.org, jgg@ziepe.ca,
zyjzyj2000@gmail.com
Cc: linux-kernel@vger.kernel.org, rpearsonhpe@gmail.com,
lizhijian@fujitsu.com,
Daisuke Matsuda <matsuda-daisuke@fujitsu.com>
Subject: [PATCH for-next v8 6/6] RDMA/rxe: Add support for the traditional Atomic operations with ODP
Date: Wed, 9 Oct 2024 10:59:03 +0900 [thread overview]
Message-ID: <20241009015903.801987-7-matsuda-daisuke@fujitsu.com> (raw)
In-Reply-To: <20241009015903.801987-1-matsuda-daisuke@fujitsu.com>
Enable 'fetch and add' and 'compare and swap' operations to be used with
ODP. This is comprised of the following steps:
1. Verify that the page is present with write permission.
2. If OK, execute the operation and exit.
3. If not, then trigger page fault to map the page.
4. Update the entry in the MR xarray.
5. Execute the operation.
Signed-off-by: Daisuke Matsuda <matsuda-daisuke@fujitsu.com>
---
drivers/infiniband/sw/rxe/rxe.c | 1 +
drivers/infiniband/sw/rxe/rxe_loc.h | 9 +++++++++
drivers/infiniband/sw/rxe/rxe_mr.c | 7 ++++++-
drivers/infiniband/sw/rxe/rxe_odp.c | 30 ++++++++++++++++++++++++++++
drivers/infiniband/sw/rxe/rxe_resp.c | 5 ++++-
5 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/sw/rxe/rxe.c b/drivers/infiniband/sw/rxe/rxe.c
index ea643ebf9667..08c69c637663 100644
--- a/drivers/infiniband/sw/rxe/rxe.c
+++ b/drivers/infiniband/sw/rxe/rxe.c
@@ -90,6 +90,7 @@ static void rxe_init_device_param(struct rxe_dev *rxe)
rxe->attr.odp_caps.per_transport_caps.rc_odp_caps |= IB_ODP_SUPPORT_RECV;
rxe->attr.odp_caps.per_transport_caps.rc_odp_caps |= IB_ODP_SUPPORT_WRITE;
rxe->attr.odp_caps.per_transport_caps.rc_odp_caps |= IB_ODP_SUPPORT_READ;
+ rxe->attr.odp_caps.per_transport_caps.rc_odp_caps |= IB_ODP_SUPPORT_ATOMIC;
rxe->attr.odp_caps.per_transport_caps.rc_odp_caps |= IB_ODP_SUPPORT_SRQ_RECV;
}
}
diff --git a/drivers/infiniband/sw/rxe/rxe_loc.h b/drivers/infiniband/sw/rxe/rxe_loc.h
index 2483e90a5443..5ea6d423d527 100644
--- a/drivers/infiniband/sw/rxe/rxe_loc.h
+++ b/drivers/infiniband/sw/rxe/rxe_loc.h
@@ -195,6 +195,9 @@ int rxe_odp_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length,
u64 iova, int access_flags, struct rxe_mr *mr);
int rxe_odp_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length,
enum rxe_mr_copy_dir dir);
+int rxe_odp_mr_atomic_op(struct rxe_mr *mr, u64 iova, int opcode,
+ u64 compare, u64 swap_add, u64 *orig_val);
+
#else /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */
static inline int
rxe_odp_mr_init_user(struct rxe_dev *rxe, u64 start, u64 length, u64 iova,
@@ -208,6 +211,12 @@ rxe_odp_mr_copy(struct rxe_mr *mr, u64 iova, void *addr,
{
return -EOPNOTSUPP;
}
+static inline int
+rxe_odp_mr_atomic_op(struct rxe_mr *mr, u64 iova, int opcode,
+ u64 compare, u64 swap_add, u64 *orig_val)
+{
+ return RESPST_ERR_UNSUPPORTED_OPCODE;
+}
#endif /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */
diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
index eef3976309eb..273da7dfca97 100644
--- a/drivers/infiniband/sw/rxe/rxe_mr.c
+++ b/drivers/infiniband/sw/rxe/rxe_mr.c
@@ -498,7 +498,12 @@ int rxe_mr_do_atomic_op(struct rxe_mr *mr, u64 iova, int opcode,
}
page_offset = rxe_mr_iova_to_page_offset(mr, iova);
index = rxe_mr_iova_to_index(mr, iova);
- page = xa_load(&mr->page_list, index);
+
+ if (mr->umem->is_odp)
+ page = xa_untag_pointer(xa_load(&mr->page_list, index));
+ else
+ page = xa_load(&mr->page_list, index);
+
if (!page)
return RESPST_ERR_RKEY_VIOLATION;
}
diff --git a/drivers/infiniband/sw/rxe/rxe_odp.c b/drivers/infiniband/sw/rxe/rxe_odp.c
index 979af279cf36..a6d9a840a38c 100644
--- a/drivers/infiniband/sw/rxe/rxe_odp.c
+++ b/drivers/infiniband/sw/rxe/rxe_odp.c
@@ -250,3 +250,33 @@ int rxe_odp_mr_copy(struct rxe_mr *mr, u64 iova, void *addr, int length,
return err;
}
+
+int rxe_odp_mr_atomic_op(struct rxe_mr *mr, u64 iova, int opcode,
+ u64 compare, u64 swap_add, u64 *orig_val)
+{
+ struct ib_umem_odp *umem_odp = to_ib_umem_odp(mr->umem);
+ int err;
+
+ spin_lock(&mr->page_list.xa_lock);
+
+ /* Atomic operations manipulate a single char. */
+ if (rxe_odp_check_pages(mr, iova, sizeof(char), 0)) {
+ spin_unlock(&mr->page_list.xa_lock);
+
+ /* umem_mutex is locked on success */
+ err = rxe_odp_do_pagefault_and_lock(mr, iova, sizeof(char), 0);
+ if (err < 0)
+ return err;
+
+ /* spinlock to prevent page invalidation */
+ spin_lock(&mr->page_list.xa_lock);
+ mutex_unlock(&umem_odp->umem_mutex);
+ }
+
+ err = rxe_mr_do_atomic_op(mr, iova, opcode, compare,
+ swap_add, orig_val);
+
+ spin_unlock(&mr->page_list.xa_lock);
+
+ return err;
+}
diff --git a/drivers/infiniband/sw/rxe/rxe_resp.c b/drivers/infiniband/sw/rxe/rxe_resp.c
index e703a3ab82d4..4c1e7337519a 100644
--- a/drivers/infiniband/sw/rxe/rxe_resp.c
+++ b/drivers/infiniband/sw/rxe/rxe_resp.c
@@ -707,7 +707,10 @@ static enum resp_states atomic_reply(struct rxe_qp *qp,
u64 iova = qp->resp.va + qp->resp.offset;
if (mr->umem->is_odp)
- err = RESPST_ERR_UNSUPPORTED_OPCODE;
+ err = rxe_odp_mr_atomic_op(mr, iova, pkt->opcode,
+ atmeth_comp(pkt),
+ atmeth_swap_add(pkt),
+ &res->atomic.orig_val);
else
err = rxe_mr_do_atomic_op(mr, iova, pkt->opcode,
atmeth_comp(pkt),
--
2.43.0
next prev parent reply other threads:[~2024-10-09 2:00 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-09 1:58 [PATCH for-next v8 0/6] On-Demand Paging on SoftRoCE Daisuke Matsuda
2024-10-09 1:58 ` [PATCH for-next v8 1/6] RDMA/rxe: Make MR functions accessible from other rxe source code Daisuke Matsuda
2024-10-09 14:13 ` Zhu Yanjun
2024-10-10 7:24 ` Daisuke Matsuda (Fujitsu)
2024-10-10 9:18 ` Zhu Yanjun
2024-10-10 10:29 ` Daisuke Matsuda (Fujitsu)
2024-12-09 19:19 ` Jason Gunthorpe
2024-10-09 1:58 ` [PATCH for-next v8 2/6] RDMA/rxe: Move resp_states definition to rxe_verbs.h Daisuke Matsuda
2024-12-09 19:20 ` Jason Gunthorpe
2024-10-09 1:59 ` [PATCH for-next v8 3/6] RDMA/rxe: Add page invalidation support Daisuke Matsuda
2024-10-13 6:15 ` Zhu Yanjun
2024-10-28 7:25 ` Daisuke Matsuda (Fujitsu)
2024-10-28 20:26 ` Zhu Yanjun
2024-12-09 19:21 ` Jason Gunthorpe
2024-12-10 12:00 ` Daisuke Matsuda (Fujitsu)
2024-12-09 19:31 ` Jason Gunthorpe
2024-12-10 12:12 ` Daisuke Matsuda (Fujitsu)
2024-10-09 1:59 ` [PATCH for-next v8 4/6] RDMA/rxe: Allow registering MRs for On-Demand Paging Daisuke Matsuda
2024-12-09 19:33 ` Jason Gunthorpe
2024-10-09 1:59 ` [PATCH for-next v8 5/6] RDMA/rxe: Add support for Send/Recv/Write/Read with ODP Daisuke Matsuda
2024-10-09 1:59 ` Daisuke Matsuda [this message]
2024-10-17 19:27 ` [PATCH for-next v8 0/6] On-Demand Paging on SoftRoCE Jason Gunthorpe
2024-10-29 5:43 ` Daisuke Matsuda (Fujitsu)
2024-10-18 7:06 ` Zhu Yanjun
2024-10-28 7:59 ` Daisuke Matsuda (Fujitsu)
2024-10-28 20:19 ` Zhu Yanjun
2024-12-09 19:36 ` Jason Gunthorpe
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=20241009015903.801987-7-matsuda-daisuke@fujitsu.com \
--to=matsuda-daisuke@fujitsu.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=lizhijian@fujitsu.com \
--cc=rpearsonhpe@gmail.com \
--cc=zyjzyj2000@gmail.com \
/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
all inboxes | Powered by JetHome®