From patchwork Wed Jan 9 01:52:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam X-Patchwork-Id: 10753359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5806F6C5 for ; Wed, 9 Jan 2019 01:55:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 423812899B for ; Wed, 9 Jan 2019 01:55:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3004028D8D; Wed, 9 Jan 2019 01:55:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E2B832899B for ; Wed, 9 Jan 2019 01:55:12 +0000 (UTC) Received: from localhost ([127.0.0.1]:38453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gh35K-0003E4-Bi for patchwork-qemu-devel@patchwork.kernel.org; Tue, 08 Jan 2019 20:55:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gh33z-00022W-Gr for qemu-devel@nongnu.org; Tue, 08 Jan 2019 20:53:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gh33y-0005wk-LN for qemu-devel@nongnu.org; Tue, 08 Jan 2019 20:53:47 -0500 Received: from sender2-op-o12.zoho.com.cn ([163.53.93.243]:17745 helo=sender1.zoho.com.cn) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gh33x-0005kQ-CL for qemu-devel@nongnu.org; Tue, 08 Jan 2019 20:53:46 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1546998768; cv=none; d=zoho.com.cn; s=zohoarc; b=ZZLLh6os+RWL8EJojbSh4zdrr5rSadrF+bmlZXY+kh9N6Qv1Y2/qDYa+LHfx43mJ5LOsnMIlqm/WzSwEFNvCSIvOcwB5BWfxPU8jrGrN72iUMBRT4oVIjoWbyFH81VMvAk6cYTrQkdfXwmw8pMQ7kndCo6fUwm1PnSfXuRJExOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1546998768; h=Cc:Date:From:In-Reply-To:Message-ID:References:Subject:To:ARC-Authentication-Results; bh=Fb5hc+G6CN9iuGA//nSqw7ZVubWJmu8R+anBUfdqI0k=; b=Xp6DuiKLsItghpfjf/TNO7H7RyjQbhR4dVPPY53ccLhp+lgjFohA2Hp8wKQyutqiBMI6wgzigXsRR7x/bcJKm/XdDBWas7D6RVcE0XXMLRjCWVmdTsB70dC7LknDvaveHn7eqz3+y2yrIIDo6xMy0kVqgt9x7Glb4a2zmyZHUvo= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=euphon.net; spf=pass smtp.mailfrom=fam@euphon.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1546998768; s=zoho; d=euphon.net; i=fam@euphon.net; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; l=2253; bh=Fb5hc+G6CN9iuGA//nSqw7ZVubWJmu8R+anBUfdqI0k=; b=cANBn1WjFjpr96GvjHcmUg6Quq/vNjiNzUhZRjLcGYGWZs3g6wmiSLI4YizZ6EuU jrQ6lN1XtVqxkhFXJrKufjF6sY3m3LwQfdIAiB5tCFuKKJUkehAT9jFpOahodRiy8fc nRuzHRENuLxFNKe39H4mNxQ8MYOHd4y60xDT8CDc= Received: from localhost (120.52.147.52 [120.52.147.52]) by mx.zoho.com.cn with SMTPS id 1546998767341420.105138964553; Wed, 9 Jan 2019 09:52:47 +0800 (CST) From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 9 Jan 2019 09:52:39 +0800 Message-Id: <20190109015240.2116-2-fam@euphon.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190109015240.2116-1-fam@euphon.net> References: <20190109015240.2116-1-fam@euphon.net> X-ZohoCNMailClient: External X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 163.53.93.243 Subject: [Qemu-devel] [PULL 1/2] block/nvme: optimize the performance of nvme driver based on vfio-pci X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Li Feng When the IO size is larger than 2 pages, we move the the pointer one by one in the pagelist, this is inefficient. This is a simple benchmark result: Before: $ qemu-io -c 'write 0 1G' nvme://0000:00:04.0/1 wrote 1073741824/1073741824 bytes at offset 0 1 GiB, 1 ops; 0:00:02.41 (424.504 MiB/sec and 0.4146 ops/sec) $ qemu-io -c 'read 0 1G' nvme://0000:00:04.0/1 read 1073741824/1073741824 bytes at offset 0 1 GiB, 1 ops; 0:00:02.03 (503.055 MiB/sec and 0.4913 ops/sec) After: $ qemu-io -c 'write 0 1G' nvme://0000:00:04.0/1 wrote 1073741824/1073741824 bytes at offset 0 1 GiB, 1 ops; 0:00:02.17 (471.517 MiB/sec and 0.4605 ops/sec) $ qemu-io -c 'read 0 1G' nvme://0000:00:04.0/1 read 1073741824/1073741824 bytes at offset 0 1 GiB, 1 ops; 0:00:01.94 (526.770 MiB/sec and 0.5144 ops/sec) Signed-off-by: Li Feng Message-Id: <20181101103807.25862-1-lifeng1519@gmail.com> Signed-off-by: Fam Zheng --- block/nvme.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 29294038fc..982097b5b1 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -837,7 +837,7 @@ try_map: } for (j = 0; j < qiov->iov[i].iov_len / s->page_size; j++) { - pagelist[entries++] = iova + j * s->page_size; + pagelist[entries++] = cpu_to_le64(iova + j * s->page_size); } trace_nvme_cmd_map_qiov_iov(s, i, qiov->iov[i].iov_base, qiov->iov[i].iov_len / s->page_size); @@ -850,20 +850,16 @@ try_map: case 0: abort(); case 1: - cmd->prp1 = cpu_to_le64(pagelist[0]); + cmd->prp1 = pagelist[0]; cmd->prp2 = 0; break; case 2: - cmd->prp1 = cpu_to_le64(pagelist[0]); - cmd->prp2 = cpu_to_le64(pagelist[1]);; + cmd->prp1 = pagelist[0]; + cmd->prp2 = pagelist[1]; break; default: - cmd->prp1 = cpu_to_le64(pagelist[0]); - cmd->prp2 = cpu_to_le64(req->prp_list_iova); - for (i = 0; i < entries - 1; ++i) { - pagelist[i] = cpu_to_le64(pagelist[i + 1]); - } - pagelist[entries - 1] = 0; + cmd->prp1 = pagelist[0]; + cmd->prp2 = cpu_to_le64(req->prp_list_iova + sizeof(uint64_t)); break; } trace_nvme_cmd_map_qiov(s, cmd, req, qiov, entries);