From patchwork Wed Sep 2 02:19:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaohua Li X-Patchwork-Id: 32782 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by bilbo.ozlabs.org (Postfix) with ESMTP id 46FB8B7BBB for ; Wed, 2 Sep 2009 12:19:37 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751425AbZIBCTc (ORCPT ); Tue, 1 Sep 2009 22:19:32 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751841AbZIBCTc (ORCPT ); Tue, 1 Sep 2009 22:19:32 -0400 Received: from mga01.intel.com ([192.55.52.88]:51056 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751425AbZIBCTc (ORCPT ); Tue, 1 Sep 2009 22:19:32 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 01 Sep 2009 19:16:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.44,315,1249282800"; d="scan'208";a="723067961" Received: from sli10-conroe.sh.intel.com (HELO sli10-desk.sh.intel.com) ([10.239.13.175]) by fmsmga001.fm.intel.com with ESMTP; 01 Sep 2009 19:22:28 -0700 Received: from david by sli10-desk.sh.intel.com with local (Exim 4.69) (envelope-from ) id 1MifRU-0006XT-LW; Wed, 02 Sep 2009 10:19:24 +0800 Date: Wed, 2 Sep 2009 10:19:24 +0800 From: Shaohua Li To: linux-ide@vger.kernel.org Cc: jgarzik@pobox.com Subject: [PATCH]libata: optimize the ncq tag search Message-ID: <20090902021924.GA23381@sli10-desk.sh.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org the bitop API should be a little faster than the loop. Signed-off-by: Shaohua Li --- 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 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;