X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=Documentation%2Faccounting%2Fgetdelays.c;h=7ea231172c850db1a7eed7127d0bb8a036e56364;hb=0d280884961de51afd87465f72ade9e8876d1e26;hp=24c5aade89987998260f956bfc16dacfe3d48841;hpb=b663a79c191508f27cd885224b592a878c0ba0f6;p=safe%2Fjmp%2Flinux-2.6 diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c index 24c5aad..7ea2311 100644 --- a/Documentation/accounting/getdelays.c +++ b/Documentation/accounting/getdelays.c @@ -21,11 +21,11 @@ #include #include #include -#include #include #include #include +#include /* * Generic macros for dealing with netlink sockets. Might be duplicated @@ -79,6 +79,7 @@ static void usage(void) fprintf(stderr, " -i: print IO accounting (works only with -p)\n"); fprintf(stderr, " -l: listen forever\n"); fprintf(stderr, " -v: debug on\n"); + fprintf(stderr, " -C: container path\n"); } /* @@ -167,7 +168,7 @@ int get_family_id(int sd) char buf[256]; } ans; - int id, rc; + int id = 0, rc; struct nlattr *na; int rep_len; @@ -195,24 +196,45 @@ void print_delayacct(struct taskstats *t) " %15llu%15llu%15llu%15llu\n" "IO %15s%15s\n" " %15llu%15llu\n" - "MEM %15s%15s\n" + "SWAP %15s%15s\n" " %15llu%15llu\n" + "RECLAIM %12s%15s\n" + " %15llu%15llu\n", "count", "real total", "virtual total", "delay total", - t->cpu_count, t->cpu_run_real_total, t->cpu_run_virtual_total, - t->cpu_delay_total, + (unsigned long long)t->cpu_count, + (unsigned long long)t->cpu_run_real_total, + (unsigned long long)t->cpu_run_virtual_total, + (unsigned long long)t->cpu_delay_total, + "count", "delay total", + (unsigned long long)t->blkio_count, + (unsigned long long)t->blkio_delay_total, + "count", "delay total", + (unsigned long long)t->swapin_count, + (unsigned long long)t->swapin_delay_total, "count", "delay total", - t->blkio_count, t->blkio_delay_total, - "count", "delay total", t->swapin_count, t->swapin_delay_total); + (unsigned long long)t->freepages_count, + (unsigned long long)t->freepages_delay_total); } void task_context_switch_counts(struct taskstats *t) { printf("\n\nTask %15s%15s\n" - " %15lu%15lu\n", + " %15llu%15llu\n", "voluntary", "nonvoluntary", - t->nvcsw, t->nivcsw); + (unsigned long long)t->nvcsw, (unsigned long long)t->nivcsw); +} + +void print_cgroupstats(struct cgroupstats *c) +{ + printf("sleeping %llu, blocked %llu, running %llu, stopped %llu, " + "uninterruptible %llu\n", (unsigned long long)c->nr_sleeping, + (unsigned long long)c->nr_io_wait, + (unsigned long long)c->nr_running, + (unsigned long long)c->nr_stopped, + (unsigned long long)c->nr_uninterruptible); } + void print_ioacct(struct taskstats *t) { printf("%s: read=%llu, write=%llu, cancelled_write=%llu\n", @@ -240,11 +262,14 @@ int main(int argc, char *argv[]) int maskset = 0; char *logfile = NULL; int loop = 0; + int containerset = 0; + char containerpath[1024]; + int cfd = 0; struct msgtemplate msg; while (1) { - c = getopt(argc, argv, "qdiw:r:m:t:p:vl"); + c = getopt(argc, argv, "qdiw:r:m:t:p:vlC:"); if (c < 0) break; @@ -261,6 +286,10 @@ int main(int argc, char *argv[]) printf("printing task/process context switch rates\n"); print_task_context_switch_counts = 1; break; + case 'C': + containerset = 1; + strncpy(containerpath, optarg, strlen(optarg) + 1); + break; case 'w': logfile = strdup(optarg); printf("write to file %s\n", logfile); @@ -335,6 +364,11 @@ int main(int argc, char *argv[]) } } + if (tid && containerset) { + fprintf(stderr, "Select either -t or -C, not both\n"); + goto err; + } + if (tid) { rc = send_cmd(nl_sd, id, mypid, TASKSTATS_CMD_GET, cmd_type, &tid, sizeof(__u32)); @@ -345,6 +379,24 @@ int main(int argc, char *argv[]) } } + if (containerset) { + cfd = open(containerpath, O_RDONLY); + if (cfd < 0) { + perror("error opening container file"); + goto err; + } + rc = send_cmd(nl_sd, id, mypid, CGROUPSTATS_CMD_GET, + CGROUPSTATS_CMD_ATTR_FD, &cfd, sizeof(__u32)); + if (rc < 0) { + perror("error sending cgroupstats command"); + goto err; + } + } + if (!maskset && !tid && !containerset) { + usage(); + goto err; + } + do { int i; @@ -364,7 +416,7 @@ int main(int argc, char *argv[]) goto done; } - PRINTF("nlmsghdr size=%d, nlmsg_len=%d, rep_len=%d\n", + PRINTF("nlmsghdr size=%zu, nlmsg_len=%d, rep_len=%d\n", sizeof(struct nlmsghdr), msg.n.nlmsg_len, rep_len); @@ -423,6 +475,9 @@ int main(int argc, char *argv[]) } break; + case CGROUPSTATS_TYPE_CGROUP_STATS: + print_cgroupstats(NLA_DATA(na)); + break; default: fprintf(stderr, "Unknown nla_type %d\n", na->nla_type); @@ -444,5 +499,7 @@ err: close(nl_sd); if (fd) close(fd); + if (cfd) + close(cfd); return 0; }