All of lore.kernel.org
 help / color / mirror / Atom feed
From: sagig@dev.mellanox.co.il (Sagi Grimberg)
Subject: [PATCH 10/18] nvme: move nvme_setup_flush and nvme_setup_rw to common code
Date: Tue, 20 Oct 2015 14:01:06 +0300	[thread overview]
Message-ID: <56261EF2.3080507@dev.mellanox.co.il> (raw)
In-Reply-To: <1444975128-8768-11-git-send-email-hch@lst.de>

On 10/16/2015 8:58 AM, Christoph Hellwig wrote:
> And mark them inline so that we don't slow down the I/O submission path by
> having to turn it into a forced out of line call.
>
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
>   drivers/nvme/host/nvme.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
>   drivers/nvme/host/pci.c  | 49 ----------------------------------------------
>   2 files changed, 51 insertions(+), 49 deletions(-)
>
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index a4f2f2c..6c77db7 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -80,6 +80,57 @@ static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector)
>   	return (sector >> (ns->lba_shift - 9));
>   }
>
> +static inline void nvme_setup_flush(struct nvme_ns *ns,
> +		struct nvme_command *cmnd)
> +{
> +	memset(cmnd, 0, sizeof(*cmnd));
> +	cmnd->common.opcode = nvme_cmd_flush;
> +	cmnd->common.nsid = cpu_to_le32(ns->ns_id);
> +}
> +
> +static inline void nvme_setup_rw(struct nvme_ns *ns, struct request *req,
> +		struct nvme_command *cmnd)
> +{
> +	u16 control = 0;
> +	u32 dsmgmt = 0;
> +
> +	if (req->cmd_flags & REQ_FUA)
> +		control |= NVME_RW_FUA;
> +	if (req->cmd_flags & (REQ_FAILFAST_DEV | REQ_RAHEAD))
> +		control |= NVME_RW_LR;
> +
> +	if (req->cmd_flags & REQ_RAHEAD)
> +		dsmgmt |= NVME_RW_DSM_FREQ_PREFETCH;
> +
> +	memset(cmnd, 0, sizeof(*cmnd));
> +	cmnd->rw.opcode = (rq_data_dir(req) ? nvme_cmd_write : nvme_cmd_read);
> +	cmnd->rw.command_id = req->tag;
> +	cmnd->rw.nsid = cpu_to_le32(ns->ns_id);
> +	cmnd->rw.slba = cpu_to_le64(nvme_block_nr(ns, blk_rq_pos(req)));
> +	cmnd->rw.length = cpu_to_le16((blk_rq_bytes(req) >> ns->lba_shift) - 1);
> +
> +	if (ns->ms) {
> +		switch (ns->pi_type) {
> +		case NVME_NS_DPS_PI_TYPE3:
> +			control |= NVME_RW_PRINFO_PRCHK_GUARD;
> +			break;
> +		case NVME_NS_DPS_PI_TYPE1:
> +		case NVME_NS_DPS_PI_TYPE2:
> +			control |= NVME_RW_PRINFO_PRCHK_GUARD |
> +					NVME_RW_PRINFO_PRCHK_REF;
> +			cmnd->rw.reftag = cpu_to_le32(
> +					nvme_block_nr(ns, blk_rq_pos(req)));
> +			break;
> +		}
> +		if (!blk_integrity_rq(req))
> +			control |= NVME_RW_PRINFO_PRACT;
> +	}
> +
> +	cmnd->rw.control = cpu_to_le16(control);
> +	cmnd->rw.dsmgmt = cpu_to_le32(dsmgmt);
> +}
> +
> +

Hi Christoph,

I do agree that making these static inline can speed things up here,
but the coding style documentation asks to avoid inline'ing functions
longer than a few lines of code (See Documentation/CodingStyle Chapter
15: "The inline disease").

Do you think this case qualifies as an exception?

  reply	other threads:[~2015-10-20 11:01 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-16  5:58 nvme driver split V2 Christoph Hellwig
2015-10-16  5:58 ` [PATCH 01/18] nvme: add missing unmaps in nvme_queue_rq Christoph Hellwig
2015-10-16  5:58   ` Christoph Hellwig
2015-10-20 10:04   ` Sagi Grimberg
2015-10-20 10:04     ` Sagi Grimberg
2015-10-20 14:07     ` Busch, Keith
2015-10-20 14:07       ` Busch, Keith
2015-10-16  5:58 ` [PATCH 02/18] nvme: move struct nvme_iod to pci.c Christoph Hellwig
2015-10-20 10:04   ` Sagi Grimberg
2015-10-16  5:58 ` [PATCH 03/18] nvme: split command submission helpers out of pci.c Christoph Hellwig
2015-10-20 10:07   ` Sagi Grimberg
2015-10-21 18:48   ` J Freyensee
2015-10-16  5:58 ` [PATCH 04/18] nvme: add a vendor field to struct nvme_dev Christoph Hellwig
2015-10-20 10:08   ` Sagi Grimberg
2015-10-21 18:58   ` J Freyensee
2015-10-21 19:10     ` Busch, Keith
2015-10-16  5:58 ` [PATCH 05/18] nvme: use offset instead of a struct for registers Christoph Hellwig
2015-10-16 17:30   ` Busch, Keith
2015-10-21 20:28   ` J Freyensee
2015-10-16  5:58 ` [PATCH 06/18] nvme: split a new struct nvme_ctrl out of struct nvme_dev Christoph Hellwig
2015-10-20 10:19   ` Sagi Grimberg
2015-10-20 10:26     ` Christoph Hellwig
2015-10-20 10:44       ` Sagi Grimberg
2015-10-20 11:30         ` Christoph Hellwig
2015-10-21 14:40           ` Sagi Grimberg
2015-10-21 21:23   ` J Freyensee
2015-10-21 22:51     ` Busch, Keith
2015-10-22  0:15       ` J Freyensee
2015-10-22  7:37     ` Christoph Hellwig
2015-10-16  5:58 ` [PATCH 07/18] nvme: simplify nvme_setup_prps calling convention Christoph Hellwig
2015-10-20 10:30   ` Sagi Grimberg
2015-10-16  5:58 ` [PATCH 08/18] nvme: refactor nvme_queue_rq Christoph Hellwig
2015-10-16  5:58 ` [PATCH 09/18] nvme: move nvme_error_status to common code Christoph Hellwig
2015-10-20 10:54   ` Sagi Grimberg
2015-10-16  5:58 ` [PATCH 10/18] nvme: move nvme_setup_flush and nvme_setup_rw " Christoph Hellwig
2015-10-20 11:01   ` Sagi Grimberg [this message]
2015-10-21  6:55     ` Christoph Hellwig
2015-10-21 14:41       ` Sagi Grimberg
2015-10-16  5:58 ` [PATCH 11/18] nvme: split __nvme_submit_sync_cmd Christoph Hellwig
2015-10-16  5:58 ` [PATCH 12/18] nvme: use the block layer for userspace passthrough metadata Christoph Hellwig
2015-10-16 20:04   ` Busch, Keith
2015-10-18 18:22     ` Christoph Hellwig
2015-10-16  5:58 ` [PATCH 13/18] nvme: move block_device_operations and ns/ctrl freeing to common code Christoph Hellwig
2015-10-16  5:58 ` [PATCH 14/18] nvme: add explicit quirk handling Christoph Hellwig
2015-10-16  5:58 ` [PATCH 15/18] nvme: add a common helper to read Identify Controller data Christoph Hellwig
2015-10-21 22:44   ` J Freyensee
2015-10-22  7:38     ` Christoph Hellwig
2015-10-16  5:58 ` [PATCH 16/18] nvme: move the call to nvme_init_identify earlier Christoph Hellwig
2015-10-16  5:58 ` [PATCH 17/18] nvme: move namespace scanning to common code Christoph Hellwig
2015-10-16  6:14   ` Ming Lin
2015-10-16  6:16     ` Christoph Hellwig
2015-10-21 23:27   ` J Freyensee
2015-10-22  7:39     ` Christoph Hellwig
2015-10-22 13:48       ` Busch, Keith
2015-10-22 16:30         ` Christoph Hellwig
2015-10-22 21:24           ` Busch, Keith
2015-10-23  5:41             ` Christoph Hellwig
2015-10-16  5:58 ` [PATCH 18/18] nvme: move chardev and sysfs interface " Christoph Hellwig
2015-10-22  0:11   ` J Freyensee
2015-10-22  7:45     ` Christoph Hellwig
2015-10-22 18:36       ` J Freyensee
2015-10-22 18:59         ` Jon Derrick

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=56261EF2.3080507@dev.mellanox.co.il \
    --to=sagig@dev.mellanox.co.il \
    /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.