linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Daisuke Matsuda <matsuda-daisuke@fujitsu.com>
Cc: linux-rdma@vger.kernel.org, leonro@nvidia.com,
	zyjzyj2000@gmail.com, linux-kernel@vger.kernel.org,
	rpearsonhpe@gmail.com, yangx.jy@fujitsu.com,
	lizhijian@fujitsu.com, y-goto@fujitsu.com
Subject: Re: [PATCH for-next v5 6/7] RDMA/rxe: Add support for Send/Recv/Write/Read with ODP
Date: Mon, 12 Jun 2023 13:22:43 -0300	[thread overview]
Message-ID: <ZIdGU709e1h5h4JJ@nvidia.com> (raw)
In-Reply-To: <25d903e0136ea1e65c612d8f6b8c18c1f010add7.1684397037.git.matsuda-daisuke@fujitsu.com>

On Thu, May 18, 2023 at 05:21:51PM +0900, Daisuke Matsuda wrote:

> +/* umem mutex must be locked before entering this function. */
> +static int rxe_odp_map_range(struct rxe_mr *mr, u64 iova, int length, u32 flags)
> +{
> +	struct ib_umem_odp *umem_odp = to_ib_umem_odp(mr->umem);
> +	const int max_tries = 3;
> +	int cnt = 0;
> +
> +	int err;
> +	u64 perm;
> +	bool need_fault;
> +
> +	if (unlikely(length < 1)) {
> +		mutex_unlock(&umem_odp->umem_mutex);
> +		return -EINVAL;
> +	}
> +
> +	perm = ODP_READ_ALLOWED_BIT;
> +	if (!(flags & RXE_PAGEFAULT_RDONLY))
> +		perm |= ODP_WRITE_ALLOWED_BIT;
> +
> +	/*
> +	 * A successful return from rxe_odp_do_pagefault() does not guarantee
> +	 * that all pages in the range became present. Recheck the DMA address
> +	 * array, allowing max 3 tries for pagefault.
> +	 */
> +	while ((need_fault = rxe_is_pagefault_neccesary(umem_odp,
> +							iova, length, perm))) {
> +		if (cnt >= max_tries)
> +			break;

I don't think this makes sense..

You need to make this work more like mlx5 does, you take the spinlock
on the xarray, you search it for your index and whatever is there
tells what to do. Hold the spinlock while doing the copy. This is
enough locking for the fast path.

If there is no index present, or it is not writable and you need
write, then you unlock the spinlock and prefetch the missing entry and
try again, this time also holding the mutex so there isn't a race.

You shouldn't probe into parts of the umem to discover information
already stored in the xarray then do the same lookup into the xarray.

IIRC this also needs to keep track in the xarray on a per page basis
if the page is writable.

Jason

  parent reply	other threads:[~2023-06-12 16:22 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18  8:21 [PATCH for-next v5 0/7] On-Demand Paging on SoftRoCE Daisuke Matsuda
2023-05-18  8:21 ` [PATCH for-next v5 1/7] RDMA/rxe: Always defer tasks on responder and completer to workqueue Daisuke Matsuda
2023-05-18  8:26   ` Daisuke Matsuda (Fujitsu)
2023-05-18 22:25   ` Bob Pearson
2023-05-18  8:21 ` [PATCH for-next v5 2/7] RDMA/rxe: Make MR functions accessible from other rxe source code Daisuke Matsuda
2023-05-18 22:28   ` Bob Pearson
2023-05-18  8:21 ` [PATCH for-next v5 3/7] RDMA/rxe: Move resp_states definition to rxe_verbs.h Daisuke Matsuda
2023-05-18 22:30   ` Bob Pearson
2023-05-18  8:21 ` [PATCH for-next v5 4/7] RDMA/rxe: Add page invalidation support Daisuke Matsuda
2023-05-19 17:08   ` Bob Pearson
2023-05-18  8:21 ` [PATCH for-next v5 5/7] RDMA/rxe: Allow registering MRs for On-Demand Paging Daisuke Matsuda
2023-05-19 17:09   ` Bob Pearson
2023-06-12 16:18   ` Jason Gunthorpe
2023-07-19  6:00     ` Daisuke Matsuda (Fujitsu)
2023-07-21 18:46       ` Jason Gunthorpe
2023-05-18  8:21 ` [PATCH for-next v5 6/7] RDMA/rxe: Add support for Send/Recv/Write/Read with ODP Daisuke Matsuda
2023-05-19 17:10   ` Bob Pearson
2023-05-19 17:10   ` Bob Pearson
2023-06-12 16:22   ` Jason Gunthorpe [this message]
2023-07-19  6:01     ` Daisuke Matsuda (Fujitsu)
2023-09-08  6:35     ` Daisuke Matsuda (Fujitsu)
2023-09-08 13:14       ` Jason Gunthorpe
2023-05-18  8:21 ` [PATCH for-next v5 7/7] RDMA/rxe: Add support for the traditional Atomic operations " Daisuke Matsuda
2023-05-22 18:49   ` Bob Pearson
2023-05-19  6:41 ` [PATCH for-next v5 0/7] On-Demand Paging on SoftRoCE Guoqing Jiang
2023-05-19  9:57   ` Daisuke Matsuda (Fujitsu)
2023-05-19 10:20     ` Guoqing Jiang

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=ZIdGU709e1h5h4JJ@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=leonro@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lizhijian@fujitsu.com \
    --cc=matsuda-daisuke@fujitsu.com \
    --cc=rpearsonhpe@gmail.com \
    --cc=y-goto@fujitsu.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).