Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6437055imu; Wed, 14 Nov 2018 01:13:10 -0800 (PST) X-Google-Smtp-Source: AJdET5fWHTp8+mE4Z0Wi79nSeKcnGS9oYHz+k0bgun3MzA1tYnwxjk97/x6Njyq3uhdhLMDldq7W X-Received: by 2002:a63:5442:: with SMTP id e2-v6mr1024708pgm.316.1542186790324; Wed, 14 Nov 2018 01:13:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542186790; cv=none; d=google.com; s=arc-20160816; b=SzI1iigpp+AEF/KMKtH5W+ETUOKtLwpGfBqsA/f5K/wbFofOrPiQBL6qqsI7VgWR9A XxUbA/o4q3g/3lWvhScVY1w/UwJf7FN7obOgwdVKTPudm6Lu0S890Z2PzJcUHjHf4P2o UkLZrHgK3ne87YlQjXatkDt9zi+Fi3atR7sGxUyIxr5ZMQqNtsvnngLtCHt9H+eBXpX0 hH1AOemddfHGDK1vlnP9ahZ0PChViTnJ4+GBti5A9lgNfjmnPJ8fnNCKKpyCCjCNXLZ4 1nX1d4ZwcrgL9d04EMzdmtatVQgpUa66kdMjS/JpJOEt/oajTh3BnoBOJLzazThw/SjD MWGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=OFlXQoP/uAiMinFuc3pPepPQbgtf/gQIPIPw1pcJqik=; b=cr7FAuH4/uKNVsYyZNkDNS809MUswMT8qfKMTkqgSM3Jwxvyhb62H2fCEPu5x5z+3f qU/6G+mmAReqRx14AKsQE88mwe63gzjUWG7l61hm9iFloWcGYmn1NPqv45vqHjLRrRR0 0Zextuxb1vC2Fl/Z5Me6mspAUdsdn0bWVrK4WE/fK/Bt2jY0yctmuokk514ZExGg7gl/ OsT8w0l4ZB4O7ZrrkKVhK+zYXw6NGz0BvU1hyxOyj3l/KE/gezkVPeSZnTN5vGWupsOJ 4Xz8OmUopvzxylIV7WKDj7LmtycEU3fzXFuU9MLUS45XIoKShT3HN4clccCBdWNZsCcT XhrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1-v6si20866540pgv.468.2018.11.14.01.12.54; Wed, 14 Nov 2018 01:13:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732302AbeKNTO3 (ORCPT + 99 others); Wed, 14 Nov 2018 14:14:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54666 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730548AbeKNTO3 (ORCPT ); Wed, 14 Nov 2018 14:14:29 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72D7780467; Wed, 14 Nov 2018 09:12:07 +0000 (UTC) Received: from ming.t460p (ovpn-8-18.pek2.redhat.com [10.72.8.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4DEA360BF7; Wed, 14 Nov 2018 09:11:59 +0000 (UTC) Date: Wed, 14 Nov 2018 17:11:55 +0800 From: Ming Lei To: Jianchao Wang Cc: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V7 1/4] blk-mq: refactor the code of issue request directly Message-ID: <20181114091153.GB20550@ming.t460p> References: <1542185131-15029-1-git-send-email-jianchao.w.wang@oracle.com> <1542185131-15029-2-git-send-email-jianchao.w.wang@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1542185131-15029-2-git-send-email-jianchao.w.wang@oracle.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 14 Nov 2018 09:12:07 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 14, 2018 at 04:45:28PM +0800, Jianchao Wang wrote: > Merge blk_mq_try_issue_directly and __blk_mq_try_issue_directly > into one interface to unify the interfaces to issue requests > directly. The merged interface takes over the requests totally, > it could insert, end or do nothing based on the return value of > .queue_rq and 'bypass' parameter. Then caller needn't any other > handling any more. > > Signed-off-by: Jianchao Wang > --- > block/blk-mq.c | 93 ++++++++++++++++++++++++++++------------------------------ > 1 file changed, 45 insertions(+), 48 deletions(-) > > diff --git a/block/blk-mq.c b/block/blk-mq.c > index 411be60..14b4d06 100644 > --- a/block/blk-mq.c > +++ b/block/blk-mq.c > @@ -1766,78 +1766,75 @@ static blk_status_t __blk_mq_issue_directly(struct blk_mq_hw_ctx *hctx, > return ret; > } > > -static blk_status_t __blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, > +static blk_status_t blk_mq_try_issue_directly(struct blk_mq_hw_ctx *hctx, > struct request *rq, > blk_qc_t *cookie, > - bool bypass_insert) > + bool bypass) > { > struct request_queue *q = rq->q; > bool run_queue = true; > + blk_status_t ret = BLK_STS_RESOURCE; > + int srcu_idx; > > + hctx_lock(hctx, &srcu_idx); > /* > - * RCU or SRCU read lock is needed before checking quiesced flag. > + * hctx_lock is needed before checking quiesced flag. > * > - * When queue is stopped or quiesced, ignore 'bypass_insert' from > - * blk_mq_request_issue_directly(), and return BLK_STS_OK to caller, > - * and avoid driver to try to dispatch again. > + * When queue is stopped or quiesced, ignore 'bypass', insert > + * and return BLK_STS_OK to caller, and avoid driver to try to > + * dispatch again. > */ > - if (blk_mq_hctx_stopped(hctx) || blk_queue_quiesced(q)) { > + if (unlikely(blk_mq_hctx_stopped(hctx) || blk_queue_quiesced(q))) { > run_queue = false; > - bypass_insert = false; > - goto insert; > + bypass = false; > + goto out_unlock; > } > > - if (q->elevator && !bypass_insert) > - goto insert; > + /* > + * Bypass the potential scheduler on the bottom device. > + */ > + if (unlikely(q->elevator && !bypass)) > + goto out_unlock; > > - if (!blk_mq_get_dispatch_budget(hctx)) > - goto insert; > + if (unlikely(!blk_mq_get_dispatch_budget(hctx))) > + goto out_unlock; The unlikely annotation is a bit misleading, since out-of-budget can happen frequently in case of low queue depth, and there are lots of such examples. > > - if (!blk_mq_get_driver_tag(rq)) { > + if (unlikely(!blk_mq_get_driver_tag(rq))) { Same with above. Thanks, Ming