Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Intel RDT support #20150

Merged
merged 6 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/podman/common/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions docs/source/markdown/options/rdt-class.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions docs/source/markdown/podman-create.1.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

wpross marked this conversation as resolved.
Show resolved Hide resolved
@@option read-only

@@option read-only-tmpfs
Expand Down
2 changes: 2 additions & 0 deletions docs/source/markdown/podman-run.1.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion libpod/container_inspect_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions libpod/define/container_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions pkg/domain/entities/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ type ContainerCreateOptions struct {
Init bool
InitContainerType string
InitPath string
IntelRdtClosID string
Interactive bool
IPC string
Label []string
Expand Down
6 changes: 6 additions & 0 deletions pkg/specgen/generate/oci_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions pkg/specgen/specgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions pkg/specgenutil/specgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 12 additions & 0 deletions test/e2e/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down