All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Bob Pearson <rpearsonhpe@gmail.com>
Cc: leon@kernel.org, zyjzyj2000@gmail.com,
	linux-rdma@vger.kernel.org, jhack@hpe.com
Subject: Re: [PATCH for-next 1/2] RDMA/core: Support drivers use of rcu locking
Date: Wed, 9 Aug 2023 16:10:02 -0300	[thread overview]
Message-ID: <ZNPkik5qUPRzZXAW@nvidia.com> (raw)
In-Reply-To: <20230718175943.16734-2-rpearsonhpe@gmail.com>

On Tue, Jul 18, 2023 at 12:59:43PM -0500, Bob Pearson wrote:
> This patch allows drivers to optionally include struct rcu_head
> in their private object data structs and have rdma-core use kfree_rcu
> to free the objects.
> 
> The offsets of the rcu_heads are stored in fields in struct
> ib_device_ops and a macro RDMA_KFREE_RCU is introduced which calls
> (an open coded) kfree_rcu instead of kfree if the value is non-
> zero. Currently the supported object types are AH, QP and MW.
> 
> Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
> ---
>  drivers/infiniband/core/uverbs_main.c |  2 +-
>  drivers/infiniband/core/verbs.c       |  6 +++---
>  include/rdma/ib_verbs.h               | 24 ++++++++++++++++++++++++
>  3 files changed, 28 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
> index 7c9c79c13941..50497e550f18 100644
> --- a/drivers/infiniband/core/uverbs_main.c
> +++ b/drivers/infiniband/core/uverbs_main.c
> @@ -112,7 +112,7 @@ int uverbs_dealloc_mw(struct ib_mw *mw)
>  		return ret;
>  
>  	atomic_dec(&pd->usecnt);
> -	kfree(mw);
> +	RDMA_KFREE_RCU(mw);
>  	return ret;
>  }
>  
> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> index b99b3cc283b6..a49ae8c52c66 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -982,7 +982,7 @@ int rdma_destroy_ah_user(struct ib_ah *ah, u32 flags, struct ib_udata *udata)
>  	if (sgid_attr)
>  		rdma_put_gid_attr(sgid_attr);
>  
> -	kfree(ah);
> +	RDMA_KFREE_RCU(ah);
>  	return ret;
>  }
>  EXPORT_SYMBOL(rdma_destroy_ah_user);
> @@ -1970,7 +1970,7 @@ int ib_close_qp(struct ib_qp *qp)
>  	atomic_dec(&real_qp->usecnt);
>  	if (qp->qp_sec)
>  		ib_close_shared_qp_security(qp->qp_sec);
> -	kfree(qp);
> +	RDMA_KFREE_RCU(qp);
>  
>  	return 0;
>  }
> @@ -2041,7 +2041,7 @@ int ib_destroy_qp_user(struct ib_qp *qp, struct ib_udata *udata)
>  		ib_destroy_qp_security_end(sec);
>  
>  	rdma_restrack_del(&qp->res);
> -	kfree(qp);
> +	RDMA_KFREE_RCU(qp);
>  	return ret;
>  }
>  EXPORT_SYMBOL(ib_destroy_qp_user);
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index 1e7774ac808f..616e9e54a733 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -2684,8 +2684,32 @@ struct ib_device_ops {
>  	DECLARE_RDMA_OBJ_SIZE(ib_srq);
>  	DECLARE_RDMA_OBJ_SIZE(ib_ucontext);
>  	DECLARE_RDMA_OBJ_SIZE(ib_xrcd);
> +
> +	/* if non-zero holds offset of rcu_head in object */
> +	ssize_t rcu_offset_ah;
> +	ssize_t rcu_offset_qp;
> +	ssize_t rcu_offset_mw;

Just size_t, this isn't negative

> +static inline void __rdma_kfree_rcu(void *obj, ssize_t rcu_offset)

Here too

Jason

  reply	other threads:[~2023-08-09 19:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-18 17:59 [PATCH for-next 0/2] Enable rcu locking of verbs objects Bob Pearson
2023-07-18 17:59 ` [PATCH for-next 1/2] RDMA/core: Support drivers use of rcu locking Bob Pearson
2023-08-09 19:10   ` Jason Gunthorpe [this message]
2023-07-18 17:59 ` [PATCH for-next 2/2] RDMA/rxe: Enable rcu locking of indexed objects Bob Pearson
2023-07-19  5:38   ` Zhu Yanjun
2023-07-19 14:34     ` Bob Pearson
2023-07-19  7:49   ` Leon Romanovsky
2023-07-19 16:43     ` Bob Pearson
2023-07-23 15:00       ` Leon Romanovsky
2023-08-09 19: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=ZNPkik5qUPRzZXAW@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=jhack@hpe.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --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 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.