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 <xiaochen.shen@intel.com>
This commit is contained in:
Xiaochen Shen 2017-09-20 00:13:29 +08:00
parent 593914b8bd
commit 2549545df5
2 changed files with 6 additions and 4 deletions

View File

@ -213,8 +213,7 @@ func (l *LinuxFactory) Create(id string, config *configs.Config) (Container, err
newgidmapPath: l.NewgidmapPath, newgidmapPath: l.NewgidmapPath,
cgroupManager: l.NewCgroupsManager(config.Cgroups, nil), cgroupManager: l.NewCgroupsManager(config.Cgroups, nil),
} }
c.intelRdtManager = nil if intelrdt.IsEnabled() {
if intelrdt.IsEnabled() && c.config.IntelRdt != nil {
c.intelRdtManager = l.NewIntelRdtManager(config, id, "") c.intelRdtManager = l.NewIntelRdtManager(config, id, "")
} }
c.state = &stoppedState{c: c} c.state = &stoppedState{c: c}
@ -256,8 +255,7 @@ func (l *LinuxFactory) Load(id string) (Container, error) {
if err := c.refreshState(); err != nil { if err := c.refreshState(); err != nil {
return nil, err return nil, err
} }
c.intelRdtManager = nil if intelrdt.IsEnabled() {
if intelrdt.IsEnabled() && c.config.IntelRdt != nil {
c.intelRdtManager = l.NewIntelRdtManager(&state.Config, id, state.IntelRdtPath) c.intelRdtManager = l.NewIntelRdtManager(&state.Config, id, state.IntelRdtPath)
} }
return c, nil return c, nil

View File

@ -401,6 +401,10 @@ func GetIntelRdtPath(id string) (string, error) {
// Applies Intel RDT configuration to the process with the specified pid // Applies Intel RDT configuration to the process with the specified pid
func (m *IntelRdtManager) Apply(pid int) (err error) { func (m *IntelRdtManager) Apply(pid int) (err error) {
// If intelRdt is not specified in config, we do nothing
if m.Config.IntelRdt == nil {
return nil
}
d, err := getIntelRdtData(m.Config, pid) d, err := getIntelRdtData(m.Config, pid)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
return err return err