From: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
To: Yuval Shaia <yuval.shaia.ml@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] hw/rdma: Cosmetic change - no need for two sge arrays
Date: Mon, 16 Mar 2020 15:32:49 +0200 [thread overview]
Message-ID: <0f105874-c15f-406e-c4e9-fd752f95aa96@gmail.com> (raw)
In-Reply-To: <20200307125608.2476-2-yuval.shaia.ml@gmail.com>
Hi Yuval,
On 3/7/20 2:56 PM, Yuval Shaia wrote:
> The function build_host_sge_array uses two sge arrays, one for input and
> one for output.
> Since the size of the two arrays is the same, the function can write
> directly to the given source array (i.e. input/output argument).
>
> Signed-off-by: Yuval Shaia <yuval.shaia.ml@gmail.com>
> ---
> hw/rdma/rdma_backend.c | 40 +++++++++++++++++-----------------------
> 1 file changed, 17 insertions(+), 23 deletions(-)
>
> diff --git a/hw/rdma/rdma_backend.c b/hw/rdma/rdma_backend.c
> index c346407cd3..79b9cfb487 100644
> --- a/hw/rdma/rdma_backend.c
> +++ b/hw/rdma/rdma_backend.c
> @@ -378,30 +378,27 @@ static void ah_cache_init(void)
> }
>
> static int build_host_sge_array(RdmaDeviceResources *rdma_dev_res,
> - struct ibv_sge *dsge, struct ibv_sge *ssge,
> - uint8_t num_sge, uint64_t *total_length)
> + struct ibv_sge *sge, uint8_t num_sge,
> + uint64_t *total_length)
> {
> RdmaRmMR *mr;
> - int ssge_idx;
> + int idx;
>
> - for (ssge_idx = 0; ssge_idx < num_sge; ssge_idx++) {
> - mr = rdma_rm_get_mr(rdma_dev_res, ssge[ssge_idx].lkey);
> + for (idx = 0; idx < num_sge; idx++) {
> + mr = rdma_rm_get_mr(rdma_dev_res, sge[idx].lkey);
> if (unlikely(!mr)) {
> - rdma_error_report("Invalid lkey 0x%x", ssge[ssge_idx].lkey);
> - return VENDOR_ERR_INVLKEY | ssge[ssge_idx].lkey;
> + rdma_error_report("Invalid lkey 0x%x", sge[idx].lkey);
> + return VENDOR_ERR_INVLKEY | sge[idx].lkey;
> }
>
> #ifdef LEGACY_RDMA_REG_MR
> - dsge->addr = (uintptr_t)mr->virt + ssge[ssge_idx].addr - mr->start;
> + sge[idx].addr = (uintptr_t)mr->virt + sge[idx].addr - mr->start;
> #else
> - dsge->addr = ssge[ssge_idx].addr;
> + sge[idx].addr = sge[idx].addr;
It seems we don't need the above line.
Other than that it looks good to me.
Thanks,
Marcel
> #endif
> - dsge->length = ssge[ssge_idx].length;
> - dsge->lkey = rdma_backend_mr_lkey(&mr->backend_mr);
> + sge[idx].lkey = rdma_backend_mr_lkey(&mr->backend_mr);
>
> - *total_length += dsge->length;
> -
> - dsge++;
> + *total_length += sge[idx].length;
> }
>
> return 0;
> @@ -484,7 +481,6 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
> void *ctx)
> {
> BackendCtx *bctx;
> - struct ibv_sge new_sge[MAX_SGE];
> uint32_t bctx_id;
> int rc;
> struct ibv_send_wr wr = {}, *bad_wr;
> @@ -518,7 +514,7 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
>
> rdma_protected_gslist_append_int32(&qp->cqe_ctx_list, bctx_id);
>
> - rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, num_sge,
> + rc = build_host_sge_array(backend_dev->rdma_dev_res, sge, num_sge,
> &backend_dev->rdma_dev_res->stats.tx_len);
> if (rc) {
> complete_work(IBV_WC_GENERAL_ERR, rc, ctx);
> @@ -538,7 +534,7 @@ void rdma_backend_post_send(RdmaBackendDev *backend_dev,
> wr.num_sge = num_sge;
> wr.opcode = IBV_WR_SEND;
> wr.send_flags = IBV_SEND_SIGNALED;
> - wr.sg_list = new_sge;
> + wr.sg_list = sge;
> wr.wr_id = bctx_id;
>
> rc = ibv_post_send(qp->ibqp, &wr, &bad_wr);
> @@ -601,7 +597,6 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
> struct ibv_sge *sge, uint32_t num_sge, void *ctx)
> {
> BackendCtx *bctx;
> - struct ibv_sge new_sge[MAX_SGE];
> uint32_t bctx_id;
> int rc;
> struct ibv_recv_wr wr = {}, *bad_wr;
> @@ -635,7 +630,7 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
>
> rdma_protected_gslist_append_int32(&qp->cqe_ctx_list, bctx_id);
>
> - rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, num_sge,
> + rc = build_host_sge_array(backend_dev->rdma_dev_res, sge, num_sge,
> &backend_dev->rdma_dev_res->stats.rx_bufs_len);
> if (rc) {
> complete_work(IBV_WC_GENERAL_ERR, rc, ctx);
> @@ -643,7 +638,7 @@ void rdma_backend_post_recv(RdmaBackendDev *backend_dev,
> }
>
> wr.num_sge = num_sge;
> - wr.sg_list = new_sge;
> + wr.sg_list = sge;
> wr.wr_id = bctx_id;
> rc = ibv_post_recv(qp->ibqp, &wr, &bad_wr);
> if (rc) {
> @@ -671,7 +666,6 @@ void rdma_backend_post_srq_recv(RdmaBackendDev *backend_dev,
> uint32_t num_sge, void *ctx)
> {
> BackendCtx *bctx;
> - struct ibv_sge new_sge[MAX_SGE];
> uint32_t bctx_id;
> int rc;
> struct ibv_recv_wr wr = {}, *bad_wr;
> @@ -688,7 +682,7 @@ void rdma_backend_post_srq_recv(RdmaBackendDev *backend_dev,
>
> rdma_protected_gslist_append_int32(&srq->cqe_ctx_list, bctx_id);
>
> - rc = build_host_sge_array(backend_dev->rdma_dev_res, new_sge, sge, num_sge,
> + rc = build_host_sge_array(backend_dev->rdma_dev_res, sge, num_sge,
> &backend_dev->rdma_dev_res->stats.rx_bufs_len);
> if (rc) {
> complete_work(IBV_WC_GENERAL_ERR, rc, ctx);
> @@ -696,7 +690,7 @@ void rdma_backend_post_srq_recv(RdmaBackendDev *backend_dev,
> }
>
> wr.num_sge = num_sge;
> - wr.sg_list = new_sge;
> + wr.sg_list = sge;
> wr.wr_id = bctx_id;
> rc = ibv_post_srq_recv(srq->ibsrq, &wr, &bad_wr);
> if (rc) {
next prev parent reply other threads:[~2020-03-16 15:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-07 12:56 [PATCH 0/2] hw/rdma: Last step in eliminating data-path processing Yuval Shaia
2020-03-07 12:56 ` [PATCH 1/2] hw/rdma: Cosmetic change - no need for two sge arrays Yuval Shaia
2020-03-16 13:32 ` Marcel Apfelbaum [this message]
2020-03-20 12:30 ` Yuval Shaia
2020-03-07 12:56 ` [PATCH 2/2] hw/rdma: Skip data-path mr_id translation Yuval Shaia
2020-03-16 13:37 ` Marcel Apfelbaum
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=0f105874-c15f-406e-c4e9-fd752f95aa96@gmail.com \
--to=marcel.apfelbaum@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=yuval.shaia.ml@gmail.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;
as well as URLs for NNTP newsgroup(s).