From: Jason Gunthorpe <jgg@ziepe.ca>
To: Zhu Yanjun <yanjun.zhu@linux.dev>
Cc: leon@kernel.org, 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: Tue, 4 Nov 2025 09:00:01 -0400 [thread overview]
Message-ID: <20251104130001.GI1204670@ziepe.ca> (raw)
In-Reply-To: <20251104020845.254870-1-yanjun.zhu@linux.dev>
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);
+
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);
next prev parent reply other threads:[~2025-11-04 13:00 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 [this message]
2025-11-04 15:39 ` Zhu Yanjun
2025-11-05 13:02 ` Leon Romanovsky
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=20251104130001.GI1204670@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=leon@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).