From d9fda11c55381895103f06fe89ce1d7ac56ef1a7 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 19 Jan 2022 11:15:28 +0100 Subject: [PATCH 1/2] libct.IntelRdtFs(): simplify - remove unneeded wrapping func, as intelrdt.NewManager already has the correct signature. - reverse the if/else to be clearer that either "IsCATEnabled()" and/or "IsMBAEnabled()" need to be enabled (and to allow skipping one of those checks in the condition). Signed-off-by: Sebastiaan van Stijn --- libcontainer/factory_linux.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libcontainer/factory_linux.go b/libcontainer/factory_linux.go index 023d623f370..d20432284f1 100644 --- a/libcontainer/factory_linux.go +++ b/libcontainer/factory_linux.go @@ -48,16 +48,14 @@ func InitArgs(args ...string) func(*LinuxFactory) error { } } -// IntelRdtfs is an options func to configure a LinuxFactory to return +// IntelRdtFs is an options func to configure a LinuxFactory to return // containers that use the Intel RDT "resource control" filesystem to // create and manage Intel RDT resources (e.g., L3 cache, memory bandwidth). func IntelRdtFs(l *LinuxFactory) error { - if !intelrdt.IsCATEnabled() && !intelrdt.IsMBAEnabled() { - l.NewIntelRdtManager = nil + if intelrdt.IsCATEnabled() || intelrdt.IsMBAEnabled() { + l.NewIntelRdtManager = intelrdt.NewManager } else { - l.NewIntelRdtManager = func(config *configs.Config, id string, path string) intelrdt.Manager { - return intelrdt.NewManager(config, id, path) - } + l.NewIntelRdtManager = nil } return nil } From c149d2ba5b2890884cb2e29bf63e5c428d143224 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 19 Jan 2022 11:25:21 +0100 Subject: [PATCH 2/2] loadFactory(): remove unneeded intermediate variable Signed-off-by: Sebastiaan van Stijn --- utils_linux.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/utils_linux.go b/utils_linux.go index a9badf20f8b..dbd69425018 100644 --- a/utils_linux.go +++ b/utils_linux.go @@ -32,8 +32,6 @@ func loadFactory(context *cli.Context) (libcontainer.Factory, error) { return nil, err } - intelRdtManager := libcontainer.IntelRdtFs - // We resolve the paths for {newuidmap,newgidmap} from the context of runc, // to avoid doing a path lookup in the nsexec context. TODO: The binary // names are not currently configurable. @@ -46,7 +44,7 @@ func loadFactory(context *cli.Context) (libcontainer.Factory, error) { newgidmap = "" } - return libcontainer.New(abs, intelRdtManager, + return libcontainer.New(abs, libcontainer.IntelRdtFs, libcontainer.CriuPath(context.GlobalString("criu")), libcontainer.NewuidmapPath(newuidmap), libcontainer.NewgidmapPath(newgidmap))