All of lore.kernel.org
 help / color / mirror / Atom feed
* ibata: get rid of ATA_MAX_QUEUE loop in ata_qc_complete_multiple() v2
@ 2009-05-20  7:44 Jens Axboe
  2009-05-20  7:46 ` Tejun Heo
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jens Axboe @ 2009-05-20  7:44 UTC (permalink / raw)
  To: linux-ide; +Cc: htejun, jeff

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: Jens Axboe <jens.axboe@oracle.com>
---
 drivers/ata/libata-core.c |   11 +++++------
 1 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index c924230..ca4d208 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5031,7 +5031,6 @@ int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active)
 {
 	int nr_done = 0;
 	u32 done_mask;
-	int i;
 
 	done_mask = ap->qc_active ^ qc_active;
 
@@ -5041,16 +5040,16 @@ int ata_qc_complete_multiple(struct ata_port *ap, u32 qc_active)
 		return -EINVAL;
 	}
 
-	for (i = 0; i < ATA_MAX_QUEUE; i++) {
+	while (done_mask) {
 		struct ata_queued_cmd *qc;
+		unsigned int tag = __ffs(done_mask);
 
-		if (!(done_mask & (1 << i)))
-			continue;
-
-		if ((qc = ata_qc_from_tag(ap, i))) {
+		qc = ata_qc_from_tag(ap, tag);
+		if (qc) {
 			ata_qc_complete(qc);
 			nr_done++;
 		}
+		done_mask &= ~(1 << tag);
 	}
 
 	return nr_done;
-- 
1.6.3.rc0.1.gf800

-- 
Jens Axboe


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

* Re: ibata: get rid of ATA_MAX_QUEUE loop in ata_qc_complete_multiple() v2
  2009-05-20  7:44 ibata: get rid of ATA_MAX_QUEUE loop in ata_qc_complete_multiple() v2 Jens Axboe
@ 2009-05-20  7:46 ` Tejun Heo
  2009-05-20  7:49 ` Jeff Garzik
  2009-05-20 20:11 ` Jeff Garzik
  2 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2009-05-20  7:46 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-ide, jeff

Jens Axboe wrote:
> 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: Jens Axboe <jens.axboe@oracle.com>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

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

* Re: ibata: get rid of ATA_MAX_QUEUE loop in ata_qc_complete_multiple() v2
  2009-05-20  7:44 ibata: get rid of ATA_MAX_QUEUE loop in ata_qc_complete_multiple() v2 Jens Axboe
  2009-05-20  7:46 ` Tejun Heo
@ 2009-05-20  7:49 ` Jeff Garzik
  2009-05-20  7:58   ` Jens Axboe
  2009-05-20 20:11 ` Jeff Garzik
  2 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2009-05-20  7:49 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-ide, htejun

Jens Axboe wrote:
> 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: Jens Axboe <jens.axboe@oracle.com>
> ---
>  drivers/ata/libata-core.c |   11 +++++------
>  1 files changed, 5 insertions(+), 6 deletions(-)

Much cleaner.  Queued...

Separately, I wonder if we shouldn't add code to report when the 
hardware gives us an unknown tag.

The code always correctly handles invalid tags passed to us from 
hardware "if (qc)", but we should probably squawk when that happens, I 
suspect.

	Jeff




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

* Re: ibata: get rid of ATA_MAX_QUEUE loop in ata_qc_complete_multiple()  v2
  2009-05-20  7:49 ` Jeff Garzik
@ 2009-05-20  7:58   ` Jens Axboe
  0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2009-05-20  7:58 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-ide, htejun

On Wed, May 20 2009, Jeff Garzik wrote:
> Jens Axboe wrote:
>> 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: Jens Axboe <jens.axboe@oracle.com>
>> ---
>>  drivers/ata/libata-core.c |   11 +++++------
>>  1 files changed, 5 insertions(+), 6 deletions(-)
>
> Much cleaner.  Queued...

Thanks!

> Separately, I wonder if we shouldn't add code to report when the  
> hardware gives us an unknown tag.
>
> The code always correctly handles invalid tags passed to us from  
> hardware "if (qc)", but we should probably squawk when that happens, I  
> suspect.

Probably a good idea, it is a sign of bigger problems if the hardware
completes tags that we don't know about.

-- 
Jens Axboe


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

* Re: ibata: get rid of ATA_MAX_QUEUE loop in ata_qc_complete_multiple() v2
  2009-05-20  7:44 ibata: get rid of ATA_MAX_QUEUE loop in ata_qc_complete_multiple() v2 Jens Axboe
  2009-05-20  7:46 ` Tejun Heo
  2009-05-20  7:49 ` Jeff Garzik
@ 2009-05-20 20:11 ` Jeff Garzik
  2 siblings, 0 replies; 5+ messages in thread
From: Jeff Garzik @ 2009-05-20 20:11 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-ide, htejun

Jens Axboe wrote:
> 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: Jens Axboe <jens.axboe@oracle.com>
> ---
>  drivers/ata/libata-core.c |   11 +++++------
>  1 files changed, 5 insertions(+), 6 deletions(-)

applied



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

end of thread, other threads:[~2009-05-20 20:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-20  7:44 ibata: get rid of ATA_MAX_QUEUE loop in ata_qc_complete_multiple() v2 Jens Axboe
2009-05-20  7:46 ` Tejun Heo
2009-05-20  7:49 ` Jeff Garzik
2009-05-20  7:58   ` Jens Axboe
2009-05-20 20:11 ` Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.