From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH] NVMe: Reduce divide operations
Date: Thu, 20 Nov 2014 23:41:36 +0000 (UTC) [thread overview]
Message-ID: <alpine.LNX.2.00.1411202312020.4225@localhost.lm.intel.com> (raw)
In-Reply-To: <546E6784.6000609@micron.com>
On Thu, 20 Nov 2014, Sam Bradshaw wrote:
> There are several expensive divide operations in the submit and
> completion paths that can be converted to less expensive arithmetic
> and logical operations. Profiling shows significant drops in time
> spent in nvme_alloc_iod() under common workloads as a result of this
> change.
Very cool. I didn't see a difference on my processor's TSC when I added
even more divides to the IO path for mismatched page size support,
but I was afraid it'd have higher cost elsewhere. Thanks for the patch.
> Patch is against Jens' for-3.19/drivers branch.
>
> Signed-off-by: Sam Bradshaw <sbradshaw at micron.com>
> ---
> diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
> index 9310fe5..a5e2ebc 100644
> --- a/drivers/block/nvme-core.c
> +++ b/drivers/block/nvme-core.c
> @@ -360,8 +360,14 @@ static __le64 **iod_list(struct nvme_iod *iod)
> */
> static int nvme_npages(unsigned size, struct nvme_dev *dev)
> {
> - unsigned nprps = DIV_ROUND_UP(size + dev->page_size, dev->page_size);
> - return DIV_ROUND_UP(8 * nprps, dev->page_size - 8);
> + unsigned page_size = (1 << dev->page_shift);
> + unsigned nprps = (size >> dev->page_shift) + 1;
> +
> + if (size & (page_size - 1))
> + nprps++;
> + if ((nprps << 3) < (page_size - 8))
> + return 1;
You actually don't need to subtract 8 here. That's for reserving a place
for chaining a PRP list, but we don't need to reserve a place if all
the entries fit in page.
> + return DIV_ROUND_UP(nprps << 3, page_size - 8);
Can we get rid of this divide too?!
next prev parent reply other threads:[~2014-11-20 23:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-20 22:13 [PATCH] NVMe: Reduce divide operations Sam Bradshaw
2014-11-20 23:41 ` Keith Busch [this message]
2014-11-21 17:36 ` Sam Bradshaw (sbradshaw)
2014-11-21 13:50 ` Matthew Wilcox
2014-11-21 15:52 ` Keith Busch
2014-11-21 17:14 ` Matthew Wilcox
2014-11-21 17:38 ` Sam Bradshaw (sbradshaw)
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=alpine.LNX.2.00.1411202312020.4225@localhost.lm.intel.com \
--to=keith.busch@intel.com \
/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