From f63b13d2d040726f139199ad95416da0a212e393 Mon Sep 17 00:00:00 2001 From: William Zhao Date: Thu, 3 Aug 2023 18:23:20 -0400 Subject: [PATCH] Set kernel param PCI realloc on "cannot allocate memory" on VF creation When creating VFs via sysfs sriov_numvfs, there is a chance of getting the error "cannot allocate memory". This could occur when the BIOS is not providing enough MMIO space for VFs. A solution is to reallocate the MMIO space via "pci=realloc". Signed-off-by: William Zhao --- pkg/plugins/generic/generic_plugin.go | 3 +++ pkg/utils/utils.go | 1 + 2 files changed, 4 insertions(+) diff --git a/pkg/plugins/generic/generic_plugin.go b/pkg/plugins/generic/generic_plugin.go index 3502e422f..f8f0e9fb0 100644 --- a/pkg/plugins/generic/generic_plugin.go +++ b/pkg/plugins/generic/generic_plugin.go @@ -124,6 +124,9 @@ func (p *GenericPlugin) Apply() error { } if err := utils.SyncNodeState(p.DesireState, pfsToSkip); err != nil { + if strings.Contains(err.Error(), "cannot allocate memory") { + p.AddToDesiredKernelParams(utils.KernelParamPciRealloc) + } return err } p.LastState = &sriovnetworkv1.SriovNetworkNodeState{} diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 7899cec3d..45e6381b3 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -42,6 +42,7 @@ const ( DeviceBF2 = "a2d6" DeviceBF3 = "a2dc" + KernelParamPciRealloc = "pci=realloc" KernelParamIntelIommu = "intel_iommu=on" KernelParamIommuPt = "iommu=pt" )