From: Christoph Hellwig <hch@lst.de>
To: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Cc: kbusch@kernel.org, hch@lst.de, linux-nvme@lists.infradead.org,
sagi@grimberg.me
Subject: Re: [PATCH V2 2/2] nvme-pci: use max of PRP or SGL for iod size
Date: Mon, 13 Jul 2020 09:42:55 +0200 [thread overview]
Message-ID: <20200713074254.GC14676@lst.de> (raw)
In-Reply-To: <20200709234025.10673-3-chaitanya.kulkarni@wdc.com>
On Thu, Jul 09, 2020 at 04:40:25PM -0700, Chaitanya Kulkarni wrote:
> >From the initial implementation of NVMe SGL kernel support
> commit a7a7cbe353a5 ("nvme-pci: add SGL support") with addition of the
> commit 943e942e6266 ("nvme-pci: limit max IO size and segments to avoid
> high order allocations") now there is only caller left for
> nvme_pci_iod_alloc_size() which statically passes true for last
> parameter that calculates allocation size based on SGL since we need
> size of biggest command supported for mempool allocation.
>
> This patch modifies the helper functions nvme_pci_iod_alloc_size() such
> that it is now uses maximum of PRP and SGL size for iod allocation size
> calculation.
>
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
> drivers/nvme/host/pci.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 68f7c090cf51..8b6792005360 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -363,14 +363,13 @@ static int nvme_pci_npages_sgl(unsigned int num_seg)
> }
>
> static size_t nvme_pci_iod_alloc_size(struct nvme_dev *dev,
> - unsigned int size, unsigned int nseg, bool use_sgl)
> + unsigned int size, unsigned int nseg)
> {
> - size_t alloc_size;
> + size_t npages_sgl = nvme_pci_npages_sgl(nseg);
> + size_t npages = nvme_npages(size, dev);
> + size_t alloc_size = sizeof(__le64 *);
>
> - if (use_sgl)
> - alloc_size = sizeof(__le64 *) * nvme_pci_npages_sgl(nseg);
> - else
> - alloc_size = sizeof(__le64 *) * nvme_npages(size, dev);
> + alloc_size *= max_t(size_t, npages_sgl, npages);
>
> return alloc_size + sizeof(struct scatterlist) * nseg;
> }
> @@ -2812,7 +2811,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> * command we support.
> */
> alloc_size = nvme_pci_iod_alloc_size(dev, NVME_MAX_KB_SZ,
> - NVME_MAX_SEGS, true);
> + NVME_MAX_SEGS);
I think we can just remove the size and nseg arguments and hard code them
in the function itself.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2020-07-13 7:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-09 23:40 [PATCH V2 0/2] nvme: fix iod size calculation in nvme_probe() Chaitanya Kulkarni
2020-07-09 23:40 ` [PATCH V2 1/2] nvme-core: replace ctrl page size with a macro Chaitanya Kulkarni
2020-07-10 14:57 ` Keith Busch
2020-07-11 18:20 ` Chaitanya Kulkarni
2020-07-13 7:42 ` Christoph Hellwig
2020-07-14 0:02 ` Chaitanya Kulkarni
2020-07-14 16:44 ` Keith Busch
2020-07-09 23:40 ` [PATCH V2 2/2] nvme-pci: use max of PRP or SGL for iod size Chaitanya Kulkarni
2020-07-13 7:42 ` Christoph Hellwig [this message]
2020-07-13 23:59 ` Chaitanya Kulkarni
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=20200713074254.GC14676@lst.de \
--to=hch@lst.de \
--cc=chaitanya.kulkarni@wdc.com \
--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 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.