Skip to content

Prevent non-NCQ command starvation

Damien Le Moal linux-ide 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest2 patches 8 repliesIn review
  2. v42 patches 1 replySuperseded
  3. v32 patches 15 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v22 patches3 repliesSuperseded
v12 patches4 repliesSuperseded

Changes in v5 from the cover letter

- Changed patch 1 refactoring to create the helper function ata_scsi_qc_issue() to handle both deferral and issuing of commands, instead of the formet ata_scsi_qc_defer(9 helper which was handling only command deferral. this simplifies patch 2 by avoiding needing modifications in ata_scsi_translate()

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2ata: libata-scsi: refactor ata_scsi_translate()drivers/ata/libata-scsi.c+50 -313 replies
2/2ata: libata-scsi: avoid Non-NCQ command starvationdrivers/ata/libata-core.c drivers/ata/libata-eh.c drivers/ata/libata-scsi.c +2 more+105 -04 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchNiklas CasselMartin K. PetersenJohn GarryIgor PylypivXingui Yang
SeriesR-b
1/2R-b R-b R-b
2/2R-b R-b T-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v5 thread

Cover letter [PATCH v5 0/2] Prevent non-NCQ command starvation

This small patch series addresses potential command starvation issues with non-NCQ commands issued to a device accessed through a multi-queue libsas HBA. In such setup, a non-NCQ command issued to a device may suffer long delays and even complete starvation if the device is under a constant workload of NCQ commands issued from multiple queues.

This issue is avoided by limiting requeing request through the block layer and instead explicitly waiting for the device command queue to drain before issuing the non-NCQ command. This is done reliably by not trying to second guess ata EH in case of error or device reset, by always requeuing a deferred command whenever EH is scheduled for the device port.

When a non-ncq command is deferred waiting for the device queue to drain, all new incoming commands are always requeued through the regular busy mechanism, thus avoiding the need to manage an internal command queue.

With this, the long latencies observed when executing non-NCQ commands under a heavy workload of NCQ commands at high queue depth is resolved:
the non-NCQ command latency only depends on how long it takes for all in-flight NCQ commands to complete.

Changes from v4:
- Changed patch 1 refactoring to create the helper function ata_scsi_qc_issue() to handle both deferral and issuing of commands, instead of the formet ata_scsi_qc_defer(9 helper which was handling only command deferral. this simplifies patch 2 by avoiding needing modifications in ata_scsi_translate()

Changes from v3:
- Added review and test tags
- Improved patch 2 commit message
- Added a comment in ata_scsi_translate() to clarify the handling of ata_scsi_defer() return value.

Changes from v2:
- Improved comment about ata_scsi_qc_new() behavior in patch 1 (suggested by Garry).
- Removed some lockdep annotations from patch 2 as they have little value.
- In patch 2, change ata_scsi_requeue_deferred_qc() and ata_scsi_schedule_deferred_qc() to return early as suggested by Garry.
- Fixed comments typo in patch 2.

Changes from v1:
- Fixed ac leak in ata_scsi_defer() in patch 2.
- Added Hannes review tag

Damien Le Moal (2):
ata: libata-scsi: refactor ata_scsi_translate()
ata: libata-scsi: avoid Non-NCQ command starvation

 drivers/ata/libata-core.c |   5 ++
 drivers/ata/libata-eh.c   |   6 ++
 drivers/ata/libata-scsi.c | 170 +++++++++++++++++++++++++++++++-------
 drivers/ata/libata.h      |   2 +
 include/linux/libata.h    |   3 +
 5 files changed, 155 insertions(+), 31 deletions(-)
Signature · 1 line
2.52.0