From: Jason Gunthorpe <jgg@nvidia.com>
To: Bob Pearson <rpearsonhpe@gmail.com>
Cc: zyjzyj2000@gmail.com, leonro@nvidia.com, yangx.jy@fujitsu.com,
linux-rdma@vger.kernel.org
Subject: Re: [PATCH for-next v6 6/6] RDMA/rxe: Replace rxe_map and rxe_phys_buf by xarray
Date: Mon, 23 Jan 2023 15:36:21 -0400 [thread overview]
Message-ID: <Y87htSGRDR2pjAvW@nvidia.com> (raw)
In-Reply-To: <20230117172540.33205-7-rpearsonhpe@gmail.com>
On Tue, Jan 17, 2023 at 11:25:41AM -0600, Bob Pearson wrote:
> @@ -574,27 +559,49 @@ int rxe_mr_do_atomic_write(struct rxe_mr *mr, u64 iova, u64 value)
> return -EINVAL;
> }
>
> - va = iova_to_vaddr(mr, iova, sizeof(value));
> - if (unlikely(!va)) {
> - rxe_dbg_mr(mr, "iova out of range");
> - return -ERANGE;
> + if (mr->ibmr.type == IB_MR_TYPE_DMA) {
> + page_offset = iova & (PAGE_SIZE - 1);
> + page = virt_to_page(iova & PAGE_MASK);
> + } else {
> + unsigned long index;
> + int err;
> +
> + /* See IBA oA19-28 */
> + err = mr_check_range(mr, iova, sizeof(value));
> + if (unlikely(err)) {
> + rxe_dbg_mr(mr, "iova out of range");
> + return -ERANGE;
> + }
> + 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 (!page)
> + return -EFAULT;
> }
>
> /* See IBA A19.4.2 */
> - if (unlikely((uintptr_t)va & 0x7 || iova & 0x7)) {
> + if (unlikely(page_offset & 0x7)) {
> rxe_dbg_mr(mr, "misaligned address");
> return -RXE_ERR_NOT_ALIGNED;
> }
>
> + va = kmap_local_page(page);
> +
> /* Do atomic write after all prior operations have completed */
> - smp_store_release(va, value);
> + /* TODO: This is what was chosen by the implementer but I am
> + * concerned it isn't what they want. This only guarantees that
> + * the write will complete before any subsequent reads but the
> + * comment says all prior operations have completed. That would
> + * require a full mb() or matching acquire.
> + * Normal usage has a matching load_acquire and store_release.
> + */
> + smp_store_release(&va[page_offset >> 3], value);
The 'atomicness' is that the NIC side does a 'release' and the CPU
side will do an 'acquire' when it reads the same memory.
The 'acquire' from the CPU side will ensure that any prior writes or
atomcis done by the NIC are visible by the CPU - because that is what
acquire/release means.
Eg if the NIC does a RDMA write to X and then an atomic update (and
release) then the acquire will observe X too if it observed the atomic
update.
acquire/release and rmb/wmb are two different models of the same
concept. acquire/release is more datacentric and tends to speak more
about how data observability is ordered, while the barriers tend to
talk more about how the CPU orders operations.
Jason
next prev parent reply other threads:[~2023-01-23 19:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 17:25 [PATCH for-next v6 0/6] RDMA/rxe: Replace mr page map with an xarray Bob Pearson
2023-01-17 17:25 ` [PATCH for-next v6 1/6] RDMA/rxe: Cleanup mr_check_range Bob Pearson
2023-01-17 17:25 ` [PATCH for-next v6 2/6] RDMA/rxe: Move rxe_map_mr_sg to rxe_mr.c Bob Pearson
2023-01-17 17:25 ` [PATCH for-next v6 3/6] RDMA-rxe: Isolate mr code from atomic_reply() Bob Pearson
2023-01-17 17:25 ` [PATCH for-next v6 4/6] RDMA-rxe: Isolate mr code from atomic_write_reply() Bob Pearson
2023-01-17 17:25 ` [PATCH for-next v6 5/6] RDMA/rxe: Cleanup page variables in rxe_mr.c Bob Pearson
2023-01-17 17:25 ` [PATCH for-next v6 6/6] RDMA/rxe: Replace rxe_map and rxe_phys_buf by xarray Bob Pearson
2023-01-23 19:36 ` Jason Gunthorpe [this message]
2023-01-23 19:36 ` [PATCH for-next v6 0/6] RDMA/rxe: Replace mr page map with an xarray Jason Gunthorpe
2023-01-24 3:43 ` Zhu Yanjun
2023-01-24 5:39 ` Daisuke Matsuda (Fujitsu)
2023-01-24 15:17 ` 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=Y87htSGRDR2pjAvW@nvidia.com \
--to=jgg@nvidia.com \
--cc=leonro@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
--cc=rpearsonhpe@gmail.com \
--cc=yangx.jy@fujitsu.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;
as well as URLs for NNTP newsgroup(s).