From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6D39C43460 for ; Thu, 1 Apr 2021 02:22:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C32D36108C for ; Thu, 1 Apr 2021 02:22:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232672AbhDACVj (ORCPT ); Wed, 31 Mar 2021 22:21:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45287 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233270AbhDACVZ (ORCPT ); Wed, 31 Mar 2021 22:21:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617243682; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JmE5i/m5IEEsJrMpVFAKNyycD7jJsnJYAktcyMjzdnY=; b=Hl4ggwAFjQvaBp/znOR7U4hgzb93AT8uLpbqeGc3FnPFe6cN+kIDzO9Tvi52PxvQ3GsGr1 WcB4OhSPNKJsutJyKeMYJ7Itohd4SVnwRO0hZVA3ppOYku+yj+c5gUmRNM2fxxbL4FI4+6 vLVTA0/9eW4l1tcqL2UJb2XizbmzQMQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-566-Dp-91om4OjKYoOglufcjjA-1; Wed, 31 Mar 2021 22:21:20 -0400 X-MC-Unique: Dp-91om4OjKYoOglufcjjA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9BCDB6B9C0; Thu, 1 Apr 2021 02:21:19 +0000 (UTC) Received: from localhost (ovpn-12-93.pek2.redhat.com [10.72.12.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id A6CE619C44; Thu, 1 Apr 2021 02:21:12 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, Jeffle Xu , Mike Snitzer , dm-devel@redhat.com, Hannes Reinecke , Ming Lei Subject: [PATCH V5 06/12] block/mq: extract one helper function polling hw queue Date: Thu, 1 Apr 2021 10:19:21 +0800 Message-Id: <20210401021927.343727-7-ming.lei@redhat.com> In-Reply-To: <20210401021927.343727-1-ming.lei@redhat.com> References: <20210401021927.343727-1-ming.lei@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org From: Jeffle Xu Extract the logic of polling one hw queue and related statistics handling out as the helper function. Reviewed-by: Hannes Reinecke Signed-off-by: Jeffle Xu Signed-off-by: Ming Lei --- block/blk-mq.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 1ada2c0e76b1..0cb88c719916 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -3852,6 +3852,19 @@ static bool blk_mq_poll_hybrid(struct request_queue *q, return blk_mq_poll_hybrid_sleep(q, rq); } +static inline int blk_mq_poll_hctx(struct request_queue *q, + struct blk_mq_hw_ctx *hctx) +{ + int ret; + + hctx->poll_invoked++; + ret = q->mq_ops->poll(hctx); + if (ret > 0) + hctx->poll_success++; + + return ret; +} + static int blk_bio_poll(struct request_queue *q, blk_qc_t cookie, bool spin) { /* @@ -3908,11 +3921,8 @@ int blk_poll(struct request_queue *q, blk_qc_t cookie, bool spin) do { int ret; - hctx->poll_invoked++; - - ret = q->mq_ops->poll(hctx); + ret = blk_mq_poll_hctx(q, hctx); if (ret > 0) { - hctx->poll_success++; __set_current_state(TASK_RUNNING); return ret; } -- 2.29.2