Skip to content

Commit e40d51c

Browse files
committed
libcontainer/intelrdt: support ClosID parameter
Handle ClosID parameter of IntelRdt. Makes it possible to use pre-configured classes/ClosIDs and avoid running out of available IDs which easily happens with per-container classes. Signed-off-by: Markus Lehtonen <[email protected]>
1 parent 4e0f2f8 commit e40d51c

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

libcontainer/configs/intelrdt.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package configs
22

33
type IntelRdt struct {
4+
// The identity for RDT Class of Service
5+
ClosID string `json:"closID,omitempty"`
6+
47
// The schema for L3 cache id and capacity bitmask (CBM)
58
// Format: "L3:<cache_id0>=<cbm0>;<cache_id1>=<cbm1>;..."
69
L3CacheSchema string `json:"l3_cache_schema,omitempty"`

libcontainer/configs/validate/validator.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,6 @@ func (v *ConfigValidator) intelrdt(config *configs.Config) error {
206206
if !intelrdt.IsMBAEnabled() && config.IntelRdt.MemBwSchema != "" {
207207
return errors.New("intelRdt.memBwSchema is specified in config, but Intel RDT/MBA is not enabled")
208208
}
209-
210-
if intelrdt.IsCATEnabled() && config.IntelRdt.L3CacheSchema == "" {
211-
return errors.New("Intel RDT/CAT is enabled and intelRdt is specified in config, but intelRdt.l3CacheSchema is empty")
212-
}
213-
if intelrdt.IsMBAEnabled() && config.IntelRdt.MemBwSchema == "" {
214-
return errors.New("Intel RDT/MBA is enabled and intelRdt is specified in config, but intelRdt.memBwSchema is empty")
215-
}
216209
}
217210

218211
return nil

libcontainer/intelrdt/intelrdt.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,12 @@ func (m *intelRdtManager) getIntelRdtPath() (string, error) {
540540
return "", err
541541
}
542542

543-
return filepath.Join(rootPath, m.id), nil
543+
clos := m.id
544+
if m.config.IntelRdt != nil && m.config.IntelRdt.ClosID != "" {
545+
clos = m.config.IntelRdt.ClosID
546+
}
547+
548+
return filepath.Join(rootPath, clos), nil
544549
}
545550

546551
// Applies Intel RDT configuration to the process with the specified pid
@@ -572,12 +577,17 @@ func (m *intelRdtManager) Apply(pid int) (err error) {
572577

573578
// Destroys the Intel RDT 'container_id' group
574579
func (m *intelRdtManager) Destroy() error {
575-
m.mu.Lock()
576-
defer m.mu.Unlock()
577-
if err := os.RemoveAll(m.GetPath()); err != nil {
578-
return err
580+
// Don't remove resctrl group if closid has been explicitly specified. The
581+
// group is likely externally managed, i.e. by some other entity than us.
582+
// There are probably other containers/tasks sharing the same group.
583+
if m.config.IntelRdt == nil || m.config.IntelRdt.ClosID == "" {
584+
m.mu.Lock()
585+
defer m.mu.Unlock()
586+
if err := os.RemoveAll(m.GetPath()); err != nil {
587+
return err
588+
}
589+
m.path = ""
579590
}
580-
m.path = ""
581591
return nil
582592
}
583593

libcontainer/specconv/spec_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
301301
}
302302
if spec.Linux.IntelRdt != nil {
303303
config.IntelRdt = &configs.IntelRdt{}
304+
if spec.Linux.IntelRdt.ClosID != "" {
305+
config.IntelRdt.ClosID = spec.Linux.IntelRdt.ClosID
306+
}
304307
if spec.Linux.IntelRdt.L3CacheSchema != "" {
305308
config.IntelRdt.L3CacheSchema = spec.Linux.IntelRdt.L3CacheSchema
306309
}

0 commit comments

Comments
 (0)