[PATCH]libata: optimize the ncq tag search

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



the bitop API should be a little faster than the loop.

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

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;
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux