public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Zhu Yanjun <yanjun.zhu@linux.dev>,
	linux-rdma@vger.kernel.org,
	syzbot+b0da83a6c0e2e2bddbd4@syzkaller.appspotmail.com
Subject: Re: [PATCH rdma-next 1/1] RDMA/core: Fix WARNING in gid_table_release_one
Date: Wed, 5 Nov 2025 15:02:05 +0200	[thread overview]
Message-ID: <20251105130205.GD16832@unreal> (raw)
In-Reply-To: <20251104130001.GI1204670@ziepe.ca>

On Tue, Nov 04, 2025 at 09:00:01AM -0400, Jason Gunthorpe wrote:
> On Mon, Nov 03, 2025 at 06:08:45PM -0800, Zhu Yanjun wrote:
> > @@ -800,13 +800,24 @@ static void release_gid_table(struct ib_device *device,
> >  		return;
> >  
> >  	for (i = 0; i < table->sz; i++) {
> > +		int cnt = 200;
> > +
> >  		if (is_gid_entry_free(table->data_vec[i]))
> >  			continue;
> >  
> > -		WARN_ONCE(true,
> > -			  "GID entry ref leak for dev %s index %d ref=%u\n",
> > +		WARN_ONCE(table->data_vec[i]->state != GID_TABLE_ENTRY_PENDING_DEL,
> > +			  "GID entry ref leak for dev %s index %d ref=%u, state: %d\n",
> >  			  dev_name(&device->dev), i,
> > -			  kref_read(&table->data_vec[i]->kref));
> > +			  kref_read(&table->data_vec[i]->kref), table->data_vec[i]->state);
> > +
> > +		while ((kref_read(&table->data_vec[i]->kref) > 0) && (cnt > 0)) {
> > +			cnt--;
> > +			msleep(10);
> > +		}
> 
> Definately don't want to see this looping.
> 
> If it is waiting for the work queue then maybe this should flush the
> work queue.
> 
> Something like this?
> 
> --- a/drivers/infiniband/core/cache.c
> +++ b/drivers/infiniband/core/cache.c
> @@ -799,7 +799,19 @@ static void release_gid_table(struct ib_device *device,
>         if (!table)
>                 return;
>  
> +       mutex_lock(&table->lock);
>         for (i = 0; i < table->sz; i++) {
> +               if (is_gid_entry_free(table->data_vec[i]))
> +                       continue;
> +
> +               /*
> +                * The entry may be sitting in the WQ waiting for
> +                * free_gid_work(), flush it to try to clean it.
> +                */
> +               mutex_unlock(&table->lock);
> +               flush_workqueue(ib_wq);
> +               mutex_lock(&table->lock);

I don't think that this is right thing to do. If you want, you can call
to flush_workqueue(ib_wq) in ib_cache_release_one().

Thanks



> +
>                 if (is_gid_entry_free(table->data_vec[i]))
>                         continue;
>  
> @@ -808,6 +820,7 @@ static void release_gid_table(struct ib_device *device,
>                           dev_name(&device->dev), i,
>                           kref_read(&table->data_vec[i]->kref));
>         }
> +       mutex_unlock(&table->lock);
>  
>         mutex_destroy(&table->lock);
>         kfree(table->data_vec);
> 
> 
> 

      parent reply	other threads:[~2025-11-05 13:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-04  2:08 [PATCH rdma-next 1/1] RDMA/core: Fix WARNING in gid_table_release_one Zhu Yanjun
2025-11-04 13:00 ` Jason Gunthorpe
2025-11-04 15:39   ` Zhu Yanjun
2025-11-05 13:02   ` Leon Romanovsky [this message]

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=20251105130205.GD16832@unreal \
    --to=leon@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=linux-rdma@vger.kernel.org \
    --cc=syzbot+b0da83a6c0e2e2bddbd4@syzkaller.appspotmail.com \
    --cc=yanjun.zhu@linux.dev \
    /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