Skip to content

Commit 36f8e78

Browse files
Merge pull request #20150 from wpross/add-rdt
Add Intel RDT support
2 parents 71b3d77 + 455d165 commit 36f8e78

File tree

11 files changed

+58
-1
lines changed

11 files changed

+58
-1
lines changed

cmd/podman/common/create.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,14 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
370370
"quiet", "q", false,
371371
"Suppress output information when pulling images",
372372
)
373+
rdtClassFlagName := "rdt-class"
374+
createFlags.StringVar(
375+
&cf.IntelRdtClosID,
376+
rdtClassFlagName, cf.IntelRdtClosID,
377+
"Class of Service (COS) that the container should be assigned to",
378+
)
379+
_ = cmd.RegisterFlagCompletionFunc(rdtClassFlagName, AutocompletePullOption)
380+
373381
createFlags.BoolVar(
374382
&cf.ReadOnly,
375383
"read-only", podmanConfig.ContainersConfDefaultsRO.Containers.ReadOnly,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
####> This option file is used in:
2+
####> podman create, run
3+
####> If file is edited, make sure the changes
4+
####> are applicable to all of those.
5+
#### **--rdt-class**=*intel-rdt-class-of-service*
6+
7+
Rdt-class sets the class of service (CLOS or COS) for the container to run in. Based on the Cache Allocation Technology (CAT) feature that is part of Intel's Resource Director Technology (RDT) feature set, all container processes will run within the pre-configured COS, representing a part of the cache. The COS has to be created and configured using a pseudo file system (usually mounted at `/sys/fs/resctrl`) that the resctrl kernel driver provides. Assigning the container to a COS requires root privileges and thus doesn't work in a rootless environment. Currently, the feature is only supported using `runc` as a runtime. See <https://docs.kernel.org/arch/x86/resctrl.html> for more details on creating a COS before a container can be assigned to it.

docs/source/markdown/podman-create.1.md.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ by having one container bind to localhost in the pod, and another connect to tha
304304

305305
Suppress output information when pulling images
306306

307+
@@option rdt-class
308+
307309
@@option read-only
308310

309311
@@option read-only-tmpfs

docs/source/markdown/podman-run.1.md.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ by having one container bind to localhost in the pod, and another connect to tha
330330

331331
Suppress output information when pulling images
332332

333+
@@option rdt-class
334+
333335
@@option read-only
334336

335337
@@option read-only-tmpfs

libpod/container_inspect_linux.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ func (c *Container) platformInspectContainerHostConfig(ctrSpec *spec.Spec, hostC
2121
// there are things that require a major:minor to path translation.
2222
var deviceNodes map[string]string
2323

24-
// Resource limits
2524
if ctrSpec.Linux != nil {
25+
if ctrSpec.Linux.IntelRdt != nil {
26+
if ctrSpec.Linux.IntelRdt.ClosID != "" {
27+
// container is assigned to a ClosID
28+
hostConfig.IntelRdtClosID = ctrSpec.Linux.IntelRdt.ClosID
29+
}
30+
}
31+
// Resource limits
2632
if ctrSpec.Linux.Resources != nil {
2733
if ctrSpec.Linux.Resources.CPU != nil {
2834
if ctrSpec.Linux.Resources.CPU.Shares != nil {

libpod/define/container_inspect.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,9 @@ type InspectContainerHostConfig struct {
567567
IOMaximumBandwidth uint64 `json:"IOMaximumBandwidth"`
568568
// CgroupConf is the configuration for cgroup v2.
569569
CgroupConf map[string]string `json:"CgroupConf"`
570+
// IntelRdtClosID defines the Intel RDT CAT Class Of Service (COS) that
571+
// all processes of the container should run in.
572+
IntelRdtClosID string `json:"IntelRdtClosID,omitempty"`
570573
}
571574

572575
// Address represents an IP address.

pkg/domain/entities/pods.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ type ContainerCreateOptions struct {
224224
Init bool
225225
InitContainerType string
226226
InitPath string
227+
IntelRdtClosID string
227228
Interactive bool
228229
IPC string
229230
Label []string

pkg/specgen/generate/oci_linux.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
216216
g.AddAnnotation(key, val)
217217
}
218218

219+
if s.IntelRdt != nil {
220+
if s.IntelRdt.ClosID != "" {
221+
g.SetLinuxIntelRdtClosID(s.IntelRdt.ClosID)
222+
}
223+
}
224+
219225
if s.ResourceLimits != nil {
220226
out, err := json.Marshal(s.ResourceLimits)
221227
if err != nil {

pkg/specgen/specgen.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,10 @@ type ContainerNetworkConfig struct {
514514

515515
// ContainerResourceConfig contains information on container resource limits.
516516
type ContainerResourceConfig struct {
517+
// IntelRdt defines the Intel RDT CAT Class of Service (COS) that all processes
518+
// of the container should run in.
519+
// Optional.
520+
IntelRdt *spec.LinuxIntelRdt `json:"intelRdt,omitempty"`
517521
// ResourceLimits are resource limits to apply to the container.,
518522
// Can only be set as root on cgroups v1 systems, but can be set as
519523
// rootless as well for cgroups v2.

pkg/specgenutil/specgen.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,12 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions
491491
s.Labels = labels
492492
}
493493

494+
// Intel RDT CAT
495+
if c.IntelRdtClosID != "" {
496+
s.IntelRdt = &specs.LinuxIntelRdt{}
497+
s.IntelRdt.ClosID = c.IntelRdtClosID
498+
}
499+
494500
// ANNOTATIONS
495501
annotations := make(map[string]string)
496502

0 commit comments

Comments
 (0)