Commit 43768180 authored by Jens Axboe's avatar Jens Axboe Committed by Jeff Garzik

[libata] get rid of ATA_MAX_QUEUE loop in ata_qc_complete_multiple() v2

We very rarely (if ever) complete more than one command in the
sactive mask at the time, even for extremely high IO rates. So
looping over the entire range of possible tags is pointless,
instead use __ffs() to just find the completed tags directly.

Updated to clear the tag from the done_mask instead of shifting
done_mask down as suggested by From: Tejun Heo <htejun@gmail.com>
Verified with a user space tester to produce the same results.
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 31f80112
...@@ -5031,7 +5031,6 @@ int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active) ...@@ -5031,7 +5031,6 @@ int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active)
{ {
int nr_done = 0; int nr_done = 0;
u32 done_mask; u32 done_mask;
int i;
done_mask = ap->qc_active ^ qc_active; done_mask = ap->qc_active ^ qc_active;
...@@ -5041,16 +5040,16 @@ int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active) ...@@ -5041,16 +5040,16 @@ int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active)
return -EINVAL; return -EINVAL;
} }
for (i = 0; i < ATA_MAX_QUEUE; i++) { while (done_mask) {
struct ata_queued_cmd *qc; struct ata_queued_cmd *qc;
unsigned int tag = __ffs(done_mask);
if (!(done_mask & (1 << i))) qc = ata_qc_from_tag(ap, tag);
continue; if (qc) {
if ((qc = ata_qc_from_tag(ap, i))) {
ata_qc_complete(qc); ata_qc_complete(qc);
nr_done++; nr_done++;
} }
done_mask &= ~(1 << tag);
} }
return nr_done; return nr_done;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment