mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qiliang Yuan <qiliang.yuan@linux.dev>
To: "Martin K. Petersen" <mkp@kernel.org>
Cc: Mike Christie <michael.christie@oracle.com>,
	linux-scsi@vger.kernel.org,  target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	 Qiliang Yuan <qiliang.yuan@linux.dev>
Subject: [PATCH] scsi: target: alua: Free target port groups with kfree_rcu()
Date: Wed, 11 Nov 2026 08:47:18 -0500	[thread overview]
Message-ID: <20261111-bug-target-alua-free-gp-v1-1-d1e692ae8694@linux.dev> (raw)

core_alua_free_tg_pt_gp() frees a target port group when its configfs
group goes away, including the default group of every device when its
backstore is deleted. Readers of lun->lun_tg_pt_gp may still hold the
group, so it waits for an RCU grace period before freeing it.

The wait is synchronous, so deleting a backstore spends most of its time
in synchronize_rcu(), which adds up when tearing down many of them.

Free the group with kfree_rcu() instead. Nothing else in the function
needs the grace period to have elapsed, and kmem_cache_destroy() waits
for pending kfree_rcu() calls on module unload.

Deleting 256 rd_mcp backstores through configfs, five rounds
alternating with and without this patch, takes (median, min-max in
parentheses):

  backstores  before (ms)       after (ms)     change
         256  2108 (2105-2127)  692 (675-700)    -67%

Signed-off-by: Qiliang Yuan <qiliang.yuan@linux.dev>
---
 drivers/target/target_core_alua.c | 3 +--
 include/target/target_core_base.h | 1 +
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 140154d93c430..4ef243ae843bb 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -1771,8 +1771,7 @@ void core_alua_free_tg_pt_gp(
 	}
 	spin_unlock(&tg_pt_gp->tg_pt_gp_lock);
 
-	synchronize_rcu();
-	kmem_cache_free(t10_alua_tg_pt_gp_cache, tg_pt_gp);
+	kfree_rcu(tg_pt_gp, rcu_head);
 }
 
 static struct t10_alua_tg_pt_gp *core_alua_get_tg_pt_gp_by_name(
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 002b0fc575876..cec29cbec1643 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -331,6 +331,7 @@ struct t10_alua_tg_pt_gp {
 	struct list_head tg_pt_gp_lun_list;
 	struct se_lun *tg_pt_gp_alua_lun;
 	struct se_node_acl *tg_pt_gp_alua_nacl;
+	struct rcu_head rcu_head;
 };
 
 struct t10_vpd {

---
base-commit: b3dfbde62cf1981c4638939c159dfd087b7a72e9
change-id: 20261110-bug-target-alua-free-gp-1465539a269a

Best regards,
-- 
Qiliang Yuan <qiliang.yuan@linux.dev>


                 reply	other threads:[~2026-11-11 13:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261111-bug-target-alua-free-gp-v1-1-d1e692ae8694@linux.dev \
    --to=qiliang.yuan@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=michael.christie@oracle.com \
    --cc=mkp@kernel.org \
    --cc=target-devel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®