From patchwork Wed Jan 10 19:39:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10156055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA1A960223 for ; Wed, 10 Jan 2018 19:39:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF531205AB for ; Wed, 10 Jan 2018 19:39:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B41B6274B4; Wed, 10 Jan 2018 19:39:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BF1E205AB for ; Wed, 10 Jan 2018 19:39:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753515AbeAJTjZ (ORCPT ); Wed, 10 Jan 2018 14:39:25 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:56712 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753447AbeAJTjU (ORCPT ); Wed, 10 Jan 2018 14:39:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1515613546; x=1547149546; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=J6CqklLX9+F8HOSjy8dAUcupLhukixbWnhtZ/kLLCek=; b=nWonkN6wwZpIs9mLHUDmq/2/PKdOgiKUeKA63igJWgbXUUScJKyOT3zc vgvfvssdbvOt1axTD2CdgWNE6gxSe61wG9uG8FriII2JolJJV3e4Hr/kR fBnB3sMZqvbKiAe0nyl1VRRlZ1Z4ScvayljwDz2EKeWaYHT3MSRm01qSQ QSeb3a/ngF11VyzqsmLwiDCf79PgdiZ4kEGHLRBtCSDV45iqPq68tqvLO QqO8o8JV2jSXqdsk5Q8lkJFzHVKWYF8ZFhdIVs/Du8VCPD202Hp0otuda UwVe+tptAAw+UyqkNQIUO/kPbOMUILhRF5zkH1/L7ZFQGE9fsLS6CyIWO w==; X-IronPort-AV: E=Sophos;i="5.46,341,1511798400"; d="scan'208";a="164734377" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Jan 2018 03:45:46 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 10 Jan 2018 11:34:52 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip02.wdc.com with ESMTP; 10 Jan 2018 11:39:20 -0800 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Omar Sandoval , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH v2 1/2] blk-mq: Reduce the number of if-statements in blk_mq_mark_tag_wait() Date: Wed, 10 Jan 2018 11:39:18 -0800 Message-Id: <20180110193919.6886-2-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180110193919.6886-1-bart.vanassche@wdc.com> References: <20180110193919.6886-1-bart.vanassche@wdc.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch does not change any functionality but makes the blk_mq_mark_tag_wait() code slightly easier to read. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Omar Sandoval Cc: Hannes Reinecke Cc: Johannes Thumshirn Reviewed-by: Hannes Reinecke --- block/blk-mq.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 1d705e25852e..e770e8814f60 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1189,6 +1189,16 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx, if (!shared_tags) { if (!test_bit(BLK_MQ_S_SCHED_RESTART, &this_hctx->state)) set_bit(BLK_MQ_S_SCHED_RESTART, &this_hctx->state); + /* + * It's possible that a tag was freed in the window between the + * allocation failure and adding the hardware queue to the wait + * queue. + */ + ret = blk_mq_get_driver_tag(rq, hctx, false); + /* + * Don't clear RESTART here, someone else could have set it. + * At most this will cost an extra queue run. + */ } else { wait = &this_hctx->dispatch_wait; if (!list_empty_careful(&wait->entry)) @@ -1202,22 +1212,12 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx, ws = bt_wait_ptr(&this_hctx->tags->bitmap_tags, this_hctx); add_wait_queue(&ws->wait, wait); - } - - /* - * It's possible that a tag was freed in the window between the - * allocation failure and adding the hardware queue to the wait - * queue. - */ - ret = blk_mq_get_driver_tag(rq, hctx, false); - - if (!shared_tags) { /* - * Don't clear RESTART here, someone else could have set it. - * At most this will cost an extra queue run. + * It's possible that a tag was freed in the window between the + * allocation failure and adding the hardware queue to the wait + * queue. */ - return ret; - } else { + ret = blk_mq_get_driver_tag(rq, hctx, false); if (!ret) { spin_unlock(&this_hctx->lock); return false; @@ -1231,8 +1231,8 @@ static bool blk_mq_mark_tag_wait(struct blk_mq_hw_ctx **hctx, list_del_init(&wait->entry); spin_unlock_irq(&ws->wait.lock); spin_unlock(&this_hctx->lock); - return true; } + return ret; } bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,