Merge pull request #20150 from wpross/add-rdt

Add Intel RDT support
This commit is contained in:
OpenShift Merge Robot 2023-09-28 01:27:02 -04:00 committed by GitHub
commit 36f8e78d71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 58 additions and 1 deletions

View File

@ -370,6 +370,14 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
"quiet", "q", false,
"Suppress output information when pulling images",
)
rdtClassFlagName := "rdt-class"
createFlags.StringVar(
&cf.IntelRdtClosID,
rdtClassFlagName, cf.IntelRdtClosID,
"Class of Service (COS) that the container should be assigned to",
)
_ = cmd.RegisterFlagCompletionFunc(rdtClassFlagName, AutocompletePullOption)
createFlags.BoolVar(
&cf.ReadOnly,
"read-only", podmanConfig.ContainersConfDefaultsRO.Containers.ReadOnly,

View File

@ -0,0 +1,7 @@
####> This option file is used in:
####> podman create, run
####> If file is edited, make sure the changes
####> are applicable to all of those.
#### **--rdt-class**=*intel-rdt-class-of-service*
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.

View File

@ -304,6 +304,8 @@ by having one container bind to localhost in the pod, and another connect to tha
Suppress output information when pulling images
@@option rdt-class
@@option read-only
@@option read-only-tmpfs

View File

@ -330,6 +330,8 @@ by having one container bind to localhost in the pod, and another connect to tha
Suppress output information when pulling images
@@option rdt-class
@@option read-only
@@option read-only-tmpfs

View File

@ -21,8 +21,14 @@ func (c *Container) platformInspectContainerHostConfig(ctrSpec *spec.Spec, hostC
// there are things that require a major:minor to path translation.
var deviceNodes map[string]string
// Resource limits
if ctrSpec.Linux != nil {
if ctrSpec.Linux.IntelRdt != nil {
if ctrSpec.Linux.IntelRdt.ClosID != "" {
// container is assigned to a ClosID
hostConfig.IntelRdtClosID = ctrSpec.Linux.IntelRdt.ClosID
}
}
// Resource limits
if ctrSpec.Linux.Resources != nil {
if ctrSpec.Linux.Resources.CPU != nil {
if ctrSpec.Linux.Resources.CPU.Shares != nil {

View File

@ -567,6 +567,9 @@ type InspectContainerHostConfig struct {
IOMaximumBandwidth uint64 `json:"IOMaximumBandwidth"`
// CgroupConf is the configuration for cgroup v2.
CgroupConf map[string]string `json:"CgroupConf"`
// IntelRdtClosID defines the Intel RDT CAT Class Of Service (COS) that
// all processes of the container should run in.
IntelRdtClosID string `json:"IntelRdtClosID,omitempty"`
}
// Address represents an IP address.

View File

@ -224,6 +224,7 @@ type ContainerCreateOptions struct {
Init bool
InitContainerType string
InitPath string
IntelRdtClosID string
Interactive bool
IPC string
Label []string

View File

@ -216,6 +216,12 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
g.AddAnnotation(key, val)
}
if s.IntelRdt != nil {
if s.IntelRdt.ClosID != "" {
g.SetLinuxIntelRdtClosID(s.IntelRdt.ClosID)
}
}
if s.ResourceLimits != nil {
out, err := json.Marshal(s.ResourceLimits)
if err != nil {

View File

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

View File

@ -491,6 +491,12 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions
s.Labels = labels
}
// Intel RDT CAT
if c.IntelRdtClosID != "" {
s.IntelRdt = &specs.LinuxIntelRdt{}
s.IntelRdt.ClosID = c.IntelRdtClosID
}
// ANNOTATIONS
annotations := make(map[string]string)

View File

@ -75,6 +75,18 @@ var _ = Describe("Podman create", func() {
Expect(session).Should(Exit(125))
})
It("podman create adds rdt-class", func() {
session := podmanTest.Podman([]string{"create", "--rdt-class", "COS1", "--name", "rdt_test", ALPINE, "ls"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(podmanTest.NumberOfContainers()).To(Equal(1))
check := podmanTest.Podman([]string{"inspect", "rdt_test"})
check.WaitWithDefaultTimeout()
data := check.InspectContainerToJSON()
Expect(data[0].HostConfig.IntelRdtClosID).To(Equal("COS1"))
})
It("podman create adds annotation", func() {
session := podmanTest.Podman([]string{"create", "--annotation", "HELLO=WORLD", "--name", "annotate_test", ALPINE, "ls"})
session.WaitWithDefaultTimeout()