All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Bob Pearson <rpearsonhpe@gmail.com>
Cc: zyjzyj2000@gmail.com, jhack@hpe.com, matsuda-daisuke@fujitsu.com,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH for-next v3 2/8] RDMA/rxe: Warn if refcnt zero in rxe_put
Date: Fri, 24 Mar 2023 11:18:05 -0300	[thread overview]
Message-ID: <ZB2xHf00620e7vtf@nvidia.com> (raw)
In-Reply-To: <20230304174533.11296-3-rpearsonhpe@gmail.com>

On Sat, Mar 04, 2023 at 11:45:28AM -0600, Bob Pearson wrote:
> This patch adds a WARN_ON if the reference count of the object
> passed to __rxe_put() is <= 0. This can only happen if there is a
> bug in the rxe driver but has bad consequences if there is.
> 
> Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
> ---
>  drivers/infiniband/sw/rxe/rxe_pool.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
> index 3f6bd672cc2d..1b160e36b751 100644
> --- a/drivers/infiniband/sw/rxe/rxe_pool.c
> +++ b/drivers/infiniband/sw/rxe/rxe_pool.c
> @@ -244,6 +244,8 @@ int __rxe_get(struct rxe_pool_elem *elem)
>  
>  int __rxe_put(struct rxe_pool_elem *elem)
>  {
> +	if (WARN_ON(kref_read(&elem->ref_cnt) <= 0))
> +		return 0;
>  	return kref_put(&elem->ref_cnt, rxe_elem_release);

refcount debugging in kref_put already does this kind of stuff, don't
need to open code it.

Jason

  reply	other threads:[~2023-03-24 14:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-04 17:45 [PATCH for-next v3 0/8] RDMA/rxe: Correct qp reference counting Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 1/8] RDMA/rxe: Convert tasklet args to queue pairs Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 2/8] RDMA/rxe: Warn if refcnt zero in rxe_put Bob Pearson
2023-03-24 14:18   ` Jason Gunthorpe [this message]
2023-03-04 17:45 ` [PATCH for-next v3 3/8] RDMA/rxe: Cleanup reset state handling in rxe_resp.c Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 4/8] RDMA/rxe: Cleanup error state handling in rxe_comp.c Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 5/8] RDMA/rxe: Remove qp reference counting in tasks Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 6/8] RDMA/rxe: Remove __rxe_do_task() Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 7/8] RDMA/rxe: Make tasks schedule each other Bob Pearson
2023-03-04 17:45 ` [PATCH for-next v3 8/8] RDMA/rxe: Rewrite rxe_task.c Bob Pearson
2023-03-24 14:23 ` [PATCH for-next v3 0/8] RDMA/rxe: Correct qp reference counting 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=ZB2xHf00620e7vtf@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=jhack@hpe.com \
    --cc=linux-rdma@vger.kernel.org \
    --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 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.