]> git.pld-linux.org Git - packages/util-vserver.git/blob - util-vserver-usersystime.patch
- rel 3; R texlive-fonts-rsfs
[packages/util-vserver.git] / util-vserver-usersystime.patch
1 --- util-vserver-0.30.216-pre2926/src/vserver-stat.c    2010-12-02 16:30:12.000000000 +0100
2 +++ util-vserver-0.30.216-pre2926.new/src/vserver-stat.c        2011-01-18 20:32:23.465389530 +0100
3 @@ -309,6 +309,7 @@
4      unsigned long long         rss;
5      char                       *endptr;
6      size_t                     len;
7 +    uint64_t                   stime_total, utime_total;
8  
9      if (vc_virt_stat(xid, &vstat) == -1) {
10        perror("vc_virt_stat()");
11 @@ -402,6 +403,24 @@
12        return;
13      }
14  
15 +    strcpy(filename, cgroup);
16 +    strcpy(filename + cgroup_len, "/cpuacct.stat");
17 +
18 +    if ((fd = open(filename, O_RDONLY)) == -1) {
19 +      perror("open(cpuacct.stat)");
20 +      return;
21 +    }
22 +    if (read(fd, buf, sizeof(buf)) == -1) {
23 +      perror("read(cpuacct.stat)");
24 +      return;
25 +    }
26 +    close(fd);
27 +
28 +    if (sscanf(buf, "user %lu\nsystem %lu\n", &utime_total, &stime_total) != 2) {
29 +      perror("sscanf(cpuacct.stat)");
30 +      return;
31 +    }
32 +
33      res                        = Vector_insert(vec, &xid, cmpData);
34      res->xid           = xid;
35  
36 @@ -409,18 +428,8 @@
37      res->VmRSS_total   = rss / 4096;
38      res->start_time_oldest= getUptime() - vstat.uptime/1000000;
39  
40 -    res->utime_total   = 0;
41 -    res->stime_total   = 0;
42 -    // XXX: arbitrary CPU limit.
43 -    for (cpu = 0; cpu < 1024; cpu++) {
44 -      sched.cpu_id = cpu;
45 -      sched.bucket_id = 0;
46 -      if (vc_sched_info(xid, &sched) == -1)
47 -        break;
48 -
49 -      res->utime_total += sched.user_msec;
50 -      res->stime_total += sched.sys_msec;
51 -    }
52 +    res->utime_total   = utime_total * 100 /* USER_HZ */;
53 +    res->stime_total   = stime_total * 100 /* USER_HZ */;
54    }
55    
56    res->VmSize_total    += process->VmSize;
57
This page took 0.036513 seconds and 3 git commands to generate.