Patchwork libata: optimize the ncq tag search

login
register
mail settings
Submitter Shaohua Li
Date Sept. 2, 2009, 2:19 a.m.
Message ID <20090902021924.GA23381@sli10-desk.sh.intel.com>
Download mbox | patch
Permalink /patch/32782/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Shaohua Li - Sept. 2, 2009, 2:19 a.m.
the bitop API should be a little faster than the loop.

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
---
 drivers/ata/libata-core.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

Index: linux/drivers/ata/libata-core.c
===================================================================
--- linux.orig/drivers/ata/libata-core.c	2009-09-02 10:06:47.000000000 +0800
+++ linux/drivers/ata/libata-core.c	2009-09-02 10:07:47.000000000 +0800
@@ -4842,11 +4842,15 @@  static struct ata_queued_cmd *ata_qc_new
 		return NULL;
 
 	/* the last tag is reserved for internal command. */
-	for (i = 0; i < ATA_MAX_QUEUE - 1; i++)
+	while (1) {
+		i = find_first_zero_bit(&ap->qc_allocated, ATA_MAX_QUEUE - 1);
+		if (i >= ATA_MAX_QUEUE - 1)
+			break;
 		if (!test_and_set_bit(i, &ap->qc_allocated)) {
 			qc = __ata_qc_from_tag(ap, i);
 			break;
 		}
+	}
 
 	if (qc)
 		qc->tag = i;