Skip to content

Commit 29e8a89

Browse files
committed
libct/intelrdt: check if available iff configured
Unless the container's runtime config has intelRdt configuration set, any checks for whether Intel RDT is supported or the resctrl filesystem is mounted are a waste of time as, per the OCI Runtime Spec, "the runtime MUST NOT manipulate any resctrl pseudo-filesystems." And in the likely case where Intel RDT is supported by both the hardware and kernel but the resctrl filesystem is not mounted, these checks can get expensive as the intelrdt package needs to parse mountinfo to check whether the filesystem has been mounted to a non-standard path. Optimize for the common case of containers with no intelRdt configuration by only performing the checks when the container has opted in. Signed-off-by: Cory Snider <[email protected]>
1 parent ddac682 commit 29e8a89

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libcontainer/intelrdt/intelrdt.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,13 @@ type Manager struct {
152152
path string
153153
}
154154

155-
// NewManager returns a new instance of Manager, or nil, if the Intel RDT
156-
// functionality is not available from hardware or not enabled in the kernel.
155+
// NewManager returns a new instance of Manager, or nil if the Intel RDT
156+
// functionality is not specified in the config, available from hardware or
157+
// enabled in the kernel.
157158
func NewManager(config *configs.Config, id string, path string) *Manager {
159+
if config.IntelRdt == nil {
160+
return nil
161+
}
158162
if _, err := Root(); err != nil {
159163
// Intel RDT is not available.
160164
return nil

0 commit comments

Comments
 (0)