mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Daisuke Matsuda <matsuda-daisuke@fujitsu.com>,
	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
Subject: Re: [PATCH for-next v8 3/6] RDMA/rxe: Add page invalidation support
Date: Sun, 13 Oct 2024 14:15:33 +0800	[thread overview]
Message-ID: <e4d71ae6-0a90-4fed-9ab2-6c0abec52756@linux.dev> (raw)
In-Reply-To: <20241009015903.801987-4-matsuda-daisuke@fujitsu.com>

在 2024/10/9 9:59, Daisuke Matsuda 写道:
> On page invalidation, an MMU notifier callback is invoked to unmap DMA
> addresses and update the driver page table(umem_odp->dma_list). It also
> sets the corresponding entries in MR xarray to NULL to prevent any access.
> The callback is registered when an ODP-enabled MR is created.
> 
> Signed-off-by: Daisuke Matsuda <matsuda-daisuke@fujitsu.com>
> ---
>   drivers/infiniband/sw/rxe/Makefile  |  2 +
>   drivers/infiniband/sw/rxe/rxe_odp.c | 57 +++++++++++++++++++++++++++++
>   2 files changed, 59 insertions(+)
>   create mode 100644 drivers/infiniband/sw/rxe/rxe_odp.c
> 
> diff --git a/drivers/infiniband/sw/rxe/Makefile b/drivers/infiniband/sw/rxe/Makefile
> index 5395a581f4bb..93134f1d1d0c 100644
> --- a/drivers/infiniband/sw/rxe/Makefile
> +++ b/drivers/infiniband/sw/rxe/Makefile
> @@ -23,3 +23,5 @@ rdma_rxe-y := \
>   	rxe_task.o \
>   	rxe_net.o \
>   	rxe_hw_counters.o
> +
> +rdma_rxe-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += rxe_odp.o
> diff --git a/drivers/infiniband/sw/rxe/rxe_odp.c b/drivers/infiniband/sw/rxe/rxe_odp.c
> new file mode 100644
> index 000000000000..ea55b79be0c6
> --- /dev/null
> +++ b/drivers/infiniband/sw/rxe/rxe_odp.c
> @@ -0,0 +1,57 @@
> +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
> +/*
> + * Copyright (c) 2022-2023 Fujitsu Ltd. All rights reserved.
> + */
> +
> +#include <linux/hmm.h>
> +
> +#include <rdma/ib_umem_odp.h>
> +
> +#include "rxe.h"
> +
> +static void rxe_mr_unset_xarray(struct rxe_mr *mr, unsigned long start,
> +				unsigned long end)
> +{
> +	unsigned long upper = rxe_mr_iova_to_index(mr, end - 1);
> +	unsigned long lower = rxe_mr_iova_to_index(mr, start);
> +	void *entry;
> +
> +	XA_STATE(xas, &mr->page_list, lower);
> +
> +	/* make elements in xarray NULL */
> +	xas_lock(&xas);
> +	xas_for_each(&xas, entry, upper)
> +		xas_store(&xas, NULL);
> +	xas_unlock(&xas);
> +}
> +
> +static bool rxe_ib_invalidate_range(struct mmu_interval_notifier *mni,
> +				    const struct mmu_notifier_range *range,
> +				    unsigned long cur_seq)
> +{
> +	struct ib_umem_odp *umem_odp =
> +		container_of(mni, struct ib_umem_odp, notifier);
> +	struct rxe_mr *mr = umem_odp->private;
> +	unsigned long start, end;
> +
> +	if (!mmu_notifier_range_blockable(range))
> +		return false;
> +
> +	mutex_lock(&umem_odp->umem_mutex);

guard(mutex)(&umem_odp->umem_mutex);

It seems that the above is more popular.

Zhu Yanjun
> +	mmu_interval_set_seq(mni, cur_seq);
> +
> +	start = max_t(u64, ib_umem_start(umem_odp), range->start);
> +	end = min_t(u64, ib_umem_end(umem_odp), range->end);
> +
> +	rxe_mr_unset_xarray(mr, start, end);
> +
> +	/* update umem_odp->dma_list */
> +	ib_umem_odp_unmap_dma_pages(umem_odp, start, end);
> +
> +	mutex_unlock(&umem_odp->umem_mutex);
> +	return true;
> +}
> +
> +const struct mmu_interval_notifier_ops rxe_mn_ops = {
> +	.invalidate = rxe_ib_invalidate_range,
> +};


  reply	other threads:[~2024-10-13  6:16 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 [this message]
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 ` [PATCH for-next v8 6/6] RDMA/rxe: Add support for the traditional Atomic operations " Daisuke Matsuda
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=e4d71ae6-0a90-4fed-9ab2-6c0abec52756@linux.dev \
    --to=yanjun.zhu@linux.dev \
    --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=matsuda-daisuke@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®