Skip to content

Commit 2549545

Browse files
committed
intelrdt: always init IntelRdtManager if Intel RDT is enabled
In current implementation: Either Intel RDT is not enabled by hardware and kernel, or intelRdt is not specified in original config, we don't init IntelRdtManager in the container to handle intelrdt constraint. It is a tradeoff that Intel RDT has hardware limitation to support only limited number of groups. This patch makes a minor change to support update command: Whether or not intelRdt is specified in config, we always init IntelRdtManager in the container if Intel RDT is enabled. If intelRdt is not specified in original config, we just don't Apply() to create intelrdt group or attach tasks for this container. In update command, we could re-enable through IntelRdtManager.Apply() and then update intelrdt constraint. Signed-off-by: Xiaochen Shen <[email protected]>
1 parent 593914b commit 2549545

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

libcontainer/factory_linux.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ func (l *LinuxFactory) Create(id string, config *configs.Config) (Container, err
213213
newgidmapPath: l.NewgidmapPath,
214214
cgroupManager: l.NewCgroupsManager(config.Cgroups, nil),
215215
}
216-
c.intelRdtManager = nil
217-
if intelrdt.IsEnabled() && c.config.IntelRdt != nil {
216+
if intelrdt.IsEnabled() {
218217
c.intelRdtManager = l.NewIntelRdtManager(config, id, "")
219218
}
220219
c.state = &stoppedState{c: c}
@@ -256,8 +255,7 @@ func (l *LinuxFactory) Load(id string) (Container, error) {
256255
if err := c.refreshState(); err != nil {
257256
return nil, err
258257
}
259-
c.intelRdtManager = nil
260-
if intelrdt.IsEnabled() && c.config.IntelRdt != nil {
258+
if intelrdt.IsEnabled() {
261259
c.intelRdtManager = l.NewIntelRdtManager(&state.Config, id, state.IntelRdtPath)
262260
}
263261
return c, nil

libcontainer/intelrdt/intelrdt.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,10 @@ func GetIntelRdtPath(id string) (string, error) {
401401

402402
// Applies Intel RDT configuration to the process with the specified pid
403403
func (m *IntelRdtManager) Apply(pid int) (err error) {
404+
// If intelRdt is not specified in config, we do nothing
405+
if m.Config.IntelRdt == nil {
406+
return nil
407+
}
404408
d, err := getIntelRdtData(m.Config, pid)
405409
if err != nil && !IsNotFound(err) {
406410
return err

0 commit comments

Comments
 (0)