From patchwork Thu Mar 9 13:16:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 9613339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2B9E060524 for ; Thu, 9 Mar 2017 13:20:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E8C428518 for ; Thu, 9 Mar 2017 13:20:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1358828546; Thu, 9 Mar 2017 13:20:24 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86DAD28626 for ; Thu, 9 Mar 2017 13:20:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754086AbdCINUX (ORCPT ); Thu, 9 Mar 2017 08:20:23 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:49647 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754585AbdCINUW (ORCPT ); Thu, 9 Mar 2017 08:20:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3kpp/R3kxU7qJV+JsFCZAsB2Thm+eR1b7SQL2ojGdv0=; b=aFNUb0U+uicWoGml1ZpDp9P7r NLiCkib3iXiUlk51qOX5z6G0CowqlCKEr0CaqLAWL30/5Fl11lQngH4IoOnWisqpPCxQZoLmqUYMI 2rAyxMHpUeSiwX+lgL78kiGtTLf9+02h4+8f79dMwdrlwRMD9OB0B6waXg+s3xBAllbA1mZSFxD3L YBkhi3bg5QkPwY9Jvlp7d3mRzFJzMvnEdCY25HMYM/8T8FHCj7MsHXvwLWbi+y8Z+zH4t0/Jlh5gY ojzHmwH/FD9ntcIzPQADpIhmTfOrEBoF6I5qaG3n8UmaYUbPpMKceNaw+27R4DKdglE5EoBdlQpsV +sxs7mG3w==; Received: from bzq-82-81-101-184.red.bezeqint.net ([82.81.101.184] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1clxwB-0001My-Ve; Thu, 09 Mar 2017 13:17:00 +0000 From: Sagi Grimberg To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH rfc 02/10] nvme-pci: Add budget to __nvme_process_cq Date: Thu, 9 Mar 2017 15:16:34 +0200 Message-Id: <1489065402-14757-3-git-send-email-sagi@grimberg.me> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489065402-14757-1-git-send-email-sagi@grimberg.me> References: <1489065402-14757-1-git-send-email-sagi@grimberg.me> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Prepare to allow passing a batch size to nvme cq processing. This patch does not change an functionality. Signed-off-by: Sagi Grimberg Reviewed-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- drivers/nvme/host/pci.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index d3f74fa40f26..4ed67f194cfd 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -716,14 +716,15 @@ static inline bool nvme_read_cqe(struct nvme_queue *nvmeq, return false; } -static int __nvme_process_cq(struct nvme_queue *nvmeq, int *tag) +static int __nvme_process_cq(struct nvme_queue *nvmeq, int budget, int *tag) { struct nvme_completion cqe; int consumed = 0; while (nvme_read_cqe(nvmeq, &cqe)) { nvme_handle_cqe(nvmeq, &cqe); - consumed++; + if (++consumed == budget) + break; if (tag && *tag == cqe.command_id) { *tag = -1; @@ -741,7 +742,7 @@ static int __nvme_process_cq(struct nvme_queue *nvmeq, int *tag) static int nvme_process_cq(struct nvme_queue *nvmeq) { - return __nvme_process_cq(nvmeq, NULL); + return __nvme_process_cq(nvmeq, INT_MAX, NULL); } static irqreturn_t nvme_irq(int irq, void *data) @@ -772,7 +773,7 @@ static int nvme_poll(struct blk_mq_hw_ctx *hctx, unsigned int tag) if (nvme_cqe_valid(nvmeq, nvmeq->cq_head, nvmeq->cq_phase)) { spin_lock_irq(&nvmeq->q_lock); - __nvme_process_cq(nvmeq, &tag); + __nvme_process_cq(nvmeq, INT_MAX, &tag); spin_unlock_irq(&nvmeq->q_lock); if (tag == -1)