The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxcfs/pull/303
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Hongbo Yin <yinhon...@bytedance.com> This commit fix container run host pid namespace, the initpid will return 1. then in same case lxcfs will get a lot of error, like this: ``` Aug 5 14:54:11 n10-019-024 lxcfs[3131]: bindings.c: 4503: cpuview_proc_stat: cpu23 from / has unexpected cpu time: 3954948 in /proc/stat, 4062974 in cpuacct.usage_all; unable to determine idle time ``` In some scenarios, the cgroup count is not accurate, which will cause the "/" counter to be greater than the system /proc/stat so if initpid==1 we need return host os's /proc/stat. Instead of getting the data in the cgroup.
From a4bd57aefbaa714d5a41dcacba9e97f00b0822b0 Mon Sep 17 00:00:00 2001 From: Hongbo Yin <yinhon...@bytedance.com> Date: Tue, 27 Aug 2019 01:33:04 +0800 Subject: [PATCH] fix container run pid host mode /proc/stat error log Signed-off-by: Hongbo Yin <yinhon...@bytedance.com> --- bindings.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bindings.c b/bindings.c index 014f400..89fe28d 100644 --- a/bindings.c +++ b/bindings.c @@ -4883,6 +4883,16 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, lxcfs_v("initpid: %d\n", initpid); if (initpid <= 0) initpid = fc->pid; + + /* + * when container run with host pid namespace initpid == 1, cgroup will "/" + * we should return host os's /proc contents. + * in some case cpuacct_usage.all in "/" will larger then /proc/stat + */ + if (initpid == 1) { + return read_file("/proc/stat", buf, size, d); + } + cg = get_pid_cgroup(initpid, "cpuset"); lxcfs_v("cg: %s\n", cg); if (!cg)
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel