linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Leon Romanovsky <leon@kernel.org>
Cc: Abhijit Gangurde <abhijit.gangurde@amd.com>,
	shannon.nelson@amd.com, brett.creeley@amd.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, corbet@lwn.net, andrew+netdev@lunn.ch,
	allen.hubbe@amd.com, nikhil.agarwal@amd.com,
	linux-rdma@vger.kernel.org, netdev@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrew Boyer <andrew.boyer@amd.com>
Subject: Re: [PATCH v3 10/14] RDMA/ionic: Register device ops for control path
Date: Tue, 15 Jul 2025 16:16:29 -0300	[thread overview]
Message-ID: <20250715191629.GA2116306@ziepe.ca> (raw)
In-Reply-To: <20250713062753.GA5882@unreal>

On Sun, Jul 13, 2025 at 09:27:53AM +0300, Leon Romanovsky wrote:
> Let's do what all other drivers do, please. I prefer simplest solution
> and objects that can potentially be around after verbs objects were
> cleaned doesn't sound right.

I think it is OK, at least QP makes sense and matches some other
drivers.

+static void ionic_qp_event(struct ionic_ibdev *dev, u32 qpid, u8 code)
+{
+       struct ib_event ibev;
+       struct ionic_qp *qp;
+
+       rcu_read_lock();
+       qp = xa_load(&dev->qp_tbl, qpid);
+       if (qp)
+               kref_get(&qp->qp_kref);
+       rcu_read_unlock();
+

The above is an async event path, and the kref is effectively the open
coded rwlock pattern we use often.

The unlock triggers a completion:

+       kref_put(&qp->qp_kref, ionic_qp_complete);
+static inline void ionic_qp_complete(struct kref *kref)
+{
+       struct ionic_qp *qp = container_of(kref, struct ionic_qp, qp_kref);
+       
+       complete(&qp->qp_rel_comp);
+}

Which acts as the unlock. And then qp destruction:

+int ionic_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata)
+{
+       kref_put(&qp->qp_kref, ionic_qp_complete);
+       wait_for_completion(&qp->qp_rel_comp);

Which is the typical "write" side of the lock.

So this is all normal, the qp doesn't outlive destroy, destroy waits
for all the async event deliver to complete. It has to, we free the
underlying memory in the core code.

As long as the other case are like this it is fine

+       xa_erase_irq(&dev->qp_tbl, qp->qpid);
+       synchronize_rcu();

This should go away though, don't like to see synchronize_rcu(). The
idea is you kfree the QP with RCU. But the core code doesn't do that..

So in the short term you should take the lock instead of using rcu:

       xa_lock(&dev->qp_tbl);
       qp = xa_load(&dev->qp_tbl, qpid);
       if (qp)
               kref_get(&qp->qp_kref);

Jason

  reply	other threads:[~2025-07-15 19:16 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-24 12:13 [PATCH v3 00/14] Introduce AMD Pensando RDMA driver Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 01/14] net: ionic: Create an auxiliary device for rdma driver Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 02/14] net: ionic: Update LIF identity with additional RDMA capabilities Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 03/14] net: ionic: Export the APIs from net driver to support device commands Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 04/14] net: ionic: Provide RDMA reset support for the RDMA driver Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 05/14] net: ionic: Provide interrupt allocation " Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 06/14] net: ionic: Provide doorbell and CMB region information Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 07/14] RDMA: Add IONIC to rdma_driver_id definition Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 08/14] RDMA/ionic: Register auxiliary module for ionic ethernet adapter Abhijit Gangurde
2025-06-26  7:26   ` Leon Romanovsky
2025-06-27 10:18     ` Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 09/14] RDMA/ionic: Create device queues to support admin operations Abhijit Gangurde
2025-07-01 10:24   ` Leon Romanovsky
2025-07-03  6:59     ` Abhijit Gangurde
2025-07-03  8:41       ` Leon Romanovsky
2025-07-04 10:45         ` Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 10/14] RDMA/ionic: Register device ops for control path Abhijit Gangurde
2025-07-01 10:38   ` Leon Romanovsky
2025-07-02 13:18     ` Jason Gunthorpe
2025-07-02 18:00       ` Leon Romanovsky
2025-07-03  7:19         ` Abhijit Gangurde
2025-07-04 17:08           ` Leon Romanovsky
2025-07-07  5:27             ` Abhijit Gangurde
2025-07-07  7:21               ` Leon Romanovsky
2025-07-07 14:56                 ` Abhijit Gangurde
2025-07-07 16:46                   ` Leon Romanovsky
2025-07-08 10:05                     ` Abhijit Gangurde
2025-07-13  6:27                       ` Leon Romanovsky
2025-07-15 19:16                         ` Jason Gunthorpe [this message]
2025-07-20  8:39                           ` Abhijit Gangurde
2025-07-03  7:00     ` Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 11/14] RDMA/ionic: Register device ops for datapath Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 12/14] RDMA/ionic: Register device ops for miscellaneous functionality Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 13/14] RDMA/ionic: Implement device stats ops Abhijit Gangurde
2025-06-24 12:13 ` [PATCH v3 14/14] RDMA/ionic: Add Makefile/Kconfig to kernel build environment Abhijit Gangurde
2025-06-25 21:44 ` [PATCH v3 00/14] Introduce AMD Pensando RDMA driver Jakub Kicinski
2025-06-26  7:07 ` Leon Romanovsky
2025-06-27 10:06   ` Abhijit Gangurde

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=20250715191629.GA2116306@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=abhijit.gangurde@amd.com \
    --cc=allen.hubbe@amd.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew.boyer@amd.com \
    --cc=brett.creeley@amd.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikhil.agarwal@amd.com \
    --cc=pabeni@redhat.com \
    --cc=shannon.nelson@amd.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).