-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel: Set arguments based on CPU architecture
Kernel arguments like `intel_iommu=on` does not have sense on AMD or ARM systems and some user might complain about their presence, though they are likely to be harmless. Also, on ARM systems the `iommu.passthrough` parameter is the one to use [1]. Improve `GHWLib` to bridge CPU information from the library. Add `CpuInfoProviderInterface` and inject it into the GenericPlugin to implement the per CPU vendor logic. [1] https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/kernel-parameters.txt#L2343 Signed-off-by: Andrea Panattoni <[email protected]>
- Loading branch information
Showing
11 changed files
with
207 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cpu | ||
|
||
import ( | ||
"fmt" | ||
|
||
ghwPkg "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/lib/ghw" | ||
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/types" | ||
) | ||
|
||
|
||
type cpuInfoProvider struct { | ||
ghwLib ghwPkg.GHWLib | ||
} | ||
|
||
func New(ghwLib ghwPkg.GHWLib) *cpuInfoProvider { | ||
return &cpuInfoProvider{ | ||
ghwLib: ghwLib, | ||
} | ||
} | ||
|
||
|
||
func (c *cpuInfoProvider) GetCPUVendor() (types.CPUVendor, error) { | ||
cpuInfo, err := c.ghwLib.CPU() | ||
if err != nil { | ||
return -1, fmt.Errorf("can't retrieve the CPU vendor: %w", err) | ||
} | ||
|
||
if len(cpuInfo.Processors) == 0 { | ||
return -1, fmt.Errorf("wrong CPU information retrieved: %v", cpuInfo) | ||
} | ||
|
||
switch (cpuInfo.Processors[0].Vendor) { | ||
case "GenuineIntel": | ||
return types.CPUVendorIntel, nil | ||
case "AuthenticAMD": | ||
return types.CPUVendorAMD, nil | ||
case "ARM": | ||
return types.CPUVendorARM, nil | ||
} | ||
|
||
return -1, fmt.Errorf("unknown CPU vendor: %s", cpuInfo.Processors[0].Vendor) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package cpu | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"go.uber.org/zap/zapcore" | ||
"sigs.k8s.io/controller-runtime/pkg/log" | ||
"sigs.k8s.io/controller-runtime/pkg/log/zap" | ||
) | ||
|
||
|
||
|
||
var _ = Describe("Cpu", func() { | ||
// TODO | ||
}) | ||
|
||
|
||
func TestCpu(t *testing.T) { | ||
log.SetLogger(zap.New( | ||
zap.WriteTo(GinkgoWriter), | ||
zap.Level(zapcore.Level(-2)), | ||
zap.UseDevMode(true))) | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Package CPU Suite") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters