mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] scsi: target: alua: Skip grace periods on LUN add and remove
@ 2026-11-10 13:29 Qiliang Yuan
  2026-11-10 13:29 ` [PATCH 1/2] scsi: target: alua: Don't wait for a grace period when attaching a LUN Qiliang Yuan
  2026-11-10 13:29 ` [PATCH 2/2] scsi: target: alua: Drop the grace period wait from LUN detach Qiliang Yuan
  0 siblings, 2 replies; 3+ messages in thread
From: Qiliang Yuan @ 2026-11-10 13:29 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Mike Christie, linux-scsi, target-devel, linux-kernel, Qiliang Yuan

Creating or removing a LUN through configfs attaches it to, or detaches
it from, its ALUA target port group, and both helpers wait for an RCU
grace period afterwards.

Neither wait protects anything, yet each costs one grace period per
LUN, which adds up to seconds when exporting or tearing down many LUNs,
e.g. when targetcli restores a saved configuration.

Drop the wait on attach (patch 1) and on detach (patch 2).

Adding and removing 256 LUNs of an iSCSI TPG through configfs, five
rounds alternating with and without the series, takes (median, min-max
in parentheses):

  256 LUNs  before (ms)       after (ms)        change
  add       3144 (3104-3175)  1379 (1277-1393)    -56%
  remove    5222 (5165-5244)  3551 (3436-3810)    -32%

Signed-off-by: Qiliang Yuan <qiliang.yuan@linux.dev>
---
Qiliang Yuan (2):
      scsi: target: alua: Don't wait for a grace period when attaching a LUN
      scsi: target: alua: Drop the grace period wait from LUN detach

 drivers/target/target_core_alua.c | 2 --
 1 file changed, 2 deletions(-)
---
base-commit: b3dfbde62cf1981c4638939c159dfd087b7a72e9
change-id: 20261110-bug-target-alua-lun-gp-b410ef8d1144

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] scsi: target: alua: Don't wait for a grace period when attaching a LUN
  2026-11-10 13:29 [PATCH 0/2] scsi: target: alua: Skip grace periods on LUN add and remove Qiliang Yuan
@ 2026-11-10 13:29 ` Qiliang Yuan
  2026-11-10 13:29 ` [PATCH 2/2] scsi: target: alua: Drop the grace period wait from LUN detach Qiliang Yuan
  1 sibling, 0 replies; 3+ messages in thread
From: Qiliang Yuan @ 2026-11-10 13:29 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Mike Christie, linux-scsi, target-devel, linux-kernel, Qiliang Yuan

core_tpg_add_lun() attaches a new LUN to the default ALUA target port
group before adding it to the device and TPG lists, and
target_attach_tg_pt_gp() then waits for an RCU grace period.

The wait protects nothing: lun->lun_tg_pt_gp goes from NULL to a live
group, nothing is freed, and no reader can reach the LUN yet. It still
costs a grace period for every LUN created through configfs, which
dominates the time spent exporting many LUNs.

Remove the synchronize_rcu() call. Group changes through
core_alua_store_tg_pt_gp_info() keep their own grace period.

Adding 256 LUNs to an iSCSI TPG through configfs, five rounds
alternating with and without this patch, takes (median, min-max in
parentheses):

  LUNs  before (ms)       after (ms)        change
   256  3144 (3104-3175)  1379 (1277-1393)    -56%

Signed-off-by: Qiliang Yuan <qiliang.yuan@linux.dev>
---
 drivers/target/target_core_alua.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 140154d93c430..35d36cd36db6c 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -1833,7 +1833,6 @@ void target_attach_tg_pt_gp(struct se_lun *lun,
 	spin_lock(&lun->lun_tg_pt_gp_lock);
 	__target_attach_tg_pt_gp(lun, tg_pt_gp);
 	spin_unlock(&lun->lun_tg_pt_gp_lock);
-	synchronize_rcu();
 }
 
 static void __target_detach_tg_pt_gp(struct se_lun *lun,

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] scsi: target: alua: Drop the grace period wait from LUN detach
  2026-11-10 13:29 [PATCH 0/2] scsi: target: alua: Skip grace periods on LUN add and remove Qiliang Yuan
  2026-11-10 13:29 ` [PATCH 1/2] scsi: target: alua: Don't wait for a grace period when attaching a LUN Qiliang Yuan
@ 2026-11-10 13:29 ` Qiliang Yuan
  1 sibling, 0 replies; 3+ messages in thread
From: Qiliang Yuan @ 2026-11-10 13:29 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Mike Christie, linux-scsi, target-devel, linux-kernel, Qiliang Yuan

core_tpg_remove_lun() detaches a LUN from its ALUA target port group
once transport_clear_lun_ref() has drained its I/O, and
target_detach_tg_pt_gp() then waits for an RCU grace period.

Nothing that wait could protect is freed here: the group lives on until
core_alua_free_tg_pt_gp(), which waits for a grace period of its own
before freeing it, and the se_lun is freed with call_rcu(). Every LUN
removed through configfs still pays a grace period for it.

Remove the synchronize_rcu() call.

Removing 256 LUNs from an iSCSI TPG through configfs, five rounds
alternating with and without this patch, takes (median, min-max in
parentheses):

  LUNs  before (ms)       after (ms)        change
   256  5222 (5165-5244)  3551 (3436-3810)    -32%

Signed-off-by: Qiliang Yuan <qiliang.yuan@linux.dev>
---
 drivers/target/target_core_alua.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
index 35d36cd36db6c..4e22f988bb83f 100644
--- a/drivers/target/target_core_alua.c
+++ b/drivers/target/target_core_alua.c
@@ -1858,7 +1858,6 @@ void target_detach_tg_pt_gp(struct se_lun *lun)
 		rcu_assign_pointer(lun->lun_tg_pt_gp, NULL);
 	}
 	spin_unlock(&lun->lun_tg_pt_gp_lock);
-	synchronize_rcu();
 }
 
 static void target_swap_tg_pt_gp(struct se_lun *lun,

-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-10 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10 13:29 [PATCH 0/2] scsi: target: alua: Skip grace periods on LUN add and remove Qiliang Yuan
2026-11-10 13:29 ` [PATCH 1/2] scsi: target: alua: Don't wait for a grace period when attaching a LUN Qiliang Yuan
2026-11-10 13:29 ` [PATCH 2/2] scsi: target: alua: Drop the grace period wait from LUN detach Qiliang Yuan

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®