Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Yonatan Nachum <ynachum@amazon.com>
Cc: jgg@nvidia.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: Sun, 5 Jul 2026 16:35:06 +0300	[thread overview]
Message-ID: <20260705133506.GF15188@unreal> (raw)
In-Reply-To: <20260628133422.523230-3-ynachum@amazon.com>

On Sun, Jun 28, 2026 at 01:34:22PM +0000, Yonatan Nachum wrote:
> On create AH, first check if the AH cache entry already exists and if
> so, returns the already stored AH number. If the entry doesn't exist,
> the driver creates it and calls the device to create the AH. A per-entry
> mutex serializes concurrent device commands on the same AH cache entry,
> ensuring only one thread issues the device create while others wait and
> reuse the result. If the device create fails, the entry's user count
> remains zero so subsequent threads will retry the device create.
> 
> On destroy AH, the user count is decremented under the entry mutex. If
> it reaches zero, the driver issues the device destroy command. After
> the device destroy completes, it removes the entry from the hashtable
> and frees it if no other references exist.  If new users arrived during
> the destroy, the entry remains in the hashtable for reuse.
> 
> Reviewed-by: Firas Jahjah <firasj@amazon.com>
> Reviewed-by: Michael Margolin <mrgolin@amazon.com>
> Signed-off-by: Yonatan Nachum <ynachum@amazon.com>
> ---
>  drivers/infiniband/hw/efa/efa_ah_cache.c | 94 ++++++++++++++++++++++++
>  drivers/infiniband/hw/efa/efa_ah_cache.h |  3 +
>  drivers/infiniband/hw/efa/efa_com_cmd.c  | 41 ++++++++++-
>  drivers/infiniband/hw/efa/efa_com_cmd.h  |  1 +
>  drivers/infiniband/hw/efa/efa_verbs.c    |  9 ++-
>  5 files changed, 140 insertions(+), 8 deletions(-)

<...>

> +/**
> + * 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

  reply	other threads:[~2026-07-05 13:35 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 [this message]
2026-07-05 14:08     ` Yonatan Nachum
2026-07-06 12:20       ` Leon Romanovsky
2026-07-06 12:23         ` Jason Gunthorpe
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=20260705133506.GF15188@unreal \
    --to=leon@kernel.org \
    --cc=firasj@amazon.com \
    --cc=gal.pressman@linux.dev \
    --cc=jgg@nvidia.com \
    --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