From: Leon Romanovsky <leonro@mellanox.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
Doug Ledford <dledford@redhat.com>,
linux-rdma@vger.kernel.org,
Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
Subject: Re: [PATCH 5/5] RDMA/srp: Make struct scsi_cmnd and struct srp_request adjacent
Date: Wed, 19 May 2021 12:09:41 +0300 [thread overview]
Message-ID: <YKTV1RKf4Ms+Zzx0@unreal> (raw)
In-Reply-To: <20210512032752.16611-6-bvanassche@acm.org>
On Tue, May 11, 2021 at 08:27:52PM -0700, Bart Van Assche wrote:
> Define .init_cmd_priv and .exit_cmd_priv callback functions in struct
> scsi_host_template. Set .cmd_size such that the SCSI core allocates
> per-command private data. Use scsi_cmd_priv() to access that private
> data. Remove the req_ring pointer from struct srp_rdma_ch since it is
> no longer necessary. Convert srp_alloc_req_data() and srp_free_req_data()
> into functions that initialize one instance of the SRP-private command
> data. This is a micro-optimization since this patch removes several
> pointer dereferences from the hot path.
>
> Note: due to commit e73a5e8e8003 ("scsi: core: Only return started requests
> from scsi_host_find_tag()"), it is no longer necessary to protect the
> completion path against duplicate responses.
>
> Cc: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/infiniband/ulp/srp/ib_srp.c | 156 ++++++++++++----------------
> drivers/infiniband/ulp/srp/ib_srp.h | 2 -
> 2 files changed, 65 insertions(+), 93 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
> index 52db42af421b..773ac5929082 100644
> --- a/drivers/infiniband/ulp/srp/ib_srp.c
> +++ b/drivers/infiniband/ulp/srp/ib_srp.c
> @@ -965,69 +965,55 @@ static void srp_disconnect_target(struct srp_target_port *target)
> }
> }
>
> -static void srp_free_req_data(struct srp_target_port *target,
> - struct srp_rdma_ch *ch)
> +static int srp_exit_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
> {
> + struct srp_target_port *target = host_to_target(shost);
> struct srp_device *dev = target->srp_host->srp_dev;
> struct ib_device *ibdev = dev->dev;
> - struct srp_request *req;
> - int i;
> + struct srp_request *req = scsi_cmd_priv(cmd);
>
> - if (!ch->req_ring)
> - return;
> -
> - for (i = 0; i < target->req_ring_size; ++i) {
> - req = &ch->req_ring[i];
> - if (dev->use_fast_reg)
> - kfree(req->fr_list);
> - if (req->indirect_dma_addr) {
> - ib_dma_unmap_single(ibdev, req->indirect_dma_addr,
> - target->indirect_size,
> - DMA_TO_DEVICE);
> - }
> - kfree(req->indirect_desc);
> + if (dev->use_fast_reg)
> + kfree(req->fr_list);
Isn't cleaner will be to ensure that fr_list is NULL for !dev->use_fast_reg path?
In patch #4 https://lore.kernel.org/linux-rdma/20210512032752.16611-5-bvanassche@acm.org
Thanks
next prev parent reply other threads:[~2021-05-19 9:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-12 3:27 [PATCH 0/5] SRP kernel patches for kernel v5.14 Bart Van Assche
2021-05-12 3:27 ` [PATCH 1/5] RDMA/ib_hdrs.h: Remove a superfluous cast Bart Van Assche
2021-05-19 9:00 ` Leon Romanovsky
2021-05-24 3:12 ` Bart Van Assche
2021-05-12 3:27 ` [PATCH 2/5] RDMA/srp: Add more structure size checks Bart Van Assche
2021-05-19 9:01 ` Leon Romanovsky
2021-05-12 3:27 ` [PATCH 3/5] RDMA/srp: Apply the __packed attribute to members instead of structures Bart Van Assche
2021-05-20 14:48 ` Jason Gunthorpe
2021-05-24 3:41 ` Bart Van Assche
2021-05-24 23:00 ` Jason Gunthorpe
2021-05-12 3:27 ` [PATCH 4/5] RDMA/srp: Fix a recently introduced memory leak Bart Van Assche
2021-05-12 8:15 ` Max Gurtovoy
2021-05-12 16:14 ` Bart Van Assche
2021-05-12 3:27 ` [PATCH 5/5] RDMA/srp: Make struct scsi_cmnd and struct srp_request adjacent Bart Van Assche
2021-05-19 9:09 ` Leon Romanovsky [this message]
2021-05-19 15:13 ` Bart Van Assche
2021-05-19 15:32 ` Leon Romanovsky
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=YKTV1RKf4Ms+Zzx0@unreal \
--to=leonro@mellanox.com \
--cc=bvanassche@acm.org \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=linux-rdma@vger.kernel.org \
--cc=nmoreychaisemartin@suse.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 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.