Skip to contentSkip to conversation

scsi_remove_target: fix softlockup regression on hot remove

PATCH RESEND In review Dan Williams 4 participants 6 messages Aug 29, 2012 – Sep 4, 2012 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 scsi_remove_target: fix softlockup regression on hot remove

John reports:

 BUG: soft lockup - CPU#2 stuck for 23s! [kworker/u:8:2202]
 [..]
 Call Trace:
  [<ffffffff8141782a>] scsi_remove_target+0xda/0x1f0
  [<ffffffff81421de5>] sas_rphy_remove+0x55/0x60
  [<ffffffff81421e01>] sas_rphy_delete+0x11/0x20
  [<ffffffff81421e35>] sas_port_delete+0x25/0x160
  [<ffffffff814549a3>] mptsas_del_end_device+0x183/0x270

...introduced by commit 3b661a9 "[SCSI] fix hot unplug vs async scan race".

Don't restart lookup of more stargets in the multi-target case, just arrange to traverse the list once, on the assumption that new targets are always added at the end. There is no guarantee that the target will change state in scsi_target_reap() so we can end up spinning if we restart.

LKML-Reference: <CAEhu1-6wq1YsNiscGMwP4ud0Q+MrViRzv=kcWCQSBNc8c68N5Q@mail.gmail.com>

---

Jack, thanks for the reminder to cc stable!

 drivers/scsi/scsi_sysfs.c |   30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)
drivers/scsi/scsi_sysfs.c +14 -16
index 093d4f6..ce5224c 100644
@@ -1031,33 +1031,31 @@ static void __scsi_remove_target(struct scsi_target *starget)
 void scsi_remove_target(struct device *dev)
 {
 	struct Scsi_Host *shost = dev_to_shost(dev->parent);
-	struct scsi_target *starget, *found;
+	struct scsi_target *starget, *last = NULL;
 	unsigned long flags;
 
- restart:
-	found = NULL;
+	/* remove targets being careful to lookup next entry before
+	 * deleting the last
+	 */
 	spin_lock_irqsave(shost->host_lock, flags);
 	list_for_each_entry(starget, &shost->__targets, siblings) {
 		if (starget->state == STARGET_DEL)
 			continue;
 		if (starget->dev.parent == dev || &starget->dev == dev) {
-			found = starget;
-			found->reap_ref++;
-			break;
+			/* assuming new targets arrive at the end */
+			starget->reap_ref++;
+			spin_unlock_irqrestore(shost->host_lock, flags);
+			if (last)
+				scsi_target_reap(last);
+			last = starget;
+			__scsi_remove_target(starget);
+			spin_lock_irqsave(shost->host_lock, flags);
 		}
 	}
 	spin_unlock_irqrestore(shost->host_lock, flags);
 
-	if (found) {
-		__scsi_remove_target(found);
-		scsi_target_reap(found);
-		/* in the case where @dev has multiple starget children,
-		 * continue removing.
-		 *
-		 * FIXME: does such a case exist?
-		 */
-		goto restart;
-	}
+	if (last)
+		scsi_target_reap(last);
 }
 EXPORT_SYMBOL(scsi_remove_target);
 
#1 lore raw
Quoted 11 lines · Dan Williams

John reports:

 BUG: soft lockup - CPU#2 stuck for 23s! [kworker/u:8:2202]
 [..]
 Call Trace:
  [<ffffffff8141782a>] scsi_remove_target+0xda/0x1f0
  [<ffffffff81421de5>] sas_rphy_remove+0x55/0x60
  [<ffffffff81421e01>] sas_rphy_delete+0x11/0x20
  [<ffffffff81421e35>] sas_port_delete+0x25/0x160
  [<ffffffff814549a3>] mptsas_del_end_device+0x183/0x270

...introduced by commit 3b661a9 "[SCSI] fix hot unplug vs async scan race".

Including that call stack in the patch description may create the misleading impression that this only occurs with the mptsas driver. This lockup also happens with at least the iSCSI initiator. See also
http://lkml.org/lkml/2012/8/24/340.

By the way, in order to get a patch in the stable tree the proper "Cc:" tag should be added in the patch description but the [email protected] e-mail address should be left out from the Cc-list of the e-mail with the patch.

Bart.

#2 lore raw
Quoted 11 lines · Bart Van Assche
Quoted 10 lines · Dan Williams

John reports:

 BUG: soft lockup - CPU#2 stuck for 23s! [kworker/u:8:2202]
 [..]
 Call Trace:
  [<ffffffff8141782a>] scsi_remove_target+0xda/0x1f0
  [<ffffffff81421de5>] sas_rphy_remove+0x55/0x60
  [<ffffffff81421e01>] sas_rphy_delete+0x11/0x20
  [<ffffffff81421e35>] sas_port_delete+0x25/0x160
  [<ffffffff814549a3>] mptsas_del_end_device+0x183/0x270
Quoted 6 lines
Quoted 1 line

...introduced by commit 3b661a9 "[SCSI] fix hot unplug vs async scan race".

Including that call stack in the patch description may create the misleading impression that this only occurs with the mptsas driver. This lockup also happens with at least the iSCSI initiator. See also
http://lkml.org/lkml/2012/8/24/340.

I don't think it does that. The title is pretty generic, but you're right the impact is potentially all scsi_remove_target() users.

Quoted 4 lines

By the way, in order to get a patch in the stable tree the proper "Cc:" tag should be added in the patch description but the [email protected] e-mail address should be left out from the Cc-list of the e-mail with the patch.

No, we talked about that at kernel summit. It's ok for the stable@ alias to get a few extra mails. The patch won't be applied until it hits mainline and in the meantime it gives a heads up to the -stable folks, or anyone that wants to follow up on stable patches making their way to mainline.

--
Dan

#3 lore raw
Quoted 27 lines · Dan Williams
Quoted 11 lines · Bart Van Assche
Quoted 10 lines · Dan Williams

John reports:

 BUG: soft lockup - CPU#2 stuck for 23s! [kworker/u:8:2202]
 [..]
 Call Trace:
  [<ffffffff8141782a>] scsi_remove_target+0xda/0x1f0
  [<ffffffff81421de5>] sas_rphy_remove+0x55/0x60
  [<ffffffff81421e01>] sas_rphy_delete+0x11/0x20
  [<ffffffff81421e35>] sas_port_delete+0x25/0x160
  [<ffffffff814549a3>] mptsas_del_end_device+0x183/0x270
Quoted 6 lines
Quoted 1 line

...introduced by commit 3b661a9 "[SCSI] fix hot unplug vs async scan race".

Including that call stack in the patch description may create the misleading impression that this only occurs with the mptsas driver. This lockup also happens with at least the iSCSI initiator. See also
http://lkml.org/lkml/2012/8/24/340.

I don't think it does that. The title is pretty generic, but you're right the impact is potentially all scsi_remove_target() users.

Quoted 4 lines

By the way, in order to get a patch in the stable tree the proper "Cc:" tag should be added in the patch description but the [email protected] e-mail address should be left out from the Cc-list of the e-mail with the patch.

Quoted 6 lines

No, we talked about that at kernel summit. It's ok for the stable@ alias to get a few extra mails. The patch won't be applied until it hits mainline and in the meantime it gives a heads up to the -stable folks, or anyone that wants to follow up on stable patches making their way to mainline.

It appears that this did not get into 3.6 rc4 (unless I am reading the changlog wrong). Do I have to file an official bug report to get this noticed?

John

#4 lore raw
Quoted 35 lines · John Drescher
Quoted 27 lines · Dan Williams
Quoted 11 lines · Bart Van Assche
Quoted 10 lines · Dan Williams

John reports:

 BUG: soft lockup - CPU#2 stuck for 23s! [kworker/u:8:2202]
 [..]
 Call Trace:
  [<ffffffff8141782a>] scsi_remove_target+0xda/0x1f0
  [<ffffffff81421de5>] sas_rphy_remove+0x55/0x60
  [<ffffffff81421e01>] sas_rphy_delete+0x11/0x20
  [<ffffffff81421e35>] sas_port_delete+0x25/0x160
  [<ffffffff814549a3>] mptsas_del_end_device+0x183/0x270
Quoted 6 lines
Quoted 1 line

...introduced by commit 3b661a9 "[SCSI] fix hot unplug vs async scan race".

Including that call stack in the patch description may create the misleading impression that this only occurs with the mptsas driver. This lockup also happens with at least the iSCSI initiator. See also
http://lkml.org/lkml/2012/8/24/340.

I don't think it does that. The title is pretty generic, but you're right the impact is potentially all scsi_remove_target() users.

Quoted 4 lines

By the way, in order to get a patch in the stable tree the proper "Cc:" tag should be added in the patch description but the [email protected] e-mail address should be left out from the Cc-list of the e-mail with the patch.

Quoted 6 lines

No, we talked about that at kernel summit. It's ok for the stable@ alias to get a few extra mails. The patch won't be applied until it hits mainline and in the meantime it gives a heads up to the -stable folks, or anyone that wants to follow up on stable patches making their way to mainline.

Quoted 3 lines

It appears that this did not get into 3.6 rc4 (unless I am reading the changlog wrong). Do I have to file an official bug report to get this noticed?

I know James was travelling last week, and I think he wanted some more time to look over the removal of the restart logic... but I think we are ok. Prior to commit 3b661a9 we had

       get_device(dev);
       device_for_each_child(dev, NULL, __remove_child);
       put_device(dev);

Where that device_for_each_child would not restart, but also would not consider stargets that were not yet proper children of dev. With the fix we find all stargets and make sure to be immune to the regression case where scsi_remove_target() is not the final source of scsi_target_reap().

--
Dan

#5 lore raw
In reply to Dan Williams
Quoted 11 lines · Dan Williams <djbw <at> fb.com> writes:

John reports:

 BUG: soft lockup - CPU#2 stuck for 23s! [kworker/u:8:2202]
 [..]

...introduced by commit 3b661a9 "[SCSI] fix hot unplug vs async scan race".

Don't restart lookup of more stargets in the multi-target case, just arrange to traverse the list once, on the assumption that new targets are always added at the end. There is no guarantee that the target will change state in scsi_target_reap() so we can end up spinning if we restart.

Patch works for me.

See also <https://bugzilla.redhat.com/show_bug.cgi?id=848425> for "hardware-less" reproduction instructions.