libata: optimize the ncq tag search
PATCH 1/1 libata: optimize the ncq tag search
the bitop API should be a little faster than the loop.
Signed-off-by Shaohua Li <[email protected]>
--- drivers/ata/libata-core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/ata/libata-core.c +5 -1
@@ -4842,11 +4842,15 @@ static struct ata_queued_cmd *ata_qc_newreturn 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;