Message ID | 20210512032752.16611-5-bvanassche@acm.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | SRP kernel patches for kernel v5.14 | expand |
On 5/12/2021 6:27 AM, Bart Van Assche wrote: > Only allocate an mr_list if it will be used and if it will be freed. > > Cc: Max Gurtovoy <maxg@mellanox.com> > Cc: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com> > Fixes: f273ad4f8d90 ("RDMA/srp: Remove support for FMR memory registration") > Signed-off-by: Bart Van Assche <bvanassche@acm.org> > --- > drivers/infiniband/ulp/srp/ib_srp.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c > index 0f66bf015db6..52db42af421b 100644 > --- a/drivers/infiniband/ulp/srp/ib_srp.c > +++ b/drivers/infiniband/ulp/srp/ib_srp.c > @@ -1009,12 +1009,13 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch) > > for (i = 0; i < target->req_ring_size; ++i) { > req = &ch->req_ring[i]; > - mr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *), > - GFP_KERNEL); > - if (!mr_list) > - goto out; > - if (srp_dev->use_fast_reg) > + if (srp_dev->use_fast_reg) { > + mr_list = kmalloc_array(target->mr_per_cmd, > + sizeof(void *), GFP_KERNEL); > + if (!mr_list) > + goto out; > req->fr_list = mr_list; > + } > req->indirect_desc = kmalloc(target->indirect_size, GFP_KERNEL); > if (!req->indirect_desc) > goto out; Looks good, maybe we can remove the local mr_list variable while we're here ? otherwise, Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
On 5/12/21 1:15 AM, Max Gurtovoy wrote: > maybe we can remove the local mr_list variable while we're here ? > > otherwise, > > Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com> Hi Max, I will remove the mr_list variable if I have to repost this patch series. Thanks, Bart.
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 0f66bf015db6..52db42af421b 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -1009,12 +1009,13 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch) for (i = 0; i < target->req_ring_size; ++i) { req = &ch->req_ring[i]; - mr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *), - GFP_KERNEL); - if (!mr_list) - goto out; - if (srp_dev->use_fast_reg) + if (srp_dev->use_fast_reg) { + mr_list = kmalloc_array(target->mr_per_cmd, + sizeof(void *), GFP_KERNEL); + if (!mr_list) + goto out; req->fr_list = mr_list; + } req->indirect_desc = kmalloc(target->indirect_size, GFP_KERNEL); if (!req->indirect_desc) goto out;
Only allocate an mr_list if it will be used and if it will be freed. Cc: Max Gurtovoy <maxg@mellanox.com> Cc: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com> Fixes: f273ad4f8d90 ("RDMA/srp: Remove support for FMR memory registration") Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/infiniband/ulp/srp/ib_srp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)