49 lines
1.6 KiB
Diff
49 lines
1.6 KiB
Diff
From 744a90222c009d1cc42c7b3bc43723d6824f2f80 Mon Sep 17 00:00:00 2001
|
|
From: zhongjiawei <zhongjiawei1@huawei.com>
|
|
Date: Fri, 20 Oct 2023 16:42:02 +0800
|
|
Subject: [PATCH] runc:fix update rt-runtime-us and rt-period-us failed
|
|
|
|
---
|
|
libcontainer/cgroups/fs/cpu.go | 20 +++++++++++++++-----
|
|
1 file changed, 15 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/libcontainer/cgroups/fs/cpu.go b/libcontainer/cgroups/fs/cpu.go
|
|
index 6c79f899..0b58781d 100644
|
|
--- a/libcontainer/cgroups/fs/cpu.go
|
|
+++ b/libcontainer/cgroups/fs/cpu.go
|
|
@@ -35,16 +35,26 @@ func (s *CpuGroup) Apply(path string, r *configs.Resources, pid int) error {
|
|
}
|
|
|
|
func (s *CpuGroup) SetRtSched(path string, r *configs.Resources) error {
|
|
- if r.CpuRtPeriod != 0 {
|
|
- if err := cgroups.WriteFile(path, "cpu.rt_period_us", strconv.FormatUint(r.CpuRtPeriod, 10)); err != nil {
|
|
- return err
|
|
+ var err error
|
|
+ if r.CpuRtRuntime != 0 {
|
|
+ if err = cgroups.WriteFile(path, "cpu.rt_runtime_us", strconv.FormatInt(r.CpuRtRuntime, 10)); err != nil {
|
|
+ if r.CpuRtPeriod != 0 {
|
|
+ if err = cgroups.WriteFile(path, "cpu.rt_period_us", strconv.FormatUint(r.CpuRtPeriod, 10)); err != nil {
|
|
+ return err
|
|
+ }
|
|
+ }
|
|
+ if err = cgroups.WriteFile(path, "cpu.rt_runtime_us", strconv.FormatInt(r.CpuRtRuntime, 10)); err != nil {
|
|
+ return err
|
|
+ }
|
|
+ return nil
|
|
}
|
|
}
|
|
- if r.CpuRtRuntime != 0 {
|
|
- if err := cgroups.WriteFile(path, "cpu.rt_runtime_us", strconv.FormatInt(r.CpuRtRuntime, 10)); err != nil {
|
|
+ if r.CpuRtPeriod != 0 {
|
|
+ if err = cgroups.WriteFile(path, "cpu.rt_period_us", strconv.FormatUint(r.CpuRtPeriod, 10)); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
+
|
|
return nil
|
|
}
|
|
|
|
--
|
|
2.33.0
|
|
|