Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3492770ybv; Mon, 10 Feb 2020 00:41:56 -0800 (PST) X-Google-Smtp-Source: APXvYqw8zExeogWcVJ/rMigaDRG0aBr7fp7e62VRkEcmOz/wbRzt1R54Y1BudfHKCJoAj1TIraR/ X-Received: by 2002:aca:ab53:: with SMTP id u80mr174643oie.94.1581324115899; Mon, 10 Feb 2020 00:41:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581324115; cv=none; d=google.com; s=arc-20160816; b=LSHItOgi4fA1FK2Pnjs/VA/7K0eUOuuboM7BwOzz5lSGobGDduTtxasRpRtiyllzth Ho2J2thIyomMmZ+i8wrHBkLRupCoyZ5k1YzgihnZM/w0NU8qakyrjMy+o6gLNeitLHZW +VIaFsJCyI0ffqTt3/8/nJMeGTi9cyxEkNr/M/B6gCelHVC3ltouRpg+8V0pkmukheOX ez2vJ+7emOnhXhY89CjCtdnxBmWxUupGOkPTLXJDcpjCGu3mgeXFGW096HzBbY+kq7t1 f4tviEV+to927AKzThsC4k8p95YAi9NuDAR2P3+0KCmODnZjoKG2qaAADayUMTqfzhaJ GinQ== 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=tMzxO+pms4irASelkz3xREp787YtIXCiGVQgDQy0n+k=; b=HRjRWC4p+tEj9X5IQrSCpHSxeVTRq7ZNu9cdxKPvNsfoM0en1GLWe8I2kXeMrCs5eT 61w7YyER8z/ywvbLLv9TkftRVY6aECiggyMKNS6T6WM45assLxmbPsLXwL3kUlLg2+i2 xDEO/HhR7oDoLsDhc5jkzvj2ME5V46vyyrbJUKxf4bG6Kr5i94M1oiBMz5PpoD6GhFST +IQwt0f3Pcp0pB3yddSfwmvn5+6r0c7YlVNVnKXNQF4W8zdUEjJktFYTXDd86oQz2ihC SWRxlVMz5ooopY/zVghZgfDdvf7GOpusc4smIrNQYeyxFRq6GfeuDlp8eQ5/fskTXsOr UCWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="sKmUY/4k"; 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 r5si7774181oic.19.2020.02.10.00.41.43; Mon, 10 Feb 2020 00:41:55 -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="sKmUY/4k"; 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 S1727434AbgBJIld (ORCPT + 99 others); Mon, 10 Feb 2020 03:41:33 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:41720 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726061AbgBJIld (ORCPT ); Mon, 10 Feb 2020 03:41:33 -0500 Received: by mail-qk1-f196.google.com with SMTP id d11so5700469qko.8; Mon, 10 Feb 2020 00:41:32 -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=tMzxO+pms4irASelkz3xREp787YtIXCiGVQgDQy0n+k=; b=sKmUY/4kCNfLJBv/3hfRzHt79AskEo4GgRKgBi+8cr+vj+I0MlA/zskHZja/cbDo+O xAESl0V8jIE8MQV6nLDzjAa7yf4v78AnR5awYoLzoKt4cfj6oS0zU5ryakzl9eY2AbXJ pa3ruoKQp8e+UlIHTsRmisxkECgRR9ctyzjVHOG8DqVNBNAfj0t0b5rh+D3sAMVPyqjM B3EXn6KYueDi+ssHc4l95KWEfcwxphI7gHFGFv9UCmvcQr6HtUjZLOpP3FDQKYLSSIQP s1C93kPjWEpPasua117Om4pMnVxoilNn++Xzq3t5Rb7GuyTeudW1QpGl1JLxBtA/PvoS asSg== 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=tMzxO+pms4irASelkz3xREp787YtIXCiGVQgDQy0n+k=; b=K99pQGX1FtjnS1z2o0XGtSa5cMAU4zFX6JBzM+xQzVa4Yn9bjAaNFLoDA6IK0PlxMu ukmxPLn5hIV3LvbR/ZZo3DKJRiZ+hUrMvx8cu9XQlYFCu4wK34fKcduum+Ulpf/OikHL joPw7mcuMEUQOQiBf9RaYaZsH4pdcSVNNgN9Ap04J9iS0LNmjLbpA5CxU327zTIv2cK9 rMYZfMoCbhrSx/fZ2tgdbJsei92Vfq4etxVdflz3vvUppDrkFhX5DMfPTZNNOF/6Bgai kHY11luKlQrnV8EqaaaKjxcBw1fhwRiPzlmLj1nTuPNVwMCSmLNHGRRZIz1z3/zTN4AO 4lMA== X-Gm-Message-State: APjAAAWPceMATuTbxIHx33OMsL7iw0G3x1n8LzfqYnXgWBaDNZ1CesSD T+WA58OQYDBr7fCkLZXq4OjHXkui9dQ2JpWRgPc= X-Received: by 2002:a05:620a:a1e:: with SMTP id i30mr321910qka.133.1581324092193; Mon, 10 Feb 2020 00:41:32 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Baolin Wang Date: Mon, 10 Feb 2020 16:41:20 +0800 Message-ID: Subject: Re: [PATCH v8 0/5] Add MMC software queue support To: Ulf Hansson Cc: Adrian Hunter , Asutosh Das , Orson Zhai , Chunyan Zhang , Arnd Bergmann , Linus Walleij , Baolin Wang , "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List 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 Hi Ulf, On Thu, Feb 6, 2020 at 11:00 PM Ulf Hansson wrote: > > On Wed, 5 Feb 2020 at 13:51, Baolin Wang wrote: > > > > Hi All, > > > > Now the MMC read/write stack will always wait for previous request is > > completed by mmc_blk_rw_wait(), before sending a new request to hardware, > > or queue a work to complete request, that will bring context switching > > overhead, especially for high I/O per second rates, to affect the IO > > performance. > > In the regular request path (non CQE), we call mmc_blk_card_busy() to > complete a request. For write I/O, this leads to calling > card_busy_detect(), which starts to poll the card by sending a CMD13. > > At least one CMD13 will be sent to the card, before we exit the > polling loop and a new I/O request can get submitted. However, in many > cases, depending on the controller/host/card/request-size, my best > guess is that *one* CMD13 might not be sufficient. At least, that is > what I have observed on those platforms I recently have been working > on. > > That said, I am wondering if you have done some measurement/profiling > on this particular behaviour for your controller/driver? For example, > how many CMD13 gets sent for random small writes during polling? Ah, I had not checked how many CMD13 for random small writes before. And I did a quick testing today, I found only 1 CMD13 gets sent for random writes on my platform. > Why am I asking this? Because, unless I am mistaken, when using the > new hsq path that you introduce in $subject series, based on the cqe > ops, then mmc_blk_card_busy() is not being called at all. In other > words, you rely on HW busy detection from the controller/driver, > rather than polling with CMD13. Is that correct? Right. I think so. > This seems like an additional reason to why you achieve significant > improvements for the random write case. Don't you think? Yes, agree wtih you. > > > > Thus this patch set will introduce the MMC software command queue support > > based on command queue engine's interfaces, and set the queue depth as 64 > > to allow more requests can be be prepared, merged and inserted into IO > > scheduler, but we only allow 2 requests in flight, that is enough to let > > the irq handler always trigger the next request without a context switch, > > as well as avoiding a long latency. > > > > Moreover we can expand the MMC software queue interface to support > > MMC packed request or packed command instead of adding new interfaces, > > according to previosus discussion. > > > > Below are some comparison data with fio tool. The fio command I used > > is like below with changing the '--rw' parameter and enabling the direct > > IO flag to measure the actual hardware transfer speed in 4K block size. > > > > ./fio --filename=/dev/mmcblk0p30 --direct=1 --iodepth=20 --rw=read --bs=4K --size=1G --group_reporting --numjobs=20 --name=test_read > > > > My eMMC card working at HS400 Enhanced strobe mode: > > [ 2.229856] mmc0: new HS400 Enhanced strobe MMC card at address 0001 > > [ 2.237566] mmcblk0: mmc0:0001 HBG4a2 29.1 GiB > > [ 2.242621] mmcblk0boot0: mmc0:0001 HBG4a2 partition 1 4.00 MiB > > [ 2.249110] mmcblk0boot1: mmc0:0001 HBG4a2 partition 2 4.00 MiB > > [ 2.255307] mmcblk0rpmb: mmc0:0001 HBG4a2 partition 3 4.00 MiB, chardev (248:0) > > > > 1. Without MMC software queue > > I tested 5 times for each case and output a average speed. > > > > 1) Sequential read: > > Speed: 59.4MiB/s, 63.4MiB/s, 57.5MiB/s, 57.2MiB/s, 60.8MiB/s > > Average speed: 59.66MiB/s > > > > 2) Random read: > > Speed: 26.9MiB/s, 26.9MiB/s, 27.1MiB/s, 27.1MiB/s, 27.2MiB/s > > Average speed: 27.04MiB/s > > > > 3) Sequential write: > > Speed: 71.6MiB/s, 72.5MiB/s, 72.2MiB/s, 64.6MiB/s, 67.5MiB/s > > Average speed: 69.68MiB/s > > > > 4) Random write: > > Speed: 36.3MiB/s, 35.4MiB/s, 38.6MiB/s, 34MiB/s, 35.5MiB/s > > Average speed: 35.96MiB/s > > > > 2. With MMC software queue > > I tested 5 times for each case and output a average speed. > > > > 1) Sequential read: > > Speed: 59.2MiB/s, 60.4MiB/s, 63.6MiB/s, 60.3MiB/s, 59.9MiB/s > > Average speed: 60.68MiB/s > > > > 2) Random read: > > Speed: 31.3MiB/s, 31.4MiB/s, 31.5MiB/s, 31.3MiB/s, 31.3MiB/s > > Average speed: 31.36MiB/s > > > > 3) Sequential write: > > Speed: 71MiB/s, 71.8MiB/s, 72.3MiB/s, 72.2MiB/s, 71MiB/s > > Average speed: 71.66MiB/s > > > > 4) Random write: > > Speed: 68.9MiB/s, 68.7MiB/s, 68.8MiB/s, 68.6MiB/s, 68.8MiB/s > > Average speed: 68.76MiB/s > > > > Form above data, we can see the MMC software queue can help to improve some > > performance obviously for random read and write, though no obvious improvement > > for sequential read and write. > > > > Any comments are welcome. Thanks a lot. > > > > Changes from v7: > > - Add reviewed tag from Arnd. > > - Use the 'hsq' acronym for varibles and functions in the core layer. > > - Check the 'card->ext_csd.cmdq_en' in cqhci.c to make sure the CQE > > can work normally. > > - Add a new patch to enable the host software queue for the SD card. > > - Use the default MMC queue depth for host software queue. > > It would be nice to also have some measurements for an SD card, now > that the series supports this. Is that possible for you test as well? Yes, but my SD card works at high speed mode, and shows a low speed in 4k block size. [ 2.941965] mmc0: new high speed SDHC card at address b368 [ 2.948325] mmcblk0: mmc0:b368 SD08G 7.42 GiB [ 2.956554] mmcblk0: p1 And I did not see any obvious improvement or recession for my SD card in 4k block size from below data, I think the most of the time is spent in hardware. (But when I enabled the packed request based on hsq, I can see some obvious improvement.) Without hsq: read: bw=4347KiB/s randread: bw=3040KiB/s write: bw=1361KiB/s randwrite: bw=692KiB/s With hsq: read: bw=4246KiB/s randread: bw=29950KiB/s write: bw=1417KiB/s randwrite: bw=697KiB/s