Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8484342ybi; Tue, 23 Jul 2019 09:21:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRYiIgT5vKtpPBa85lDj0mmafuuHee/9aRs2ZfigZa3k9oio5Wg13m0HzAJ0Lp3vquOB6I X-Received: by 2002:a17:90a:4f0e:: with SMTP id p14mr80385962pjh.40.1563898895432; Tue, 23 Jul 2019 09:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563898895; cv=none; d=google.com; s=arc-20160816; b=FnKuXEv1XAMU9xG8kk85gcHckqd/ezocCYAuWQmLElbIxXS6T6DTCOheazZujPLD8/ qr/YEIEtxahu+I2faPOOAmdFNXHZFFl5JEvJYT4hZSz6tgqqtpyElOUxBwX4731UMCHa HRlcEZpiJA3j4hedeN6Jy9TrfrZcK38Vdcyh9leHT73yGoPAEWV6ruWaQAjrpkQfwx3r eBtM9UMRu5tux3xLWz/TrCUZbJjsRMz9dCrbOUPXcCkOmzIm2T/f+dywVEBMycea4Sw3 6rXmus5Jm42FHcmqxD37+Ejy8B3zFPVBk0sb4jeJ1ij0AHk2R5WHW/rZbsBitadFNZng 4Sjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=l8ikddQeaKpRv73RcpRnjhbVGDZiHul3jH+N9vzFDo0=; b=gPkE9lK5fQO2pz2RXgCnau4t1/AuK+yKByfYlnPrMsdAVljPKlCCJBDe4eXahLCzkf uXPwpdx+Tg0Q3Czuarl1JWUUvP1bgRI2qz6qkz59wjFRp3oPZeibG5oa93ncE0wvarho y71aj+fyGi/lXhYGygQFNikxbc0DUZiBfFhg2YA7pJ8wPA3T+tQiln+uVZVDaKecqKu1 lK0gG1qJ/MkqfAdFDdmwgESNfWo9ONDThWKycy1bCsEpra5Oz6XBCRKjId+VR9oEWtdq FghHpE1P3s4Fm+7lCIWP0rVRhbci0O6OPjGFPDRj/f59CbTfxYE4ITsRn8fvxGaENvZh 3pYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RY++HW4S; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s94si10794836pjb.83.2019.07.23.09.21.19; Tue, 23 Jul 2019 09:21:35 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=RY++HW4S; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388263AbfGWHPX (ORCPT + 99 others); Tue, 23 Jul 2019 03:15:23 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:32782 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbfGWHPX (ORCPT ); Tue, 23 Jul 2019 03:15:23 -0400 Received: by mail-ot1-f65.google.com with SMTP id q20so42971552otl.0 for ; Tue, 23 Jul 2019 00:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=l8ikddQeaKpRv73RcpRnjhbVGDZiHul3jH+N9vzFDo0=; b=RY++HW4S6YvluB3ykZ83EnXbkxdRn0XGH/M6sHwl0pXMKHpPhZYXssPidQ+Mk6BwUU hWb+4ljjVQo6lbPZf/R0uVj+O6yVvuDNPJp/A6YWXTlNvtMRSNByXd6TWJJQYjKyH0sg P6arGJ5bHvMAO/bBtzVTYc3ypt0tF6QA91Qbbjd5Uhwc7n5TRl9ynpygqiv9Aeue2vmO Y/pOGxpZfT8bedkrbPBizevmTfZTBlUUYGB3xJWMcC8W5oLes/32Zl6ZZn+pj8len4Bc qp4E7r38ihani7d4VzCZWoephD1iHCzBQ03daY7c/EksFK9d6GApKWW61k+Ljpw4yu/9 BnkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=l8ikddQeaKpRv73RcpRnjhbVGDZiHul3jH+N9vzFDo0=; b=g+xmnSv/eCIAakLzBA+otHVk9uQs28Ms17V9N8KpXEDiw0BZTV/kPnXOCAhe6DAnG8 6xLg5nak44upJ+bB6qOQX0oJrF3El2dYhan43flKS98BklLxANmV5s1up3h8xEBUxXkQ OF3dfhF2pK1APNoEiqMMqcMZRzTo5lypYVF5tVfum11YItIcuRNwLHVQWH6JP3GUUAkT bTEow/Bppr5BjI0VzO9/Ar5V6OmpFl7RJp/sK5/nLEXwG4tghw4dqyDKUXmwv23fJlg+ kjSOrqt5YGjKVhEc8efQutGYHO5txDgQushPSbfzL0D7yiBOZZu9DQo+hazLVSJBUP8I PRzg== X-Gm-Message-State: APjAAAXKyDI5c0dU0uudbYFUtt9Xl/VklKirC18W7FmOoE/keswDxfny xH7umJTqB4xfu8Oyiw4950ydycLgf4LCfuOLZdYOQQ== X-Received: by 2002:a05:6830:13c2:: with SMTP id e2mr55602193otq.123.1563866121892; Tue, 23 Jul 2019 00:15:21 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:7541:0:0:0:0:0 with HTTP; Tue, 23 Jul 2019 00:15:21 -0700 (PDT) In-Reply-To: <20190723033103.GA13829@ming.t460p> References: <94a0d20e6304b909391abd9a425c71c376cad964.1563782844.git.baolin.wang@linaro.org> <20190722141940.GA26528@ming.t460p> <20190723033103.GA13829@ming.t460p> From: Baolin Wang Date: Tue, 23 Jul 2019 15:15:21 +0800 Message-ID: Subject: Re: [RFC PATCH 1/7] blk-mq: Export blk_mq_hctx_has_pending() function To: Ming Lei Cc: Jens Axboe , Adrian Hunter , Ulf Hansson , Chunyan Zhang , Orson Zhai , Arnd Bergmann , Linus Walleij , Vincent Guittot , linux-mmc , LKML , linux-block@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/07/2019, Ming Lei wrote: > On Tue, Jul 23, 2019 at 11:12:57AM +0800, Baolin Wang wrote: >> Hi Ming, >> >> On Mon, 22 Jul 2019 at 22:19, Ming Lei wrote: >> > >> > On Mon, Jul 22, 2019 at 09:09:36PM +0800, Baolin Wang wrote: >> > > Some SD/MMC host controllers can support packed command or packed >> > > request, >> > > that means we can package several requests to host controller at one >> > > time >> > > to improve performence. And this patch set will introduce MMC packed >> > > function >> > > to support this feature by following patches. >> > > >> > > To support MMC packed function, the MMC layer need to know if there >> > > are >> > > requests are pending now in hardware queue to help to combine >> > > requests >> > > as much as possible. If we know there are requests pending in >> > > hardware >> > > queue, then we should not package requests to host controller >> > > immediately, >> > > instead we should collect more requests into MMC packed queue to be >> > > packed >> > > to host controller with packed condition. >> > > >> > > Thus export this function for MMC packed function. >> > > >> > > Signed-off-by: Baolin Wang >> > > --- >> > > block/blk-mq.c | 3 ++- >> > > include/linux/blk-mq.h | 1 + >> > > 2 files changed, 3 insertions(+), 1 deletion(-) >> > > >> > > diff --git a/block/blk-mq.c b/block/blk-mq.c >> > > index b038ec6..5bd4ef9 100644 >> > > --- a/block/blk-mq.c >> > > +++ b/block/blk-mq.c >> > > @@ -63,12 +63,13 @@ static int blk_mq_poll_stats_bkt(const struct >> > > request *rq) >> > > * Check if any of the ctx, dispatch list or elevator >> > > * have pending work in this hardware queue. >> > > */ >> > > -static bool blk_mq_hctx_has_pending(struct blk_mq_hw_ctx *hctx) >> > > +bool blk_mq_hctx_has_pending(struct blk_mq_hw_ctx *hctx) >> > > { >> > > return !list_empty_careful(&hctx->dispatch) || >> > > sbitmap_any_bit_set(&hctx->ctx_map) || >> > > blk_mq_sched_has_work(hctx); >> > > } >> > > +EXPORT_SYMBOL_GPL(blk_mq_hctx_has_pending); >> > >> > Just wondering why you don't use the 'last' field of 'struct >> > blk_mq_queue_data', >> > which is passed to .queue_rq(), and supposed for implementing batch >> > submission. >> >> The 'last' field of 'struct blk_mq_queue_data' does not indicate the >> last request in the hardware queue, since we want to collect more >> requests from block layer as much as possible to be packed later. >> >> And from blk_mq_do_dispatch_sched()--->blk_mq_dispatch_rq_list()---> >> queue_rq(), I always get 'bd.last = true', which is not useful to >> combine requests for MMC packed queue. Maybe I missed anything? > > That is one flaw of current implementation, and we may improve it, > so other drivers(virtio-io, ...) can benefit from it too. > OK. I am not sure can I add a new flag to indicate if there are requests are pending in the hardware queue? That will help MMC driver to combine more requests. Or do you have any other good suggestion? Thanks. diff --git a/block/blk-mq.c b/block/blk-mq.c index 5bd4ef9..cb240f4 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1257,6 +1257,8 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list, bd.last = !blk_mq_get_driver_tag(nxt); } + bd.rq_pending = blk_mq_hctx_has_pending(hctx); + ret = q->mq_ops->queue_rq(hctx, &bd); if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE) { /* diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 15a2b7b..9b06fe0 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -118,6 +118,7 @@ struct blk_mq_tag_set { struct blk_mq_queue_data { struct request *rq; bool last; + bool rq_pending; }; -- Baolin Wang Best Regards