[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZPsuLeuGAgpBoTjU@ziepe.ca>
Date: Fri, 8 Sep 2023 11:22:37 -0300
From: Jason Gunthorpe <jgg@...pe.ca>
To: Daisuke Matsuda <matsuda-daisuke@...itsu.com>
Cc: linux-rdma@...r.kernel.org, leon@...nel.org, zyjzyj2000@...il.com,
linux-kernel@...r.kernel.org, rpearsonhpe@...il.com,
yangx.jy@...itsu.com, lizhijian@...itsu.com, y-goto@...itsu.com
Subject: Re: [PATCH for-next v6 4/7] RDMA/rxe: Add page invalidation support
On Fri, Sep 08, 2023 at 03:26:45PM +0900, Daisuke Matsuda wrote:
> 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@...itsu.com>
> ---
> drivers/infiniband/sw/rxe/Makefile | 2 +
> drivers/infiniband/sw/rxe/rxe_odp.c | 64 +++++++++++++++++++++++++++++
> 2 files changed, 66 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..834fb1a84800
> --- /dev/null
> +++ b/drivers/infiniband/sw/rxe/rxe_odp.c
> @@ -0,0 +1,64 @@
> +// 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 lower = rxe_mr_iova_to_index(mr, start);
> + unsigned long upper = rxe_mr_iova_to_index(mr, end - 1);
> + void *entry;
> +
> + XA_STATE(xas, &mr->page_list, lower);
> +
> + /* make elements in xarray NULL */
> + xas_lock(&xas);
> + while (true) {
> + xas_store(&xas, NULL);
> +
> + entry = xas_next(&xas);
I think this should just be
xas_for_each(xas, entry, upper)
xas_store(&xas, NULL)
> + if (xas_retry(&xas, entry) || (xas.xa_index <= upper))
> + continue;
xa_erase doesn't deal with retry entries, why do you think this does?
IIRC retry entries cannot be seen under the spinlock
Jason
Powered by blists - more mailing lists