From: Christoph Hellwig <hch@lst.de>
To: Keith Busch <kbusch@kernel.org>
Cc: hch@lst.de, linux-nvme@lists.infradead.org, sagi@grimberg.me
Subject: Re: [PATCH] nvme-pci: remove volatile cqes
Date: Tue, 28 Apr 2020 09:08:48 +0200 [thread overview]
Message-ID: <20200428070848.GD18754@lst.de> (raw)
In-Reply-To: <20200427191446.2195863-1-kbusch@kernel.org>
On Mon, Apr 27, 2020 at 12:14:46PM -0700, Keith Busch wrote:
> The completion queue entry is not volatile once the phase is confirmed.
> Remove the volaitle keywords and check the phase using the appropriate
> READ_ONCE() accessor, allowing the compiler to optimize the remaining
> completion path.
>
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
> 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 8ebcf40f04fe..cf386c84588b 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -166,7 +166,7 @@ struct nvme_queue {
> void *sq_cmds;
> /* only used for poll queues: */
> spinlock_t cq_poll_lock ____cacheline_aligned_in_smp;
> - volatile struct nvme_completion *cqes;
> + struct nvme_completion *cqes;
> dma_addr_t sq_dma_addr;
> dma_addr_t cq_dma_addr;
> u32 __iomem *q_db;
> @@ -908,8 +908,9 @@ static void nvme_pci_complete_rq(struct request *req)
> /* We read the CQE phase first to check if the rest of the entry is valid */
> static inline bool nvme_cqe_pending(struct nvme_queue *nvmeq)
> {
> - return (le16_to_cpu(nvmeq->cqes[nvmeq->cq_head].status) & 1) ==
> - nvmeq->cq_phase;
> + return (le16_to_cpu(
> + READ_ONCE(nvmeq->cqes[nvmeq->cq_head].status)) & 1) ==
> + nvmeq->cq_phase;
Despite the sound logic this just visually looks horrible. How about:
static inline bool nvme_cqe_pending(struct nvme_queue *nvmeq)
{
struct nvme_completion *hcqe = &nvmeq->cqes[nvmeq->cq_head];
return (le16_to_cpu(READ_ONCE(hcqe->status)) & 1) == nvmeq->cq_phase;
}
Otherwise looks fine:
Reviewed-by: Christoph Hellwig <hch@lst.de>
_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
prev parent reply other threads:[~2020-04-28 7:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 19:14 [PATCH] nvme-pci: remove volatile cqes Keith Busch
2020-04-28 7:08 ` Christoph Hellwig [this message]
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=20200428070848.GD18754@lst.de \
--to=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).