All of lore.kernel.org
 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 5/7] RDMA/rxe: Allow registering MRs for On-Demand Paging
Date: Mon, 12 Jun 2023 13:18:37 -0300	[thread overview]
Message-ID: <ZIdFXfDu4IMKE+BQ@nvidia.com> (raw)
In-Reply-To: <7d8595c23e954e0fdc19b14e95da13ceef2adafd.1684397037.git.matsuda-daisuke@fujitsu.com>

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

> +static void rxe_mr_set_xarray(struct rxe_mr *mr, unsigned long start,
> +			      unsigned long end, unsigned long *pfn_list)
> +{
> +	unsigned long lower, upper, idx;
> +	struct page *page;
> +
> +	lower = rxe_mr_iova_to_index(mr, start);
> +	upper = rxe_mr_iova_to_index(mr, end);
> +
> +	/* make pages visible in xarray. no sleep while taking the lock */
> +	spin_lock(&mr->page_list.xa_lock);
> +	for (idx = lower; idx <= upper; idx++) {
> +		page = hmm_pfn_to_page(pfn_list[idx]);
> +		__xa_store(&mr->page_list, idx, page, GFP_ATOMIC);

All of these loops can be performance improved a lot by using xas
loops

>  				    unsigned long cur_seq)
> @@ -54,3 +72,105 @@ static bool rxe_ib_invalidate_range(struct mmu_interval_notifier *mni,
>  const struct mmu_interval_notifier_ops rxe_mn_ops = {
>  	.invalidate = rxe_ib_invalidate_range,
>  };
> +
> +#define RXE_PAGEFAULT_RDONLY BIT(1)
> +#define RXE_PAGEFAULT_SNAPSHOT BIT(2)
> +static int rxe_odp_do_pagefault(struct rxe_mr *mr, u64 user_va, int bcnt, u32 flags)
> +{
> +	int np;
> +	u64 access_mask;
> +	bool fault = !(flags & RXE_PAGEFAULT_SNAPSHOT);
> +	struct ib_umem_odp *umem_odp = to_ib_umem_odp(mr->umem);
> +
> +	access_mask = ODP_READ_ALLOWED_BIT;
> +	if (umem_odp->umem.writable && !(flags & RXE_PAGEFAULT_RDONLY))
> +		access_mask |= ODP_WRITE_ALLOWED_BIT;
> +
> +	/*
> +	 * ib_umem_odp_map_dma_and_lock() locks umem_mutex on success.
> +	 * Callers must release the lock later to let invalidation handler
> +	 * do its work again.
> +	 */
> +	np = ib_umem_odp_map_dma_and_lock(umem_odp, user_va, bcnt,
> +					  access_mask, fault);
> +	if (np < 0)
> +		return np;
> +
> +	/* umem_mutex is still locked here, so we can use hmm_pfn_to_page()
> +	 * safely to fetch pages in the range.

All the comments should be in the style like the first one, not the
second

> +	 */
> +	rxe_mr_set_xarray(mr, user_va, user_va + bcnt, umem_odp->pfn_list);
> +
> +	return np;
> +}
> +
> +static int rxe_odp_init_pages(struct rxe_mr *mr)
> +{
> +	int ret;
> +	struct ib_umem_odp *umem_odp = to_ib_umem_odp(mr->umem);
> +
> +	ret = rxe_odp_do_pagefault(mr, mr->umem->address, mr->umem->length,
> +				   RXE_PAGEFAULT_SNAPSHOT);

Probably suffix this with "and_lock"

> +	mr->odp_enabled = true;
> +	mr->umem = &umem_odp->umem;
> +	mr->access = access_flags;
> +	mr->ibmr.length = length;
> +	mr->ibmr.iova = iova;
> +	mr->page_offset = ib_umem_offset(&umem_odp->umem);
> +
> +	err = rxe_odp_init_pages(mr);
> +	if (err) {
> +		ib_umem_odp_release(umem_odp);
> +		return err;
> +	}
> +
> +	err = rxe_mr_fill_pages_from_sgt(mr, &umem_odp->umem.sgt_append.sgt);

Uh? What is this? The sgt is not used in the ODP mode?

> diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h
> index b6fbd9b3d086..de5a982c7c7e 100644
> --- a/drivers/infiniband/sw/rxe/rxe_verbs.h
> +++ b/drivers/infiniband/sw/rxe/rxe_verbs.h
> @@ -333,6 +333,8 @@ struct rxe_mr {
>  	u32			nbuf;
>  
>  	struct xarray		page_list;
> +
> +	bool			odp_enabled;

You can tell from the umem, don't need a flag

Jason

  parent reply	other threads:[~2023-06-12 16:18 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 [this message]
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
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=ZIdFXfDu4IMKE+BQ@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.