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

Andrey Ryabinin aryabinin at virtuozzo.com
Tue Jun 11 19:29:51 MSK 2019


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 at 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(-)

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;
-- 
2.21.0



More information about the Devel mailing list