Skip to content

Commit dea6fff

Browse files
committed
libcontainer/intelrdt: rename CAT and MBA enabled flags
Rename CAT and MBA enabled flags to be consistent with others. No functional change. Signed-off-by: Xiaochen Shen <[email protected]>
1 parent 3c4c811 commit dea6fff

File tree

8 files changed

+42
-42
lines changed

8 files changed

+42
-42
lines changed

events.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ func convertLibcontainerStats(ls *libcontainer.Stats) *types.Stats {
154154
}
155155

156156
if is := ls.IntelRdtStats; is != nil {
157-
if intelrdt.IsCatEnabled() {
157+
if intelrdt.IsCATEnabled() {
158158
s.IntelRdt.L3CacheInfo = convertL3CacheInfo(is.L3CacheInfo)
159159
s.IntelRdt.L3CacheSchemaRoot = is.L3CacheSchemaRoot
160160
s.IntelRdt.L3CacheSchema = is.L3CacheSchema
161161
}
162-
if intelrdt.IsMbaEnabled() {
162+
if intelrdt.IsMBAEnabled() {
163163
s.IntelRdt.MemBwInfo = convertMemBwInfo(is.MemBwInfo)
164164
s.IntelRdt.MemBwSchemaRoot = is.MemBwSchemaRoot
165165
s.IntelRdt.MemBwSchema = is.MemBwSchema

libcontainer/configs/validate/validator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,21 +182,21 @@ func (v *ConfigValidator) sysctl(config *configs.Config) error {
182182

183183
func (v *ConfigValidator) intelrdt(config *configs.Config) error {
184184
if config.IntelRdt != nil {
185-
if !intelrdt.IsCatEnabled() && !intelrdt.IsMbaEnabled() {
185+
if !intelrdt.IsCATEnabled() && !intelrdt.IsMBAEnabled() {
186186
return errors.New("intelRdt is specified in config, but Intel RDT is not supported or enabled")
187187
}
188188

189-
if !intelrdt.IsCatEnabled() && config.IntelRdt.L3CacheSchema != "" {
189+
if !intelrdt.IsCATEnabled() && config.IntelRdt.L3CacheSchema != "" {
190190
return errors.New("intelRdt.l3CacheSchema is specified in config, but Intel RDT/CAT is not enabled")
191191
}
192-
if !intelrdt.IsMbaEnabled() && config.IntelRdt.MemBwSchema != "" {
192+
if !intelrdt.IsMBAEnabled() && config.IntelRdt.MemBwSchema != "" {
193193
return errors.New("intelRdt.memBwSchema is specified in config, but Intel RDT/MBA is not enabled")
194194
}
195195

196-
if intelrdt.IsCatEnabled() && config.IntelRdt.L3CacheSchema == "" {
196+
if intelrdt.IsCATEnabled() && config.IntelRdt.L3CacheSchema == "" {
197197
return errors.New("Intel RDT/CAT is enabled and intelRdt is specified in config, but intelRdt.l3CacheSchema is empty")
198198
}
199-
if intelrdt.IsMbaEnabled() && config.IntelRdt.MemBwSchema == "" {
199+
if intelrdt.IsMBAEnabled() && config.IntelRdt.MemBwSchema == "" {
200200
return errors.New("Intel RDT/MBA is enabled and intelRdt is specified in config, but intelRdt.memBwSchema is empty")
201201
}
202202
}

libcontainer/container_linux_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,15 @@ func TestGetContainerStats(t *testing.T) {
202202
if stats.CgroupStats.MemoryStats.Usage.Usage != 1024 {
203203
t.Fatalf("expected memory usage 1024 but received %d", stats.CgroupStats.MemoryStats.Usage.Usage)
204204
}
205-
if intelrdt.IsCatEnabled() {
205+
if intelrdt.IsCATEnabled() {
206206
if stats.IntelRdtStats == nil {
207207
t.Fatal("intel rdt stats are nil")
208208
}
209209
if stats.IntelRdtStats.L3CacheSchema != "L3:0=f;1=f0" {
210210
t.Fatalf("expected L3CacheSchema L3:0=f;1=f0 but received %s", stats.IntelRdtStats.L3CacheSchema)
211211
}
212212
}
213-
if intelrdt.IsMbaEnabled() {
213+
if intelrdt.IsMBAEnabled() {
214214
if stats.IntelRdtStats == nil {
215215
t.Fatal("intel rdt stats are nil")
216216
}
@@ -283,7 +283,7 @@ func TestGetContainerState(t *testing.T) {
283283
if memPath := paths["memory"]; memPath != expectedMemoryPath {
284284
t.Fatalf("expected memory path %q but received %q", expectedMemoryPath, memPath)
285285
}
286-
if intelrdt.IsCatEnabled() || intelrdt.IsMbaEnabled() {
286+
if intelrdt.IsCATEnabled() || intelrdt.IsMBAEnabled() {
287287
intelRdtPath := state.IntelRdtPath
288288
if intelRdtPath == "" {
289289
t.Fatal("intel rdt path should not be empty")

libcontainer/factory_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func (l *LinuxFactory) Create(id string, config *configs.Config) (Container, err
276276
newgidmapPath: l.NewgidmapPath,
277277
cgroupManager: l.NewCgroupsManager(config.Cgroups, nil),
278278
}
279-
if intelrdt.IsCatEnabled() || intelrdt.IsMbaEnabled() {
279+
if intelrdt.IsCATEnabled() || intelrdt.IsMBAEnabled() {
280280
c.intelRdtManager = l.NewIntelRdtManager(config, id, "")
281281
}
282282
c.state = &stoppedState{c: c}
@@ -322,7 +322,7 @@ func (l *LinuxFactory) Load(id string) (Container, error) {
322322
if err := c.refreshState(); err != nil {
323323
return nil, err
324324
}
325-
if intelrdt.IsCatEnabled() || intelrdt.IsMbaEnabled() {
325+
if intelrdt.IsCATEnabled() || intelrdt.IsMBAEnabled() {
326326
c.intelRdtManager = l.NewIntelRdtManager(&state.Config, id, state.IntelRdtPath)
327327
}
328328
return c, nil

libcontainer/intelrdt/intelrdt.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ var (
182182
intelRdtRootLock sync.Mutex
183183

184184
// The flag to indicate if Intel RDT/CAT is enabled
185-
isCatEnabled bool
185+
catEnabled bool
186186
// The flag to indicate if Intel RDT/MBA is enabled
187-
isMbaEnabled bool
187+
mbaEnabled bool
188188
// The flag to indicate if Intel RDT/MBA Software Controller is enabled
189-
isMbaScEnabled bool
189+
mbaScEnabled bool
190190
)
191191

192192
type intelRdtData struct {
@@ -215,17 +215,17 @@ func init() {
215215
// (e.g., rdt=!l3cat,mba) in 4.14 and newer kernel
216216
if flagsSet.CAT {
217217
if _, err := os.Stat(filepath.Join(intelRdtRoot, "info", "L3")); err == nil {
218-
isCatEnabled = true
218+
catEnabled = true
219219
}
220220
}
221-
if isMbaScEnabled {
221+
if mbaScEnabled {
222222
// We confirm MBA Software Controller is enabled in step 2,
223223
// MBA should be enabled because MBA Software Controller
224224
// depends on MBA
225-
isMbaEnabled = true
225+
mbaEnabled = true
226226
} else if flagsSet.MBA {
227227
if _, err := os.Stat(filepath.Join(intelRdtRoot, "info", "MB")); err == nil {
228-
isMbaEnabled = true
228+
mbaEnabled = true
229229
}
230230
}
231231

@@ -263,7 +263,7 @@ func findIntelRdtMountpointDir(f io.Reader) (string, error) {
263263

264264
// Check if MBA Software Controller is enabled through mount option "-o mba_MBps"
265265
if strings.Contains(","+mi[0].VFSOptions+",", ",mba_MBps,") {
266-
isMbaScEnabled = true
266+
mbaScEnabled = true
267267
}
268268

269269
return mi[0].Mountpoint, nil
@@ -515,18 +515,18 @@ func WriteIntelRdtTasks(dir string, pid int) error {
515515
}
516516

517517
// Check if Intel RDT/CAT is enabled
518-
func IsCatEnabled() bool {
519-
return isCatEnabled
518+
func IsCATEnabled() bool {
519+
return catEnabled
520520
}
521521

522522
// Check if Intel RDT/MBA is enabled
523-
func IsMbaEnabled() bool {
524-
return isMbaEnabled
523+
func IsMBAEnabled() bool {
524+
return mbaEnabled
525525
}
526526

527527
// Check if Intel RDT/MBA Software Controller is enabled
528-
func IsMbaScEnabled() bool {
529-
return isMbaScEnabled
528+
func IsMBAScEnabled() bool {
529+
return mbaScEnabled
530530
}
531531

532532
// Get the 'container_id' path in Intel RDT "resource control" filesystem
@@ -612,7 +612,7 @@ func (m *IntelRdtManager) GetStats() (*Stats, error) {
612612
}
613613
schemaStrings := strings.Split(tmpStrings, "\n")
614614

615-
if IsCatEnabled() {
615+
if IsCATEnabled() {
616616
// The read-only L3 cache information
617617
l3CacheInfo, err := getL3CacheInfo()
618618
if err != nil {
@@ -635,7 +635,7 @@ func (m *IntelRdtManager) GetStats() (*Stats, error) {
635635
}
636636
}
637637

638-
if IsMbaEnabled() {
638+
if IsMBAEnabled() {
639639
// The read-only memory bandwidth information
640640
memBwInfo, err := getMemBwInfo()
641641
if err != nil {

libcontainer/intelrdt/intelrdt_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func TestIntelRdtSetL3CacheSchema(t *testing.T) {
12-
if !IsCatEnabled() {
12+
if !IsCATEnabled() {
1313
return
1414
}
1515

@@ -47,7 +47,7 @@ func TestIntelRdtSetL3CacheSchema(t *testing.T) {
4747
}
4848

4949
func TestIntelRdtSetMemBwSchema(t *testing.T) {
50-
if !IsMbaEnabled() {
50+
if !IsMBAEnabled() {
5151
return
5252
}
5353

@@ -85,7 +85,7 @@ func TestIntelRdtSetMemBwSchema(t *testing.T) {
8585
}
8686

8787
func TestIntelRdtSetMemBwScSchema(t *testing.T) {
88-
if !IsMbaScEnabled() {
88+
if !IsMBAScEnabled() {
8989
return
9090
}
9191

@@ -200,7 +200,7 @@ func TestFindIntelRdtMountpointDir(t *testing.T) {
200200
input io.Reader
201201
isNotFoundError bool
202202
isError bool
203-
isMbaScEnabled bool
203+
mbaScEnabled bool
204204
mountpoint string
205205
}{
206206
{
@@ -209,10 +209,10 @@ func TestFindIntelRdtMountpointDir(t *testing.T) {
209209
mountpoint: "/sys/fs/resctrl",
210210
},
211211
{
212-
name: "Valid mountinfo with MBA Software Controller enabled",
213-
input: strings.NewReader(mountinfoMbaSc),
214-
isMbaScEnabled: true,
215-
mountpoint: "/sys/fs/resctrl",
212+
name: "Valid mountinfo with MBA Software Controller enabled",
213+
input: strings.NewReader(mountinfoMbaSc),
214+
mbaScEnabled: true,
215+
mountpoint: "/sys/fs/resctrl",
216216
},
217217
{
218218
name: "Empty mountinfo",
@@ -248,9 +248,9 @@ func TestFindIntelRdtMountpointDir(t *testing.T) {
248248
return
249249
}
250250
// no errors, check the results
251-
if tc.isMbaScEnabled != isMbaScEnabled {
252-
t.Errorf("expected isMbaScEnabled=%v, got %v",
253-
tc.isMbaScEnabled, isMbaScEnabled)
251+
if tc.mbaScEnabled != mbaScEnabled {
252+
t.Errorf("expected mbaScEnabled=%v, got %v",
253+
tc.mbaScEnabled, mbaScEnabled)
254254
}
255255
if tc.mountpoint != mp {
256256
t.Errorf("expected mountpoint=%q, got %q",

update.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,11 @@ other options are ignored.
298298
// Update Intel RDT
299299
l3CacheSchema := context.String("l3-cache-schema")
300300
memBwSchema := context.String("mem-bw-schema")
301-
if l3CacheSchema != "" && !intelrdt.IsCatEnabled() {
301+
if l3CacheSchema != "" && !intelrdt.IsCATEnabled() {
302302
return errors.New("Intel RDT/CAT: l3 cache schema is not enabled")
303303
}
304304

305-
if memBwSchema != "" && !intelrdt.IsMbaEnabled() {
305+
if memBwSchema != "" && !intelrdt.IsMBAEnabled() {
306306
return errors.New("Intel RDT/MBA: memory bandwidth schema is not enabled")
307307
}
308308

utils_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func loadFactory(context *cli.Context) (libcontainer.Factory, error) {
5757
}
5858

5959
intelRdtManager := libcontainer.IntelRdtFs
60-
if !intelrdt.IsCatEnabled() && !intelrdt.IsMbaEnabled() {
60+
if !intelrdt.IsCATEnabled() && !intelrdt.IsMBAEnabled() {
6161
intelRdtManager = nil
6262
}
6363

0 commit comments

Comments
 (0)