Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Yonatan Nachum <ynachum@amazon.com>,
	linux-rdma@vger.kernel.org, mrgolin@amazon.com,
	sleybo@amazon.com, matua@amazon.com, gal.pressman@linux.dev,
	Firas Jahjah <firasj@amazon.com>
Subject: Re: [PATCH for-next v5 2/2] RDMA/efa: Add AH cache handling on create and destroy AH
Date: Mon, 6 Jul 2026 09:23:14 -0300	[thread overview]
Message-ID: <20260706122314.GB71454@nvidia.com> (raw)
In-Reply-To: <20260706122007.GL15188@unreal>

On Mon, Jul 06, 2026 at 03:20:07PM +0300, Leon Romanovsky wrote:
> On Sun, Jul 05, 2026 at 02:08:52PM +0000, Yonatan Nachum wrote:
> > On Sun, Jul 05, 2026 at 04:35:06PM +0300, Leon Romanovsky wrote:
> > > > +/**
> > > > + * efa_ah_cache_put - Put a refcount of an AH cache entry
> > > > + * @ah_cache: AH cache
> > > > + * @entry: AH cache entry
> > > > + *
> > > > + * Drop the refcount. If it reaches zero, remove the entry from the hashtable
> > > > + * and free it.
> > > > + */
> > > > +void efa_ah_cache_put(struct efa_ah_cache *ah_cache, struct efa_ah_cache_entry *entry)
> > > > +{
> > > > +	if (!refcount_dec_and_mutex_lock(&entry->refcount, &ah_cache->lock))
> > > > +		return;
> > > > +
> > > > +	/* AH cache lock is held here */
> > > > +	rhashtable_remove_fast(&ah_cache->hashtable, &entry->linkage, ah_cache_params);
> > > > +	mutex_unlock(&ah_cache->lock);
> > > > +
> > > > +	mutex_destroy(&entry->lock);
> > > > +	kfree_rcu(entry, rcu_head);
> > > 
> > > Where do you use RCU locking in this series? Why do you call
> > > kfree_rcu() instead of kfree()?
> > > 
> > > Thanks
> > 
> > Originally I used kfree directly, but changed to kfree_rcu in v3
> > following this Sashiko review and Jason's comment:
> > https://sashiko.dev/#/patchset/20260512061121.2177521-1-ynachum%40amazon.com
> > 
> > If you think its not needed I can delete it.
> 
> I'm not sure you're using the right data structure for this task.
> 
> An RCU grace period is required to ensure that rhash has been unlinked
> from ah_cache->hashtable, since a concurrent lookup may still succeed in
> finding the deleted entry. 

It doesn't look like this uses RCU for lookup

> The problem is that the refcount has already been decremented to 0,
> and any attempt to increment it will trigger a dmesg splat.

Sashiko claimed this was for some worker thread internal to rhashtable

Jason

  reply	other threads:[~2026-07-06 12:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-28 13:34 [PATCH for-next v5 0/2] RDMA/efa: Add AH cache for AH reuse Yonatan Nachum
2026-06-28 13:34 ` [PATCH for-next v5 1/2] RDMA/efa: Add initialization of AH cache rhashtable Yonatan Nachum
2026-06-28 13:34 ` [PATCH for-next v5 2/2] RDMA/efa: Add AH cache handling on create and destroy AH Yonatan Nachum
2026-07-05 13:35   ` Leon Romanovsky
2026-07-05 14:08     ` Yonatan Nachum
2026-07-06 12:20       ` Leon Romanovsky
2026-07-06 12:23         ` Jason Gunthorpe [this message]
2026-07-06 13:28           ` Yonatan Nachum

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=20260706122314.GB71454@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=firasj@amazon.com \
    --cc=gal.pressman@linux.dev \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=matua@amazon.com \
    --cc=mrgolin@amazon.com \
    --cc=sleybo@amazon.com \
    --cc=ynachum@amazon.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