runc:fix update rt-runtime-us and rt-period-us failed

(cherry picked from commit 8ea12dd106966f2a1cfc9884c6813781448116a8)
This commit is contained in:
zhongjiawei 2023-10-24 16:18:19 +08:00 committed by openeuler-sync-bot
parent 8fdc1ebc38
commit 5f98ac951a
4 changed files with 57 additions and 2 deletions

View File

@ -1 +1 @@
f00c21f87036fd8a6f453ae0ba294f2c7f70503e
7f4d3483bdf8c5ec6bfec21d2afd9621c3bdceee

View File

@ -0,0 +1,48 @@
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

View File

@ -3,7 +3,7 @@
Name: docker-runc
Version: 1.1.3
Release: 16
Release: 18
Summary: runc is a CLI tool for spawning and running containers according to the OCI specification.
License: ASL 2.0
@ -54,6 +54,12 @@ install -p -m 755 runc $RPM_BUILD_ROOT/%{_bindir}/runc
%{_bindir}/runc
%changelog
* Tue Oct 24 2023 zhongjiawei<zhongjiawei1@huawei.com> - 1.1.3-18
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix update rt-runtime-us and rt-period-us failed
* Thu Oct 12 2023 zhongjiawei<zhongjiawei1@huawei.com> - 1.1.3-17
- Type:bugfix
- ID:NA

View File

@ -40,3 +40,4 @@ patch/0039-runc-libct-fix-a-race-with-systemd-removal.patch
patch/0040-runc-run-refuse-a-non-empty-cgroup.patch
patch/0041-runc-libct-init-unify-init-fix-its-error-logic.patch
patch/0042-runc-Handle-kmem.limit_in_bytes-removal.patch
patch/0043-runc-fix-update-rt-runtime-us-and-rt-period-us-faile.patch