Skip to content

Commit 2c004a1

Browse files
committed
libcontainer/intelrdt: introduce NewManager()
Introduce NewManager() to wrap up IntelRdtManager initialization. And call it when required. Signed-off-by: Xiaochen Shen <[email protected]>
1 parent d8bfd6c commit 2c004a1

File tree

4 files changed

+13
-22
lines changed

4 files changed

+13
-22
lines changed

libcontainer/factory_linux.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,7 @@ func RootlessCgroupfs(l *LinuxFactory) error {
149149
// create and manage Intel RDT resources (e.g., L3 cache, memory bandwidth).
150150
func IntelRdtFs(l *LinuxFactory) error {
151151
l.NewIntelRdtManager = func(config *configs.Config, id string, path string) intelrdt.Manager {
152-
return &intelrdt.IntelRdtManager{
153-
Config: config,
154-
Id: id,
155-
Path: path,
156-
}
152+
return intelrdt.NewManager(config, id, path)
157153
}
158154
return nil
159155
}

libcontainer/intelrdt/intelrdt.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,14 @@ type IntelRdtManager struct {
172172
Path string
173173
}
174174

175+
func NewManager(config *configs.Config, id string, path string) Manager {
176+
return &IntelRdtManager{
177+
Config: config,
178+
Id: id,
179+
Path: path,
180+
}
181+
}
182+
175183
const (
176184
IntelRdtTasks = "tasks"
177185
)

libcontainer/intelrdt/intelrdt_test.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ func TestIntelRdtSetL3CacheSchema(t *testing.T) {
2626
})
2727

2828
helper.IntelRdtData.config.IntelRdt.L3CacheSchema = l3CacheSchemeAfter
29-
intelrdt := &IntelRdtManager{
30-
Config: helper.IntelRdtData.config,
31-
Path: helper.IntelRdtPath,
32-
}
29+
intelrdt := NewManager(helper.IntelRdtData.config, "", helper.IntelRdtPath)
3330
if err := intelrdt.Set(helper.IntelRdtData.config); err != nil {
3431
t.Fatal(err)
3532
}
@@ -64,10 +61,7 @@ func TestIntelRdtSetMemBwSchema(t *testing.T) {
6461
})
6562

6663
helper.IntelRdtData.config.IntelRdt.MemBwSchema = memBwSchemeAfter
67-
intelrdt := &IntelRdtManager{
68-
Config: helper.IntelRdtData.config,
69-
Path: helper.IntelRdtPath,
70-
}
64+
intelrdt := NewManager(helper.IntelRdtData.config, "", helper.IntelRdtPath)
7165
if err := intelrdt.Set(helper.IntelRdtData.config); err != nil {
7266
t.Fatal(err)
7367
}
@@ -102,10 +96,7 @@ func TestIntelRdtSetMemBwScSchema(t *testing.T) {
10296
})
10397

10498
helper.IntelRdtData.config.IntelRdt.MemBwSchema = memBwScSchemeAfter
105-
intelrdt := &IntelRdtManager{
106-
Config: helper.IntelRdtData.config,
107-
Path: helper.IntelRdtPath,
108-
}
99+
intelrdt := NewManager(helper.IntelRdtData.config, "", helper.IntelRdtPath)
109100
if err := intelrdt.Set(helper.IntelRdtData.config); err != nil {
110101
t.Fatal(err)
111102
}

update.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,11 +317,7 @@ other options are ignored.
317317
return err
318318
}
319319
config.IntelRdt = &configs.IntelRdt{}
320-
intelRdtManager := intelrdt.IntelRdtManager{
321-
Config: &config,
322-
Id: container.ID(),
323-
Path: state.IntelRdtPath,
324-
}
320+
intelRdtManager := intelrdt.NewManager(&config, container.ID(), state.IntelRdtPath)
325321
if err := intelRdtManager.Apply(state.InitProcessPid); err != nil {
326322
return err
327323
}

0 commit comments

Comments
 (0)