From c26ca15cc787987266c5fabf3cc3b15eba34ae36 Mon Sep 17 00:00:00 2001 From: Rohit Jnagal Date: Mon, 26 Jan 2015 23:48:39 +0000 Subject: [PATCH] Make cpu load stats hierarchical for scheddebug. --- utils/cpuload/scheddebug/scheddebug.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/cpuload/scheddebug/scheddebug.go b/utils/cpuload/scheddebug/scheddebug.go index 2c57059e..6a9c4575 100644 --- a/utils/cpuload/scheddebug/scheddebug.go +++ b/utils/cpuload/scheddebug/scheddebug.go @@ -17,6 +17,7 @@ package scheddebug import ( "fmt" "io/ioutil" + "path" "regexp" "strconv" "strings" @@ -110,9 +111,15 @@ func (self *SchedReader) refresh() { // collapse all autogroups to root. cgroup = "/" } - // TODO(rjnagal): Walk up the path and add load to all parent containers. That will make - // it different from netlink approach which is non-hierarchical. load[cgroup] += int(numRunning) + // Walk up the path and add load to all parent containers. + for cgroup != "/" { + cgroup = path.Dir(cgroup) + if cgroup == "." { + cgroup = "/" + } + load[cgroup] += int(numRunning) + } } glog.V(2).Infof("New loads : %+v", load) self.dataLock.Lock()