[rh7] i40iw: use kvzalloc for large allocation of iwdev->mem_resources

Submitted by Andrey Ryabinin on June 11, 2019, 4:29 p.m.

Details

Message ID 20190611162951.3838-1-aryabinin@virtuozzo.com
State New
Series "i40iw: use kvzalloc for large allocation of iwdev->mem_resources"
Headers show

Commit Message

Andrey Ryabinin June 11, 2019, 4:29 p.m.
10-order allocation needed for iwdev->mem_resources in
i40iw_initialize_hw_resources() may easily fail under memory fragmentation.
Use kvzalloc to fallback to 0-order pages when high order aren't available.

https://pmc.acronis.com/browse/VSTOR-23649
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 drivers/infiniband/hw/i40iw/i40iw_hw.c   | 2 +-
 drivers/infiniband/hw/i40iw/i40iw_main.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/infiniband/hw/i40iw/i40iw_hw.c b/drivers/infiniband/hw/i40iw/i40iw_hw.c
index 6139836fb533..318cb390c1c5 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_hw.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_hw.c
@@ -70,7 +70,7 @@  u32 i40iw_initialize_hw_resources(struct i40iw_device *iwdev)
 	resources_size += sizeof(unsigned long) * BITS_TO_LONGS(num_pds);
 	resources_size += sizeof(unsigned long) * BITS_TO_LONGS(arp_table_size);
 	resources_size += sizeof(struct i40iw_qp **) * max_qp;
-	iwdev->mem_resources = kzalloc(resources_size, GFP_KERNEL);
+	iwdev->mem_resources = kvzalloc(resources_size, GFP_KERNEL);
 
 	if (!iwdev->mem_resources)
 		return -ENOMEM;
diff --git a/drivers/infiniband/hw/i40iw/i40iw_main.c b/drivers/infiniband/hw/i40iw/i40iw_main.c
index cc19eb328a13..f20599e5b4ce 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_main.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_main.c
@@ -1027,7 +1027,7 @@  static void i40iw_del_init_mem(struct i40iw_device *iwdev)
 	i40iw_free_dma_mem(&iwdev->hw, &iwdev->obj_mem);
 	kfree(dev->hmc_info->sd_table.sd_entry);
 	dev->hmc_info->sd_table.sd_entry = NULL;
-	kfree(iwdev->mem_resources);
+	kvfree(iwdev->mem_resources);
 	iwdev->mem_resources = NULL;
 	kfree(iwdev->ceqlist);
 	iwdev->ceqlist = NULL;