Lines Matching +full:0 +full:- +full:15
1 // SPDX-License-Identifier: GPL-2.0
4 * Utility to get per-pid and per-tgid delay accounting statistics
12 * gcc -I/usr/src/linux/include getdelays.c -o getdelays
38 #define GENLMSG_PAYLOAD(glh) (NLMSG_PAYLOAD(glh, 0) - GENL_HDRLEN)
40 #define NLA_PAYLOAD(len) (len - NLA_HDRLEN)
46 } while (0)
77 fprintf(stderr, "getdelays [-dilv] [-w logfile] [-r bufsize] " in usage()
78 "[-m cpumask] [-t tgid] [-p pid]\n"); in usage()
79 fprintf(stderr, " -d: print delayacct stats\n"); in usage()
80 fprintf(stderr, " -i: print IO accounting (works only with -p)\n"); in usage()
81 fprintf(stderr, " -l: listen forever\n"); in usage()
82 fprintf(stderr, " -v: debug on\n"); in usage()
83 fprintf(stderr, " -C: container path\n"); in usage()
95 if (fd < 0) in create_nl_socket()
96 return -1; in create_nl_socket()
100 &rcvbufsz, sizeof(rcvbufsz)) < 0) { in create_nl_socket()
106 memset(&local, 0, sizeof(local)); in create_nl_socket()
109 if (bind(fd, (struct sockaddr *) &local, sizeof(local)) < 0) in create_nl_socket()
115 return -1; in create_nl_socket()
133 msg.n.nlmsg_seq = 0; in send_cmd()
136 msg.g.version = 0x1; in send_cmd()
138 na->nla_type = nla_type; in send_cmd()
139 na->nla_len = nla_len + NLA_HDRLEN; in send_cmd()
141 msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len); in send_cmd()
145 memset(&nladdr, 0, sizeof(nladdr)); in send_cmd()
147 while ((r = sendto(sd, buf, buflen, 0, (struct sockaddr *) &nladdr, in send_cmd()
149 if (r > 0) { in send_cmd()
151 buflen -= r; in send_cmd()
153 return -1; in send_cmd()
155 return 0; in send_cmd()
171 int id = 0, rc; in get_family_id()
179 if (rc < 0) in get_family_id()
180 return 0; /* sendto() failure? */ in get_family_id()
182 rep_len = recv(sd, &ans, sizeof(ans), 0); in get_family_id()
184 (rep_len < 0) || !NLMSG_OK((&ans.n), rep_len)) in get_family_id()
185 return 0; in get_family_id()
188 na = (struct nlattr *) ((char *) na + NLA_ALIGN(na->nla_len)); in get_family_id()
189 if (na->nla_type == CTRL_ATTR_FAMILY_ID) { in get_family_id()
199 printf("\n\nCPU %15s%15s%15s%15s%15s\n" in print_delayacct()
200 " %15llu%15llu%15llu%15llu%15.3fms\n" in print_delayacct()
201 "IO %15s%15s%15s\n" in print_delayacct()
202 " %15llu%15llu%15llums\n" in print_delayacct()
203 "SWAP %15s%15s%15s\n" in print_delayacct()
204 " %15llu%15llu%15llums\n" in print_delayacct()
205 "RECLAIM %12s%15s%15s\n" in print_delayacct()
206 " %15llu%15llu%15llums\n" in print_delayacct()
207 "THRASHING%12s%15s%15s\n" in print_delayacct()
208 " %15llu%15llu%15llums\n", in print_delayacct()
211 (unsigned long long)t->cpu_count, in print_delayacct()
212 (unsigned long long)t->cpu_run_real_total, in print_delayacct()
213 (unsigned long long)t->cpu_run_virtual_total, in print_delayacct()
214 (unsigned long long)t->cpu_delay_total, in print_delayacct()
215 average_ms((double)t->cpu_delay_total, t->cpu_count), in print_delayacct()
217 (unsigned long long)t->blkio_count, in print_delayacct()
218 (unsigned long long)t->blkio_delay_total, in print_delayacct()
219 average_ms(t->blkio_delay_total, t->blkio_count), in print_delayacct()
221 (unsigned long long)t->swapin_count, in print_delayacct()
222 (unsigned long long)t->swapin_delay_total, in print_delayacct()
223 average_ms(t->swapin_delay_total, t->swapin_count), in print_delayacct()
225 (unsigned long long)t->freepages_count, in print_delayacct()
226 (unsigned long long)t->freepages_delay_total, in print_delayacct()
227 average_ms(t->freepages_delay_total, t->freepages_count), in print_delayacct()
229 (unsigned long long)t->thrashing_count, in print_delayacct()
230 (unsigned long long)t->thrashing_delay_total, in print_delayacct()
231 average_ms(t->thrashing_delay_total, t->thrashing_count)); in print_delayacct()
236 printf("\n\nTask %15s%15s\n" in task_context_switch_counts()
237 " %15llu%15llu\n", in task_context_switch_counts()
239 (unsigned long long)t->nvcsw, (unsigned long long)t->nivcsw); in task_context_switch_counts()
245 "uninterruptible %llu\n", (unsigned long long)c->nr_sleeping, in print_cgroupstats()
246 (unsigned long long)c->nr_io_wait, in print_cgroupstats()
247 (unsigned long long)c->nr_running, in print_cgroupstats()
248 (unsigned long long)c->nr_stopped, in print_cgroupstats()
249 (unsigned long long)c->nr_uninterruptible); in print_cgroupstats()
256 t->ac_comm, in print_ioacct()
257 (unsigned long long)t->read_bytes, in print_ioacct()
258 (unsigned long long)t->write_bytes, in print_ioacct()
259 (unsigned long long)t->cancelled_write_bytes); in print_ioacct()
270 int nl_sd = -1; in main()
271 int len = 0; in main()
272 pid_t tid = 0; in main()
273 pid_t rtid = 0; in main()
275 int fd = 0; in main()
276 int count = 0; in main()
277 int write_file = 0; in main()
278 int maskset = 0; in main()
280 int loop = 0; in main()
281 int containerset = 0; in main()
283 int cfd = 0; in main()
284 int forking = 0; in main()
291 if (c < 0) in main()
319 if (rcvbufsz < 0) in main()
324 cpumask[sizeof(cpumask) - 1] = '\0'; in main()
343 if (sigemptyset(&sigset) == -1) in main()
351 if (tid < 0) in main()
353 if (tid == 0) in main()
354 if (execvp(argv[optind - 1], in main()
355 &argv[optind - 1]) < 0) in main()
356 exit(-1); in main()
372 exit(-1); in main()
379 if (fd == -1) { in main()
386 if (nl_sd < 0) in main()
403 if (rc < 0) { in main()
410 fprintf(stderr, "Select either -t or -C, not both\n"); in main()
427 if (rc < 0) { in main()
435 if (cfd < 0) { in main()
441 if (rc < 0) { in main()
452 rep_len = recv(nl_sd, &msg, sizeof(msg), 0); in main()
455 if (rep_len < 0) { in main()
464 err->error); in main()
475 len = 0; in main()
477 len += NLA_ALIGN(na->nla_len); in main()
478 switch (na->nla_type) { in main()
482 aggr_len = NLA_PAYLOAD(na->nla_len); in main()
483 len2 = 0; in main()
486 done = 0; in main()
488 switch (na->nla_type) { in main()
508 if (write(fd, NLA_DATA(na), na->nla_len) < 0) { in main()
520 na->nla_type); in main()
523 len2 += NLA_ALIGN(na->nla_len); in main()
525 NLA_ALIGN(na->nla_len)); in main()
534 na->nla_type); in main()
547 if (rc < 0) in main()
556 return 0; in main()