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

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jun 18 15:33:03 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.45
------>
commit e8cdc18637f50bd4d5047c2ff3acff1fef34ac51
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Fri Jun 18 15:33:02 2021 +0300

    i40iw: use kvzalloc for large allocation of iwdev->mem_resources
    
    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>
    
    https://jira.sw.ru/browse/PSBM-127846
    (cherry-picked from vz7 commit 99c3d1b2d531 ("i40iw: use kvzalloc for
    large allocation of iwdev->mem_resources"))
    Signed-off-by: Pavel Tikhomirov <ptikhomirov 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 55a1fbf0e670..9a9ed9a09983 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 07b4743156c4..d58785ef9e95 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_main.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_main.c
@@ -1026,7 +1026,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;


More information about the Devel mailing list