All of lore.kernel.org
 help / color / mirror / Atom feed
From: helen.koike@collabora.co.uk (Helen Koike)
Subject: [PATCH v5 RFC] nvme: improve performance for virtual NVMe devices
Date: Mon, 27 Mar 2017 13:04:44 -0300	[thread overview]
Message-ID: <619476f4-9680-e00b-3692-175adfbf4838@collabora.co.uk> (raw)
In-Reply-To: <20170327094947.GA26830@infradead.org>

Hi Keith,

Thanks for your review. Please, see my comments below

On 2017-03-27 06:49 AM, Christoph Hellwig wrote:
>> +#define SQ_IDX(qid, stride)	((qid) * 2 * (stride))
>> +#define CQ_IDX(qid, stride)	(((qid) * 2 + 1) * (stride))
>
> Please use inline functions for these.
>
>> +	struct {
>> +		u32 *dbs;
>> +		u32 *eis;
>> +		dma_addr_t dbs_dma_addr;
>> +		dma_addr_t eis_dma_addr;
>> +	} dbbuf;
>
> No need for a struct here, also please keep the field and its dma_addr_t
> together.
>
>> +	struct {
>> +		u32 *sq_db;
>> +		u32 *cq_db;
>> +		u32 *sq_ei;
>> +		u32 *cq_ei;
>> +	} dbbuf;
>
> No need for the struct here either.
>
>> +
>> +static int nvme_dbbuf_dma_alloc(struct nvme_dev *dev)
>> +{
>> +	unsigned int mem_size = nvme_dbbuf_size(dev->db_stride);
>> +
>> +	dev->dbbuf.dbs = dma_alloc_coherent(dev->dev, mem_size,
>> +					    &dev->dbbuf.dbs_dma_addr,
>> +					    GFP_KERNEL);
>> +	if (!dev->dbbuf.dbs)
>> +		return -ENOMEM;
>> +	dev->dbbuf.eis = dma_alloc_coherent(dev->dev, mem_size,
>> +					    &dev->dbbuf.eis_dma_addr,
>> +					    GFP_KERNEL);
>> +	if (!dev->dbbuf.eis) {
>> +		dma_free_coherent(dev->dev, mem_size,
>> +				  dev->dbbuf.dbs, dev->dbbuf.dbs_dma_addr);
>> +		dev->dbbuf.dbs = NULL;
>> +		return -ENOMEM;
>> +	}
>> +
>> +	return 0;
>
> Please use normal kernel-style goto unwinding.

I don't think it is necessary as there is only a single item to unwind. 
 From my experience in other parts of the kernel code we usually use 
goto when there are several other steps to unwind. But I don't mind 
changing it if you still prefer a goto here.

>
>> +static void nvme_dbbuf_set(struct nvme_dev *dev)
>> +{
>> +	struct nvme_command c;
>> +
>> +	if (!dev->dbbuf.dbs)
>> +		return;
>> +
>> +	memset(&c, 0, sizeof(c));
>> +	c.dbbuf.opcode = nvme_admin_dbbuf;
>> +	c.dbbuf.prp1 = cpu_to_le64(dev->dbbuf.dbs_dma_addr);
>> +	c.dbbuf.prp2 = cpu_to_le64(dev->dbbuf.eis_dma_addr);
>> +
>> +	if (nvme_submit_sync_cmd(dev->ctrl.admin_q, &c, NULL, 0))
>> +		/* Free memory and continue on */
>> +		nvme_dbbuf_dma_free(dev);
>
> At least log a warning.
>
>> +static inline int nvme_dbbuf_need_event(u16 event_idx, u16 new_idx, u16 old)
>> +{
>> +	/* Borrowed from vring_need_event */
>
> I don't think this comment matters.
>
>> +static void nvme_write_doorbell(u16 value,
>> +				u32 __iomem *db,
>> +				u32 *dbbuf_db,
>> +				volatile u32 *dbbuf_ei)
>> +{
>
> Very odd formatting.  Why not:
>
> static void nvme_write_doorbell(u16 value, u32 __iomem *db, u32 *dbbuf_db,
> 		volatile u32 *dbbuf_ei)
>
> ?
>
>> +	u16 old_value;
>> +
>> +	if (!dbbuf_db) {
>> +		writel(value, db);
>> +		return;
>> +	}
>
> I'd prefer to keep this in the ultimate callers to make the flow
> easier to read.
>
>> +static inline void nvme_write_doorbell_cq(struct nvme_queue *nvmeq, u16 value)
>> +{
>> +	nvme_write_doorbell(value, nvmeq->q_db + nvmeq->dev->db_stride,
>> +			    nvmeq->dbbuf.cq_db, nvmeq->dbbuf.cq_ei);
>> +}
>> +
>> +static inline void nvme_write_doorbell_sq(struct nvme_queue *nvmeq, u16 value)
>> +{
>> +	nvme_write_doorbell(value, nvmeq->q_db,
>> +			    nvmeq->dbbuf.sq_db, nvmeq->dbbuf.sq_ei);
>>  }
>
> I'd skip these wrappers entirely.

I added them to avoid future mistakes as mixing nvmeq->dbbuf.sq_db with 
nvmeq->dbbuf.sq_ei. But I don't mind to remove them either.

>
>> +	if (dev->ctrl.oacs & NVME_CTRL_OACS_DBBUF_SUPP) {
>> +		result = nvme_dbbuf_dma_alloc(dev);
>> +		if (result)
>> +			goto out;
>> +	}
>
> Should we really fail the init here or just print a warning?
>

  reply	other threads:[~2017-03-27 16:04 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-14 18:04 [PATCH v2 RFC] nvme: improve performance for virtual NVMe devices Helen Mae Koike Fornazier
2016-04-21 13:33 ` Helen Koike
2016-04-21 13:38   ` Christoph Hellwig
2016-04-21 18:11     ` Ming Lin
2016-04-27 15:26       ` Helen Koike
2016-05-03  8:05       ` Christoph Hellwig
2016-05-04 16:48         ` Helen Koike
2016-05-05 14:17           ` Christoph Hellwig
2016-05-11 16:50     ` Helen Koike
2016-05-11 17:43       ` Keith Busch
2016-05-12  4:05         ` Helen Koike
2016-05-12  7:05           ` Christoph Hellwig
     [not found]             ` <CALu-fzt8=kmzZDqKsRYE42Q+F+Zu3U_s6XErpd9izXdxG1cUMA@mail.gmail.com>
     [not found]               ` <CAPst7KAAymUqbNwzxNAczduF6iLXQAMm5-auEdXZ_zHwhHtbWQ@mail.gmail.com>
2016-05-12 17:29                 ` Mike Waychison
2016-05-05 15:15 ` Helen Koike
2016-05-05 15:24 ` Helen Koike
2016-08-16  1:41 ` [PATCH v3 RFC 0/2] Virtual NVMe device optimization Helen Koike
2016-08-16  1:41   ` Helen Koike
2016-08-16  1:41   ` [PATCH v3 RFC 1/2] PCI: Add Google device ID Helen Koike
2016-08-18 21:59     ` Bjorn Helgaas
2016-08-16  1:41   ` [PATCH v3 RFC 2/2] nvme: improve performance for virtual NVMe devices Helen Koike
2016-08-16  1:41     ` Helen Koike
2016-08-16 20:45     ` J Freyensee
2016-08-16 20:45       ` J Freyensee
2016-08-16 23:45       ` Keith Busch
2016-08-16 23:45         ` Keith Busch
2017-03-17 21:44     ` [PATCH v4 RFC] " Helen Koike
2017-03-17 22:28       ` Keith Busch
2017-03-17 22:26         ` Helen Koike
2017-03-24  4:23         ` [PATCH v5 " Helen Koike
2017-03-27  9:49           ` Christoph Hellwig
2017-03-27 16:04             ` Helen Koike [this message]
2017-03-27 16:25               ` Helen Koike
2017-03-27 14:43           ` Keith Busch
2017-03-27 16:50           ` [PATCH v6 " Helen Koike
2017-03-30 17:33             ` Keith Busch
2017-03-30 17:46               ` [PATCH v7 " Helen Koike
2017-03-31  7:01                 ` Christoph Hellwig
2017-04-01 21:50                   ` Helen Koike
2017-04-10 15:31                     ` Helen Koike
2017-04-10 15:37                     ` Christoph Hellwig
2017-04-10 15:51                   ` [PATCH v8] " Helen Koike
2017-04-14 18:10                     ` Helen Koike
2017-04-14 18:10                       ` Helen Koike
2017-04-17 23:01                       ` Keith Busch
2017-04-17 23:01                         ` Keith Busch
2017-04-17 23:20                         ` Helen Koike
2017-04-17 23:20                           ` Helen Koike
2017-04-20 10:22                         ` Sagi Grimberg
2017-04-20 10:22                           ` Sagi Grimberg

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=619476f4-9680-e00b-3692-175adfbf4838@collabora.co.uk \
    --to=helen.koike@collabora.co.uk \
    /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.