Skip to content

Commit 5d9aa69

Browse files
committed
config-linux: Add Intel RDT/MBA Linux support
Add support for Intel Resource Director Technology (RDT) / Memory Bandwidth Allocation (MBA). Add memory bandwidth resource constraints in Linux-specific configuration. In this PR, the spec for memory bandwidth (memBwSchema) keeps the same format as existed spec for L3 cache (l3CacheSchema) for consistency and compatibility in runtime-spec 1.x. Example: "linux": { "intelRdt": { "closID": "guaranteed_group", "l3CacheSchema": "L3:0=7f0;1=1f", "memBwSchema": "MB:0=20;1=70" } } This is the prerequisite of this runc proposal: opencontainers/runc#1596 For more information about Intel RDT/MBA, please refer to: opencontainers/runc#1596 Signed-off-by: Xiaochen Shen <[email protected]>
1 parent cc07cb9 commit 5d9aa69

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

config-linux.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,28 +491,41 @@ You MUST specify at least one of the `hcaHandles` or `hcaObjects` in a given ent
491491
If `intelRdt` is set, the runtime MUST write the container process ID to the `tasks` file in a proper sub-directory in a mounted `resctrl` pseudo-filesystem. That sub-directory name is specified by `closID` parameter.
492492
If no mounted `resctrl` pseudo-filesystem is available in the [runtime mount namespace](glossary.md#runtime-namespace), the runtime MUST [generate an error](runtime.md#errors).
493493

494-
If `intelRdt` is not set, the runtime MUST NOT manipulate any `resctrl` pseudo-filesystems.
494+
If `intelRdt` is not set, the runtime MUST NOT manipulate any `resctrl` pseudo-filesystems.
495495

496496
The following parameters can be specified for the container:
497497

498498
* **`closID`** *(string, OPTIONAL)* - specifies the identity for RDT Class of Service (CLOS).
499499
If `closID` is set, runtimes MUST create `closID` directory in a mounted `resctrl` pseudo-filesystem if it doesn't exist. If not set, runtimes MUST use the container ID from [`start`](runtime.md#start) and create the `<container-id>` directory.
500500

501501
* **`l3CacheSchema`** *(string, OPTIONAL)* - specifies the schema for L3 cache id and capacity bitmask (CBM).
502-
If `l3CacheSchema` is set, runtimes MUST write the value to the `schemata` file in that sub-directory discussed in `closID`. If not set, runtimes MUST NOT write to `schemata` files in any `resctrl` pseudo-filesystems.
502+
The value SHOULD start with `L3:` and SHOULD NOT contain newlines.
503+
* **`memBwSchema`** *(string, OPTIONAL)* - specifies the schema of memory bandwidth percentage per L3 cache id.
504+
The value MUST start with `MB:` and MUST NOT contain newlines.
503505

504-
If `closID` and `l3CacheSchema` both are set, runtimes MUST compare `l3CacheSchema` value with `schemata` file, and [generate an error](runtime.md#errors) if doesn't match.
506+
If both `l3CacheSchema` and `memBwSchema` are set, runtimes MUST write the combined value to the `schemata` file in that sub-directory discussed in `closID`.
507+
If `l3CacheSchema` contains a line beginning with `MB:`, the value written to `schemata` file MUST be the non-`MB:` line(s) from `l3CacheSchema` and the line from `memBWSchema`.
508+
509+
If either `l3CacheSchema` or `memBwSchema` is set, runtimes MUST write the value to the `schemata` file in the that sub-directory discussed in `closID`.
510+
511+
If neither `l3CacheSchema` nor `memBwSchema` is set, runtimes MUST NOT write to `schemata` files in any `resctrl` pseudo-filesystems.
512+
513+
If `closID` is set, `l3CacheSchema` and/or `memBwSchema` is set, runtimes MUST compare `l3CacheSchema` and/or `memBwSchema` value with `schemata` file, and [generate an error](runtime.md#errors) if doesn't match.
505514

506515
### Example
507516

508-
Consider a two-socket machine with two L3 caches where the default CBM is 0xfffff and the max CBM length is 20 bits.
509-
Tasks inside the container only have access to the "upper" 80% of L3 cache id 0 and the "lower" 50% L3 cache id 1:
517+
Consider a two-socket machine with two L3 caches where the default CBM is 0x7ff and the max CBM length is 11 bits,
518+
and minimum memory bandwidth of 10% with a memory bandwidth granularity of 10%.
519+
520+
Tasks inside the container only have access to the "upper" 7/11 of L3 cache on socket 0 and the "lower" 5/11 L3 cache on socket 1,
521+
and may use a maximum memory bandwidth of 20% on socket 0 and 70% on socket 1.
510522

511523
```json
512524
"linux": {
513525
"intelRdt": {
514526
"closID": "guaranteed_group",
515-
"l3CacheSchema": "L3:0=ffff0;1=3ff"
527+
"l3CacheSchema": "L3:0=7f0;1=1f",
528+
"memBwSchema": "MB:0=20;1=70"
516529
}
517530
}
518531
```

schema/config-linux.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@
233233
},
234234
"l3CacheSchema": {
235235
"type": "string"
236+
},
237+
"memBwSchema": {
238+
"type": "string",
239+
"pattern": "^MB:[^\\n]*$"
236240
}
237241
}
238242
}

specs-go/config.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ type Linux struct {
160160
ReadonlyPaths []string `json:"readonlyPaths,omitempty"`
161161
// MountLabel specifies the selinux context for the mounts in the container.
162162
MountLabel string `json:"mountLabel,omitempty"`
163-
// IntelRdt contains Intel Resource Director Technology (RDT) information
164-
// for handling resource constraints (e.g., L3 cache) for the container
163+
// IntelRdt contains Intel Resource Director Technology (RDT) information for
164+
// handling resource constraints (e.g., L3 cache, memory bandwidth) for the container
165165
IntelRdt *LinuxIntelRdt `json:"intelRdt,omitempty"`
166166
}
167167

@@ -623,12 +623,16 @@ type LinuxSyscall struct {
623623
Args []LinuxSeccompArg `json:"args,omitempty"`
624624
}
625625

626-
// LinuxIntelRdt has container runtime resource constraints
627-
// for Intel RDT/CAT which introduced in Linux 4.10 kernel
626+
// LinuxIntelRdt has container runtime resource constraints for Intel RDT
627+
// CAT and MBA features which introduced in Linux 4.10 and 4.12 kernel
628628
type LinuxIntelRdt struct {
629629
// The identity for RDT Class of Service
630630
ClosID string `json:"closID,omitempty"`
631631
// The schema for L3 cache id and capacity bitmask (CBM)
632632
// Format: "L3:<cache_id0>=<cbm0>;<cache_id1>=<cbm1>;..."
633633
L3CacheSchema string `json:"l3CacheSchema,omitempty"`
634+
635+
// The schema of memory bandwidth percentage per L3 cache id
636+
// Format: "MB:<cache_id0>=bandwidth0;<cache_id1>=bandwidth1;..."
637+
MemBwSchema string `json:"memBwSchema,omitempty"`
634638
}

0 commit comments

Comments
 (0)