Skip to content

Commit b389bce

Browse files
committed
[Dependency: opencontainers#2677] 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 926f81e commit b389bce

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
@@ -272,7 +272,7 @@ func (l *LinuxFactory) Create(id string, config *configs.Config) (Container, err
272272
newgidmapPath: l.NewgidmapPath,
273273
cgroupManager: l.NewCgroupsManager(config.Cgroups, nil),
274274
}
275-
if intelrdt.IsCatEnabled() || intelrdt.IsMbaEnabled() {
275+
if intelrdt.IsCATEnabled() || intelrdt.IsMBAEnabled() {
276276
c.intelRdtManager = l.NewIntelRdtManager(config, id, "")
277277
}
278278
c.state = &stoppedState{c: c}
@@ -318,7 +318,7 @@ func (l *LinuxFactory) Load(id string) (Container, error) {
318318
if err := c.refreshState(); err != nil {
319319
return nil, err
320320
}
321-
if intelrdt.IsCatEnabled() || intelrdt.IsMbaEnabled() {
321+
if intelrdt.IsCATEnabled() || intelrdt.IsMBAEnabled() {
322322
c.intelRdtManager = l.NewIntelRdtManager(&state.Config, id, state.IntelRdtPath)
323323
}
324324
return c, nil

libcontainer/intelrdt/intelrdt.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ var (
190190
intelRdtRootLock sync.Mutex
191191

192192
// The flag to indicate if Intel RDT/CAT is enabled
193-
isCatEnabled bool
193+
catEnabled bool
194194
// The flag to indicate if Intel RDT/MBA is enabled
195-
isMbaEnabled bool
195+
mbaEnabled bool
196196
// The flag to indicate if Intel RDT/MBA Software Controller is enabled
197-
isMbaScEnabled bool
197+
mbaScEnabled bool
198198
)
199199

200200
type intelRdtData struct {
@@ -223,17 +223,17 @@ func init() {
223223
// (e.g., rdt=!l3cat,mba) in 4.14 and newer kernel
224224
if flagsSet.CAT {
225225
if _, err := os.Stat(filepath.Join(intelRdtRoot, "info", "L3")); err == nil {
226-
isCatEnabled = true
226+
catEnabled = true
227227
}
228228
}
229-
if isMbaScEnabled {
229+
if mbaScEnabled {
230230
// We confirm MBA Software Controller is enabled in step 2,
231231
// MBA should be enabled because MBA Software Controller
232232
// depends on MBA
233-
isMbaEnabled = true
233+
mbaEnabled = true
234234
} else if flagsSet.MBA {
235235
if _, err := os.Stat(filepath.Join(intelRdtRoot, "info", "MB")); err == nil {
236-
isMbaEnabled = true
236+
mbaEnabled = true
237237
}
238238
}
239239

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

273273
// Check if MBA Software Controller is enabled through mount option "-o mba_MBps"
274274
if strings.Contains(","+mi[0].VFSOptions+",", ",mba_MBps,") {
275-
isMbaScEnabled = true
275+
mbaScEnabled = true
276276
}
277277

278278
return mi[0].Mountpoint, nil
@@ -524,18 +524,18 @@ func WriteIntelRdtTasks(dir string, pid int) error {
524524
}
525525

526526
// Check if Intel RDT/CAT is enabled
527-
func IsCatEnabled() bool {
528-
return isCatEnabled
527+
func IsCATEnabled() bool {
528+
return catEnabled
529529
}
530530

531531
// Check if Intel RDT/MBA is enabled
532-
func IsMbaEnabled() bool {
533-
return isMbaEnabled
532+
func IsMBAEnabled() bool {
533+
return mbaEnabled
534534
}
535535

536536
// Check if Intel RDT/MBA Software Controller is enabled
537-
func IsMbaScEnabled() bool {
538-
return isMbaScEnabled
537+
func IsMBAScEnabled() bool {
538+
return mbaScEnabled
539539
}
540540

541541
// Get the 'container_id' path in Intel RDT "resource control" filesystem
@@ -621,7 +621,7 @@ func (m *intelRdtManager) GetStats() (*Stats, error) {
621621
}
622622
schemaStrings := strings.Split(tmpStrings, "\n")
623623

624-
if IsCatEnabled() {
624+
if IsCATEnabled() {
625625
// The read-only L3 cache information
626626
l3CacheInfo, err := getL3CacheInfo()
627627
if err != nil {
@@ -644,7 +644,7 @@ func (m *intelRdtManager) GetStats() (*Stats, error) {
644644
}
645645
}
646646

647-
if IsMbaEnabled() {
647+
if IsMBAEnabled() {
648648
// The read-only memory bandwidth information
649649
memBwInfo, err := getMemBwInfo()
650650
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

@@ -44,7 +44,7 @@ func TestIntelRdtSetL3CacheSchema(t *testing.T) {
4444
}
4545

4646
func TestIntelRdtSetMemBwSchema(t *testing.T) {
47-
if !IsMbaEnabled() {
47+
if !IsMBAEnabled() {
4848
return
4949
}
5050

@@ -79,7 +79,7 @@ func TestIntelRdtSetMemBwSchema(t *testing.T) {
7979
}
8080

8181
func TestIntelRdtSetMemBwScSchema(t *testing.T) {
82-
if !IsMbaScEnabled() {
82+
if !IsMBAScEnabled() {
8383
return
8484
}
8585

@@ -191,7 +191,7 @@ func TestFindIntelRdtMountpointDir(t *testing.T) {
191191
input io.Reader
192192
isNotFoundError bool
193193
isError bool
194-
isMbaScEnabled bool
194+
mbaScEnabled bool
195195
mountpoint string
196196
}{
197197
{
@@ -200,10 +200,10 @@ func TestFindIntelRdtMountpointDir(t *testing.T) {
200200
mountpoint: "/sys/fs/resctrl",
201201
},
202202
{
203-
name: "Valid mountinfo with MBA Software Controller enabled",
204-
input: strings.NewReader(mountinfoMbaSc),
205-
isMbaScEnabled: true,
206-
mountpoint: "/sys/fs/resctrl",
203+
name: "Valid mountinfo with MBA Software Controller enabled",
204+
input: strings.NewReader(mountinfoMbaSc),
205+
mbaScEnabled: true,
206+
mountpoint: "/sys/fs/resctrl",
207207
},
208208
{
209209
name: "Empty mountinfo",
@@ -239,9 +239,9 @@ func TestFindIntelRdtMountpointDir(t *testing.T) {
239239
return
240240
}
241241
// no errors, check the results
242-
if tc.isMbaScEnabled != isMbaScEnabled {
243-
t.Errorf("expected isMbaScEnabled=%v, got %v",
244-
tc.isMbaScEnabled, isMbaScEnabled)
242+
if tc.mbaScEnabled != mbaScEnabled {
243+
t.Errorf("expected mbaScEnabled=%v, got %v",
244+
tc.mbaScEnabled, mbaScEnabled)
245245
}
246246
if tc.mountpoint != mp {
247247
t.Errorf("expected mountpoint=%q, got %q",

update.go

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

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

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)