Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp264755ybc; Tue, 12 Nov 2019 00:51:01 -0800 (PST) X-Google-Smtp-Source: APXvYqxZs1Y6qGySxagoq0JyPoI+Zmh2G0uNnq/kl+7rwFVkHTZC+Xdqq+NoDmzT8G7xaSBicU0w X-Received: by 2002:a17:906:843:: with SMTP id f3mr6395102ejd.127.1573548661218; Tue, 12 Nov 2019 00:51:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573548661; cv=none; d=google.com; s=arc-20160816; b=utfcdzkDIuUAdGSvE5iw4b5vKZJXUUP/NCdVuq8g1OgdomwnnGilwqd9cENiSvANEN gBZ5ePB+gQS+VwCeROY+xvI7pnoLY7WgTLQPGlo7aastJfx1ADzPWt3j3jwznCJtd+ts 4SstbZs/gJjyn9wrS2BzF2eMEd6+nDZPOEdsgRHuhD1I1MrzlX7JaUvz3Npd7L7bpmuG Fm11Md4JltRGyuQSj5P2sSeyntUPuQC6IUFAiYQgCdiZuEqXVWbqPNITawL71A7IptMZ B+5umLWBaFfYWERL3u7dIXbLRcnCL8B+Fe9HWARQvA8W1f85YdDN+xNUMcC3YSxYIOfF Pr/A== 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 :in-reply-to:references:mime-version:dkim-signature; bh=uYpmcMMqlT0yk3qneW+aFmnPdVZOuZEw3kSyEOhlztI=; b=VzPlbhFEeoE9iVXsDb910EZx0+VOVevC93U9lxFCGWia0rWYPy35rc8zpQ+n73p6Y3 t42EyLCPjU4iUIllWNmC3lhACvh+pH+vS5ofN90Xz0HnYQTw/2rEptX2BPEMZeI2Juca aIINBcmipWbK1zu/F1MPYwW+BbbIrReHMYn8nlLQqikQvNsRQOz/dDut4OLNBK0s0fXk NUJdDp4J41DSnvXVcaa6MEa7ynfWZys/IGtanvlRDX8jtoDxo+ihfQg1l2XgZ5+ZmBEf D5wV6Js02tYz4hfhtzeIqLgaBZC9qBQOJLagNjmYp1YfF7O++uw7UluQZn3WAptK8CYt 3NQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ve3lo0ji; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z44si14249876edz.211.2019.11.12.00.50.37; Tue, 12 Nov 2019 00:51:01 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ve3lo0ji; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726986AbfKLIso (ORCPT + 99 others); Tue, 12 Nov 2019 03:48:44 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:41371 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725821AbfKLIso (ORCPT ); Tue, 12 Nov 2019 03:48:44 -0500 Received: by mail-qt1-f193.google.com with SMTP id o3so18915935qtj.8; Tue, 12 Nov 2019 00:48:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uYpmcMMqlT0yk3qneW+aFmnPdVZOuZEw3kSyEOhlztI=; b=Ve3lo0jiYJa14s3msCDNn9GhL6p/qKWcyhW9L+uj13YuJJlTSxLB583XojGwXpWMVX BxDYQmKB9eLD/KgpQ8HLXRWKnKCjVts5VltLViERwCLdtfj7LUpeJw8gs/I8xnagawgk pM3wV73ZyPXWeAofuphgsR2zz0l7rkMVrsDENGkaPeDJ5NePysvrsSB7CzFJLEc7dV5T vRrn8jN94HYtx7Mb3Lo6eIkJco/RH6MLAB3NwFHzy1uTG7e1437GbPtex6eMTqViYBve p9wPF6636QeHTweuImCwMIDOWiCNF8NKgoeAp58dradBoy40ebKmg1ocub1suSEA9Gv/ AQIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uYpmcMMqlT0yk3qneW+aFmnPdVZOuZEw3kSyEOhlztI=; b=MkoV2ERSNxGzHG6Lw0Mkm+mHe/96Jp/uETqSBjP8rQcpQCSqxFlAY77fYmT3aecAQB IIaY3lMm+DUgOsoMXdV4clo2QOhhupaw+i9Dq28Q0jnduLvD2DFIK5YGe2AD4+xg1IQc l6LzTzV9VBUW900LxqE2XIm4giQe8l6w6n3Arvk/BkJWGJuanQ8Ht36aj8+j5WyLt1JW zogFFdDig9I5hIZ6yENClH7JEk39pjCKRpXy7kLSLpJvoaN56kKtCkmj4VVKCXS94XJf fvkF8dkacKhLooi1oT3jMuOypN6/aPUTmV1WjuL/oHvkgNgJ7x1nKCkvm8P5c944FDpi fIQQ== X-Gm-Message-State: APjAAAUq7EMXqjn6Gvcr7cdDtTI/0vK4XhC++aOd0sbKA9aW0plpENqm ILljsSKXOwNLFhMGuV4GFM0b0ILXoy8QGoy2Usc= X-Received: by 2002:ac8:28c7:: with SMTP id j7mr32051234qtj.4.1573548522730; Tue, 12 Nov 2019 00:48:42 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Baolin Wang Date: Tue, 12 Nov 2019 16:48:30 +0800 Message-ID: Subject: Re: [PATCH v6 0/4] Add MMC software queue support To: Arnd Bergmann Cc: Baolin Wang , Adrian Hunter , Ulf Hansson , asutoshd@codeaurora.org, Orson Zhai , Lyra Zhang , Linus Walleij , Vincent Guittot , linux-mmc , "linux-kernel@vger.kernel.org" , Hannes Reinecke , linux-block 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 Tue, Nov 12, 2019 at 12:59 AM Arnd Bergmann wrote: > > On Mon, Nov 11, 2019 at 1:58 PM Baolin Wang wrote: > > On Mon, 11 Nov 2019 at 17:28, Arnd Bergmann wrote: > > > On Mon, Nov 11, 2019 at 8:35 AM Baolin Wang wrote: > > > - Removing all the context switches and workqueues from the data submission > > > path is also the right idea. As you found, there is still a workqueue inside > > > of blk_mq that is used because it may get called from atomic context but > > > the submission may get blocked in __mmc_claim_host(). This really > > > needs to be changed as well, but not in the way I originally suggested: > > > As Hannes suggested, the host interrrupt handler should always use > > > request_threaded_irq() to have its own process context, and then pass a > > > flag to blk_mq to say that we never need another workqueue there. > > > > So you mean we should complete the request in the host driver irq > > thread context, then issue another request in this context by calling > > blk_mq_run_hw_queues()? > > Yes. I assumed there was already code that would always run > blk_mq_run_hw_queue() at I/O completion, but I can't find where > that happens today. OK. Now we will complete a request in block softirq, which means the irq thread of host driver should call blk_mq_complete_request() to complete this request (triggering the block softirq) and call blk_mq_run_hw_queues() to dispatch another request in this context. > > As I understand, the main difference to today is that > __blk_mq_delay_run_hw_queue() can call into __blk_mq_run_hw_queue > directly rather than using the delayed work queue once we > can skip the BLK_MQ_F_BLOCKING check. Right. Need to improve this as you suggested. > > > > - With that change in place calling a blocking __mmc_claim_host() is > > > still a problem, so there should still be a nonblocking mmc_try_claim_host() > > > for the submission path, leading to a BLK_STS_DEV_RESOURCE (?) > > > return code from mmc_mq_queue_rq(). Basically mmc_mq_queue_rq() > > > should always return right away, either after having queued the next I/O > > > or with an error, but not waiting for the device in any way. > > > > Actually not only the mmc_claim_host() will block the MMC request > > processing, in this routine, the mmc_blk_part_switch() and > > mmc_retune() can also block the request processing. Moreover the part > > switching and tuning should be sync operations, and we can not move > > them to a work or a thread. > > Ok, I see. > > Those would also cause requests to be sent to the device or the host > controller, right? Maybe we can treat them as "a non-IO request Right. > has successfully been queued to the device" events, returning > busy from the mmc_mq_queue_rq() function and then running > the queue again when they complete? Yes, seems reasonable to me. > > > > - For the packed requests, there is apparently a very simple way to implement > > > that without a software queue: mmc_mq_queue_rq() is allowed to look at > > > and dequeue all requests that are currently part of the request_queue, > > > so it should take out as many as it wants to submit at once and send > > > them all down to the driver together, avoiding the need for any further > > > round-trips to blk_mq or maintaining a queue in mmc. > > > > You mean we can dispatch a request directly from > > elevator->type->ops.dispatch_request()? but we still need some helper > > functions to check if these requests can be packed (the package > > condition), and need to invent new APIs to start a packed request (or > > using cqe interfaces, which means we still need to implement some cqe > > callbacks). > > I don't know how the dispatch_request() function fits in there, > what Hannes told me is that in ->queue_rq() you can always > look at the following requests that are already queued up > and take the next ones off the list. Looking at bd->last > tells you if there are additional requests. If there are, you can > look at the next one from blk_mq_hw_ctx (not sure how, but > should not be hard to find) > > I also see that there is a commit_rqs() callback that may > go along with queue_rq(), implementing that one could make > this easier as well. Yes, we can use queue_rq()/commit_rqs() and bd->last (now bd->last may can not work well, see [1]), but like we talked before, for packed request, we still need some new interfaces (for example, a interface used to start a packed request, and a interface used to complete a packed request), but at last we got a consensus that we should re-use the CQE interfaces instead of new invention. [1] https://lore.kernel.org/patchwork/patch/1102897/ > > > > - The DMA management (bounce buffer, map, unmap) that is currently > > > done in mmc_blk_mq_issue_rq() should ideally be done in the > > > init_request()/exit_request() (?) callbacks from mmc_mq_ops so this > > > can be done asynchronously, out of the critical timing path for the > > > submission. With this, there won't be any need for a software queue. > > > > This is not true, now the blk-mq will allocate some static request > > objects (usually the static requests number should be the same with > > the hardware queue depth) saved in struct blk_mq_tags. So the > > init_request() is used to initialize the static requests when > > allocating them, and call exit_request to free the static requests > > when freeing the 'struct blk_mq_tags', such as the queue is dead. So > > we can not move the DMA management into the init_request/exit_request. > > Ok, I must have misremembered which callback that is then, but I guess > there is some other place to do it. I checked the 'struct blk_mq_ops', and I did not find a ops can be used to do DMA management. And I also checked UFS driver, it also did the DMA mapping in the queue_rq() (scsi_queue_rq() ---> ufshcd_queuecommand() ---> ufshcd_map_sg()). Maybe I missed something? Moreover like I said above, for the packed request, we still need implement something (like the software queue) based on the CQE interfaces to help to handle packed requests.