From: Jens Axboe <axboe@kernel.dk>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-block@vger.kernel.org, Keith Busch <keith.busch@intel.com>,
linux-nvme@lists.infradead.org
Subject: Re: [PATCH 1/6] nvme: don't disable local ints for polled queue
Date: Wed, 14 Nov 2018 08:31:14 -0700 [thread overview]
Message-ID: <fdc36207-ee35-e262-c0b9-1592be817ac3@kernel.dk> (raw)
In-Reply-To: <20181114084322.GA14954@infradead.org>
On 11/14/18 1:43 AM, Christoph Hellwig wrote:
>> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
>> index 6aa86dfcb32c..a6e3fbddfadf 100644
>> --- a/drivers/nvme/host/pci.c
>> +++ b/drivers/nvme/host/pci.c
>> @@ -1061,15 +1061,26 @@ static irqreturn_t nvme_irq_check(int irq, void *data)
>>
>> static int __nvme_poll(struct nvme_queue *nvmeq, unsigned int tag)
>> {
>> + unsigned long flags = 0; /* gcc 7.x fail */
>> u16 start, end;
>> - bool found;
>> + bool found, has_irq;
>>
>> if (!nvme_cqe_pending(nvmeq))
>> return 0;
>>
>> - spin_lock_irq(&nvmeq->cq_lock);
>> + /*
>> + * Polled queue doesn't have an IRQ, no need to disable ints
>> + */
>> + has_irq = !nvmeq->polled;
>> + if (has_irq)
>> + local_irq_save(flags);
>> +
>> + spin_lock(&nvmeq->cq_lock);
>> found = nvme_process_cq(nvmeq, &start, &end, tag);
>> - spin_unlock_irq(&nvmeq->cq_lock);
>> + spin_unlock(&nvmeq->cq_lock);
>> +
>> + if (has_irq)
>> + local_irq_restore(flags);
>
> Eww, this just looks ugly. Given that we are micro-optimizing here
> I'd rather just use a different ->poll implementation and thus blk_mq_ops
> if we have a separate poll code. Then we could leave the existing
> __nvme_poll as-is and have a new nvme_poll_noirq something like this:
Yeah good point, gets rid of those branches too. I'll make that change.
> And while we are at it: I think for the irq-driven queuest in a
> separate queue for poll setup we might not even need to take the
> CQ lock. Which might be an argument for only allowing polling
> if we have the separate queues just to keep everything simple.
We can definitely move in that direction, I'll take a look at what
is feasible.
--
Jens Axboe
WARNING: multiple messages have this Message-ID (diff)
From: axboe@kernel.dk (Jens Axboe)
Subject: [PATCH 1/6] nvme: don't disable local ints for polled queue
Date: Wed, 14 Nov 2018 08:31:14 -0700 [thread overview]
Message-ID: <fdc36207-ee35-e262-c0b9-1592be817ac3@kernel.dk> (raw)
In-Reply-To: <20181114084322.GA14954@infradead.org>
On 11/14/18 1:43 AM, Christoph Hellwig wrote:
>> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
>> index 6aa86dfcb32c..a6e3fbddfadf 100644
>> --- a/drivers/nvme/host/pci.c
>> +++ b/drivers/nvme/host/pci.c
>> @@ -1061,15 +1061,26 @@ static irqreturn_t nvme_irq_check(int irq, void *data)
>>
>> static int __nvme_poll(struct nvme_queue *nvmeq, unsigned int tag)
>> {
>> + unsigned long flags = 0; /* gcc 7.x fail */
>> u16 start, end;
>> - bool found;
>> + bool found, has_irq;
>>
>> if (!nvme_cqe_pending(nvmeq))
>> return 0;
>>
>> - spin_lock_irq(&nvmeq->cq_lock);
>> + /*
>> + * Polled queue doesn't have an IRQ, no need to disable ints
>> + */
>> + has_irq = !nvmeq->polled;
>> + if (has_irq)
>> + local_irq_save(flags);
>> +
>> + spin_lock(&nvmeq->cq_lock);
>> found = nvme_process_cq(nvmeq, &start, &end, tag);
>> - spin_unlock_irq(&nvmeq->cq_lock);
>> + spin_unlock(&nvmeq->cq_lock);
>> +
>> + if (has_irq)
>> + local_irq_restore(flags);
>
> Eww, this just looks ugly. Given that we are micro-optimizing here
> I'd rather just use a different ->poll implementation and thus blk_mq_ops
> if we have a separate poll code. Then we could leave the existing
> __nvme_poll as-is and have a new nvme_poll_noirq something like this:
Yeah good point, gets rid of those branches too. I'll make that change.
> And while we are at it: I think for the irq-driven queuest in a
> separate queue for poll setup we might not even need to take the
> CQ lock. Which might be an argument for only allowing polling
> if we have the separate queues just to keep everything simple.
We can definitely move in that direction, I'll take a look at what
is feasible.
--
Jens Axboe
next prev parent reply other threads:[~2018-11-14 15:31 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-10 15:13 [PATCHSET 0/6] Various block optimizations Jens Axboe
2018-11-10 15:13 ` [PATCH 1/6] nvme: don't disable local ints for polled queue Jens Axboe
2018-11-10 15:13 ` Jens Axboe
2018-11-14 8:43 ` Christoph Hellwig
2018-11-14 8:43 ` Christoph Hellwig
2018-11-14 15:31 ` Jens Axboe [this message]
2018-11-14 15:31 ` Jens Axboe
2018-11-14 15:37 ` Keith Busch
2018-11-14 15:37 ` Keith Busch
2018-11-14 10:18 ` Max Gurtovoy
2018-11-14 10:18 ` Max Gurtovoy
2018-11-10 15:13 ` [PATCH 2/6] block: add queue_is_mq() helper Jens Axboe
2018-11-10 15:13 ` [PATCH 3/6] blk-mq: embed blk_mq_ops directly in the request queue Jens Axboe
2018-11-14 15:20 ` Christoph Hellwig
2018-11-14 15:33 ` Jens Axboe
2018-11-14 15:39 ` Christoph Hellwig
2018-11-14 15:47 ` Jens Axboe
2018-11-14 15:58 ` Christoph Hellwig
2018-11-10 15:13 ` [PATCH 4/6] block: avoid ordered task state change for polled IO Jens Axboe
2018-11-12 9:35 ` jianchao.wang
2018-11-12 16:26 ` Jens Axboe
2018-11-13 2:02 ` jianchao.wang
2018-11-10 15:13 ` [PATCH 5/6] blk-rq-qos: inline check for q->rq_qos functions Jens Axboe
2018-11-14 15:21 ` Christoph Hellwig
2018-11-14 15:33 ` Jens Axboe
2018-11-14 15:40 ` Christoph Hellwig
2018-11-14 17:16 ` Jens Axboe
2018-11-10 15:13 ` [PATCH 6/6] block: add polled wakeup task helper Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fdc36207-ee35-e262-c0b9-1592be817ac3@kernel.dk \
--to=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=keith.busch@intel.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.