Skip to content

Commit

Permalink
libct/intelrdt: check if available iff configured
Browse files Browse the repository at this point in the history
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 <csnider@mirantis.com>
(cherry picked from commit ea0bd78)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
corhere authored and lifubang committed Aug 10, 2023
1 parent 6cf9ac1 commit f44190e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libcontainer/intelrdt/intelrdt.go
Expand Up @@ -152,9 +152,13 @@ type Manager struct {
path string
}

// NewManager returns a new instance of Manager, or nil, if the Intel RDT
// functionality is not available from hardware or not enabled in the kernel.
// NewManager returns a new instance of Manager, or nil if the Intel RDT
// functionality is not specified in the config, available from hardware or
// enabled in the kernel.
func NewManager(config *configs.Config, id string, path string) *Manager {
if config.IntelRdt == nil {
return nil
}
if _, err := Root(); err != nil {
// Intel RDT is not available.
return nil
Expand Down

0 comments on commit f44190e

Please sign in to comment.