Skip to content

Commit 65918b0

Browse files
committed
intelrdt: add update command support
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 <[email protected]>
1 parent 2549545 commit 65918b0

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

update.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"strconv"
1010

1111
"github.com/docker/go-units"
12+
"github.com/opencontainers/runc/libcontainer/configs"
13+
"github.com/opencontainers/runc/libcontainer/intelrdt"
1214
"github.com/opencontainers/runtime-spec/specs-go"
1315
"github.com/urfave/cli"
1416
)
@@ -112,6 +114,10 @@ other options are ignored.
112114
Name: "pids-limit",
113115
Usage: "Maximum number of pids allowed in the container",
114116
},
117+
cli.StringFlag{
118+
Name: "l3-cache-schema",
119+
Usage: "The string of Intel RDT/CAT L3 cache schema",
120+
},
115121
},
116122
Action: func(context *cli.Context) error {
117123
if err := checkArgs(context, 1, exactArgs); err != nil {
@@ -254,6 +260,34 @@ other options are ignored.
254260
config.Cgroups.Resources.MemorySwap = *r.Memory.Swap
255261
config.Cgroups.Resources.PidsLimit = r.Pids.Limit
256262

263+
// Update Intel RDT/CAT
264+
if val := context.String("l3-cache-schema"); val != "" {
265+
if !intelrdt.IsEnabled() {
266+
return fmt.Errorf("Intel RDT: l3 cache schema is not enabled")
267+
}
268+
269+
// If intelRdt is not specified in original configuration, we just don't
270+
// Apply() to create intelRdt group or attach tasks for this container.
271+
// In update command, we could re-enable through IntelRdtManager.Apply()
272+
// and then update intelrdt constraint.
273+
if config.IntelRdt == nil {
274+
state, err := container.State()
275+
if err != nil {
276+
return err
277+
}
278+
config.IntelRdt = &configs.IntelRdt{}
279+
intelRdtManager := intelrdt.IntelRdtManager{
280+
Config: &config,
281+
Id: container.ID(),
282+
Path: state.IntelRdtPath,
283+
}
284+
if err := intelRdtManager.Apply(state.InitProcessPid); err != nil {
285+
return err
286+
}
287+
}
288+
config.IntelRdt.L3CacheSchema = val
289+
}
290+
257291
return container.Set(config)
258292
},
259293
}

0 commit comments

Comments
 (0)