Skip to content

Commit d59b17d

Browse files
committed
libcontainer: intelrdt: Add more check if sub-features are enabled
Double check if Intel RDT sub-features are available in "resource control" filesystem. Intel RDT sub-features can be selectively disabled or enabled by kernel command line (e.g., rdt=!l3cat,mba) in 4.14 and newer kernel. Signed-off-by: Xiaochen Shen <[email protected]>
1 parent f097339 commit d59b17d

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

libcontainer/intelrdt/intelrdt.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,29 @@ func init() {
179179
// "cat_l3" flag for CAT and "mba" flag for MBA
180180
isCatFlagSet, isMbaFlagSet, err := parseCpuInfoFile("/proc/cpuinfo")
181181
if err != nil {
182-
isCatEnabled = false
183-
isMbaEnabled = false
184182
return
185183
}
186184

187185
// 2. Check if Intel RDT "resource control" filesystem is mounted
188186
// The user guarantees to mount the filesystem
189-
isFsMounted := isIntelRdtMounted()
190-
isCatEnabled = isCatFlagSet && isFsMounted
191-
isMbaEnabled = isMbaFlagSet && isFsMounted
187+
if !isIntelRdtMounted() {
188+
return
189+
}
190+
191+
// 3. Double check if Intel RDT sub-features are available in
192+
// "resource control" filesystem. Intel RDT sub-features can be
193+
// selectively disabled or enabled by kernel command line
194+
// (e.g., rdt=!l3cat,mba) in 4.14 and newer kernel
195+
if isCatFlagSet {
196+
if _, err := os.Stat(filepath.Join(intelRdtRoot, "info", "L3")); err == nil {
197+
isCatEnabled = true
198+
}
199+
}
200+
if isMbaFlagSet {
201+
if _, err := os.Stat(filepath.Join(intelRdtRoot, "info", "MB")); err == nil {
202+
isMbaEnabled = true
203+
}
204+
}
192205
}
193206

194207
// Return the mount point path of Intel RDT "resource control" filesysem

0 commit comments

Comments
 (0)