OSDN Git Service

ib_srpt: use kvmalloc to allocate ring pointers
authorJan Dakinevich <jan.dakinevich@virtuozzo.com>
Mon, 9 Jul 2018 13:51:08 +0000 (16:51 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 10 Jul 2018 17:13:05 +0000 (11:13 -0600)
An array of pointers to SRPT contexts in ib_device is over 30KiB even
in default case, in which an amount of contexts is 4095. The patch
is intended to weed out large contigous allocation for non-DMA memory.

Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/ulp/srpt/ib_srpt.c

index e42eec2..3cb99ca 100644 (file)
@@ -719,7 +719,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev,
        WARN_ON(ioctx_size != sizeof(struct srpt_recv_ioctx)
                && ioctx_size != sizeof(struct srpt_send_ioctx));
 
-       ring = kmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL);
+       ring = kvmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL);
        if (!ring)
                goto out;
        for (i = 0; i < ring_size; ++i) {
@@ -733,7 +733,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev,
 err:
        while (--i >= 0)
                srpt_free_ioctx(sdev, ring[i], dma_size, dir);
-       kfree(ring);
+       kvfree(ring);
        ring = NULL;
 out:
        return ring;
@@ -758,7 +758,7 @@ static void srpt_free_ioctx_ring(struct srpt_ioctx **ioctx_ring,
 
        for (i = 0; i < ring_size; ++i)
                srpt_free_ioctx(sdev, ioctx_ring[i], dma_size, dir);
-       kfree(ioctx_ring);
+       kvfree(ioctx_ring);
 }
 
 /**