linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Bob Pearson <rpearsonhpe@gmail.com>
Cc: leon@kernel.org, zyjzyj2000@gmail.com, jhack@hpe.com,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH for-next 8/9] RDMA/rxe: Report leaked objects
Date: Fri, 4 Aug 2023 11:16:31 -0300	[thread overview]
Message-ID: <ZM0IP/3QtXG6Dtrx@nvidia.com> (raw)
In-Reply-To: <394e5205-4bec-3a92-7c89-8966d2329946@gmail.com>

On Mon, Jul 31, 2023 at 01:51:59PM -0500, Bob Pearson wrote:
> On 7/31/23 13:43, Jason Gunthorpe wrote:
> > On Mon, Jul 31, 2023 at 01:42:09PM -0500, Bob Pearson wrote:
> >> On 7/31/23 13:31, Jason Gunthorpe wrote:
> >>> On Mon, Jul 31, 2023 at 01:23:59PM -0500, Bob Pearson wrote:
> >>>> On 7/31/23 13:15, Jason Gunthorpe wrote:
> >>>>> On Fri, Jul 21, 2023 at 03:50:21PM -0500, Bob Pearson wrote:
> >>>>>> This patch gives a more detailed list of objects that are not
> >>>>>> freed in case of error before the module exits.
> >>>>>>
> >>>>>> Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com>
> >>>>>> ---
> >>>>>>  drivers/infiniband/sw/rxe/rxe_pool.c | 12 +++++++++++-
> >>>>>>  1 file changed, 11 insertions(+), 1 deletion(-)
> >>>>>>
> >>>>>> diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c
> >>>>>> index cb812bd969c6..3249c2741491 100644
> >>>>>> --- a/drivers/infiniband/sw/rxe/rxe_pool.c
> >>>>>> +++ b/drivers/infiniband/sw/rxe/rxe_pool.c
> >>>>>> @@ -113,7 +113,17 @@ void rxe_pool_init(struct rxe_dev *rxe, struct rxe_pool *pool,
> >>>>>>  
> >>>>>>  void rxe_pool_cleanup(struct rxe_pool *pool)
> >>>>>>  {
> >>>>>> -	WARN_ON(!xa_empty(&pool->xa));
> >>>>>> +	unsigned long index;
> >>>>>> +	struct rxe_pool_elem *elem;
> >>>>>> +
> >>>>>> +	xa_lock(&pool->xa);
> >>>>>> +	xa_for_each(&pool->xa, index, elem) {
> >>>>>> +		rxe_err_dev(pool->rxe, "%s#%d: Leaked", pool->name,
> >>>>>> +				elem->index);
> >>>>>> +	}
> >>>>>> +	xa_unlock(&pool->xa);
> >>>>>> +
> >>>>>> +	xa_destroy(&pool->xa);
> >>>>>>  }
> >>>>>
> >>>>> Is this why? Just count the number of unfinalized objects and report
> >>>>> if there is difference, don't mess up the xarray.
> >>>>>
> >>>>> Jason
> >>>> This is why I made the last change but I really didn't like that there was no
> >>>> way to lookup the qp from its index since we were using a NULL xarray entry to
> >>>> indicate the state of the qp. Making it explicit, i.e. a variable in the struct
> >>>> seems much more straight forward. Not sure why you hated the last
> >>>> change.
> >>>
> >>> Because if you don't call finalize abort has to be deterministic, and
> >>> abort can't be that if it someone else can access the poitner and, eg,
> >>> take a reference.
> >>
> >> rxe_pool_get_index() is the only 'correct' way to look up the pointer and
> >> it checks the valid state (now). Scanning the xarray or just looking up
> >> the qp is something outside the scope of the normal flows. Like listing
> >> orphan objects on module exit.
> > 
> > Maybe at this instance, but people keep changing this and it is
> > fundamentally wrong to store a pointer to an incompletely initialized
> > memory for other threads to see.
> > 
> > Especially for some minor debugging feature.
> 
> Maybe warning comments would help. There are lots of ways to break the code, sigh.
> The typical one is someone makes a change that breaks reference
> counting.

Don't do it wrong in the first place is the most important thing.

Don't put incompletely intialized objects in global memory. It is a
very simple rule.

Jason

  reply	other threads:[~2023-08-04 14:16 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-21 20:50 [PATCH for-next 0/9] RDMA/rxe: Misc fixes and cleanups Bob Pearson
2023-07-21 20:50 ` [PATCH for-next 1/9] RDMA/rxe: Fix handling sleepable in rxe_pool.c Bob Pearson
2023-07-31 18:08   ` Jason Gunthorpe
2023-07-21 20:50 ` [PATCH for-next 2/9] RDMA/rxe: Fix xarray locking " Bob Pearson
2023-07-21 20:50 ` [PATCH for-next 3/9] RDMA/rxe: Fix freeing busy objects Bob Pearson
2023-07-31 18:11   ` Jason Gunthorpe
2023-07-31 18:16     ` Bob Pearson
2023-07-31 18:22       ` Jason Gunthorpe
2023-07-21 20:50 ` [PATCH for-next 4/9] RDMA/rxe: Fix delayed send packet handling Bob Pearson
2023-07-23 13:03   ` Zhu Yanjun
2023-07-23 17:24     ` Bob Pearson
2023-07-24 17:59     ` Leon Romanovsky
2023-07-24 18:26       ` Bob Pearson
2023-07-31 18:12   ` Jason Gunthorpe
2023-07-31 18:20     ` Bob Pearson
2023-07-31 18:23       ` Jason Gunthorpe
2023-07-31 18:33         ` Bob Pearson
2023-08-04 14:17           ` Jason Gunthorpe
2023-07-21 20:50 ` [PATCH for-next 5/9] RDMA/rxe: Optimize rxe_init_packet in rxe_net.c Bob Pearson
2023-07-21 20:50 ` [PATCH for-next 6/9] RDMA/rxe: Delete unused field elem->list Bob Pearson
2023-07-21 20:50 ` [PATCH for-next 7/9] RDMA/rxe: Add elem->valid field Bob Pearson
2023-07-31 18:15   ` Jason Gunthorpe
2023-07-21 20:50 ` [PATCH for-next 8/9] RDMA/rxe: Report leaked objects Bob Pearson
2023-07-31 18:15   ` Jason Gunthorpe
2023-07-31 18:23     ` Bob Pearson
2023-07-31 18:31       ` Jason Gunthorpe
2023-07-31 18:42         ` Bob Pearson
2023-07-31 18:43           ` Jason Gunthorpe
2023-07-31 18:51             ` Bob Pearson
2023-08-04 14:16               ` Jason Gunthorpe [this message]
2023-07-21 20:50 ` [PATCH for-next 9/9] RDMA/rxe: Protect pending send packets Bob Pearson
2023-07-31 18:17   ` Jason Gunthorpe
2023-07-31 18:26     ` Bob Pearson
2023-07-31 18:32       ` Jason Gunthorpe
2023-07-31 18:44         ` Bob Pearson
2023-08-01 22:56           ` Jason Gunthorpe
2023-08-02 14:39             ` Bob Pearson
2023-08-02 14:57               ` 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=ZM0IP/3QtXG6Dtrx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).