Skip to content

Commit

Permalink
intelrdt: add update command support
Browse files Browse the repository at this point in the history
Add runc update command support for Intel RDT/CAT.

for example:
runc update --l3-cache-schema "L3:0=f;1=f" <container-id>

Signed-off-by: Xiaochen Shen <xiaochen.shen@intel.com>
  • Loading branch information
xiaochenshen committed Sep 19, 2017
1 parent 2549545 commit 65918b0
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions update.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strconv" "strconv"


"github.com/docker/go-units" "github.com/docker/go-units"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runc/libcontainer/intelrdt"
"github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/runtime-spec/specs-go"
"github.com/urfave/cli" "github.com/urfave/cli"
) )
Expand Down Expand Up @@ -112,6 +114,10 @@ other options are ignored.
Name: "pids-limit", Name: "pids-limit",
Usage: "Maximum number of pids allowed in the container", Usage: "Maximum number of pids allowed in the container",
}, },
cli.StringFlag{
Name: "l3-cache-schema",
Usage: "The string of Intel RDT/CAT L3 cache schema",
},
}, },
Action: func(context *cli.Context) error { Action: func(context *cli.Context) error {
if err := checkArgs(context, 1, exactArgs); err != nil { if err := checkArgs(context, 1, exactArgs); err != nil {
Expand Down Expand Up @@ -254,6 +260,34 @@ other options are ignored.
config.Cgroups.Resources.MemorySwap = *r.Memory.Swap config.Cgroups.Resources.MemorySwap = *r.Memory.Swap
config.Cgroups.Resources.PidsLimit = r.Pids.Limit config.Cgroups.Resources.PidsLimit = r.Pids.Limit


// Update Intel RDT/CAT
if val := context.String("l3-cache-schema"); val != "" {
if !intelrdt.IsEnabled() {
return fmt.Errorf("Intel RDT: l3 cache schema is not enabled")
}

// If intelRdt is not specified in original configuration, we just don't
// Apply() to create intelRdt group or attach tasks for this container.
// In update command, we could re-enable through IntelRdtManager.Apply()
// and then update intelrdt constraint.
if config.IntelRdt == nil {
state, err := container.State()
if err != nil {
return err
}
config.IntelRdt = &configs.IntelRdt{}
intelRdtManager := intelrdt.IntelRdtManager{
Config: &config,
Id: container.ID(),
Path: state.IntelRdtPath,
}
if err := intelRdtManager.Apply(state.InitProcessPid); err != nil {
return err
}
}
config.IntelRdt.L3CacheSchema = val
}

return container.Set(config) return container.Set(config)
}, },
} }

0 comments on commit 65918b0

Please sign in to comment.