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)
76 fprintf(stderr, "getdelays [-dilv] [-w logfile] [-r bufsize] " in usage()
77 "[-m cpumask] [-t tgid] [-p pid]\n"); in usage()
78 fprintf(stderr, " -d: print delayacct stats\n"); in usage()
79 fprintf(stderr, " -i: print IO accounting (works only with -p)\n"); in usage()
80 fprintf(stderr, " -l: listen forever\n"); in usage()
81 fprintf(stderr, " -v: debug on\n"); in usage()
82 fprintf(stderr, " -C: container path\n"); in usage()
94 if (fd < 0) in create_nl_socket()
95 return -1; in create_nl_socket()
99 &rcvbufsz, sizeof(rcvbufsz)) < 0) { in create_nl_socket()
105 memset(&local, 0, sizeof(local)); in create_nl_socket()
108 if (bind(fd, (struct sockaddr *) &local, sizeof(local)) < 0) in create_nl_socket()
114 return -1; in create_nl_socket()
132 msg.n.nlmsg_seq = 0; in send_cmd()
135 msg.g.version = 0x1; in send_cmd()
137 na->nla_type = nla_type; in send_cmd()
138 na->nla_len = nla_len + NLA_HDRLEN; in send_cmd()
140 msg.n.nlmsg_len += NLMSG_ALIGN(na->nla_len); in send_cmd()
144 memset(&nladdr, 0, sizeof(nladdr)); in send_cmd()
146 while ((r = sendto(sd, buf, buflen, 0, (struct sockaddr *) &nladdr, in send_cmd()
148 if (r > 0) { in send_cmd()
150 buflen -= r; in send_cmd()
152 return -1; in send_cmd()
154 return 0; in send_cmd()
170 int id = 0, rc; in get_family_id()
178 if (rc < 0) in get_family_id()
179 return 0; /* sendto() failure? */ in get_family_id()
181 rep_len = recv(sd, &ans, sizeof(ans), 0); in get_family_id()
183 (rep_len < 0) || !NLMSG_OK((&ans.n), rep_len)) in get_family_id()
184 return 0; in get_family_id()
187 na = (struct nlattr *) ((char *) na + NLA_ALIGN(na->nla_len)); in get_family_id()
188 if (na->nla_type == CTRL_ATTR_FAMILY_ID) { in get_family_id()
198 printf("\n\nCPU %15s%15s%15s%15s%15s\n" in print_delayacct()
199 " %15llu%15llu%15llu%15llu%15.3fms\n" in print_delayacct()
200 "IO %15s%15s%15s\n" in print_delayacct()
201 " %15llu%15llu%15.3fms\n" in print_delayacct()
202 "SWAP %15s%15s%15s\n" in print_delayacct()
203 " %15llu%15llu%15.3fms\n" in print_delayacct()
204 "RECLAIM %12s%15s%15s\n" in print_delayacct()
205 " %15llu%15llu%15.3fms\n" in print_delayacct()
206 "THRASHING%12s%15s%15s\n" in print_delayacct()
207 " %15llu%15llu%15.3fms\n" in print_delayacct()
208 "COMPACT %12s%15s%15s\n" in print_delayacct()
209 " %15llu%15llu%15.3fms\n" in print_delayacct()
210 "WPCOPY %12s%15s%15s\n" in print_delayacct()
211 " %15llu%15llu%15.3fms\n" in print_delayacct()
212 "IRQ %15s%15s%15s\n" in print_delayacct()
213 " %15llu%15llu%15.3fms\n", in print_delayacct()
216 (unsigned long long)t->cpu_count, in print_delayacct()
217 (unsigned long long)t->cpu_run_real_total, in print_delayacct()
218 (unsigned long long)t->cpu_run_virtual_total, in print_delayacct()
219 (unsigned long long)t->cpu_delay_total, in print_delayacct()
220 average_ms((double)t->cpu_delay_total, t->cpu_count), in print_delayacct()
222 (unsigned long long)t->blkio_count, in print_delayacct()
223 (unsigned long long)t->blkio_delay_total, in print_delayacct()
224 average_ms((double)t->blkio_delay_total, t->blkio_count), in print_delayacct()
226 (unsigned long long)t->swapin_count, in print_delayacct()
227 (unsigned long long)t->swapin_delay_total, in print_delayacct()
228 average_ms((double)t->swapin_delay_total, t->swapin_count), in print_delayacct()
230 (unsigned long long)t->freepages_count, in print_delayacct()
231 (unsigned long long)t->freepages_delay_total, in print_delayacct()
232 average_ms((double)t->freepages_delay_total, t->freepages_count), in print_delayacct()
234 (unsigned long long)t->thrashing_count, in print_delayacct()
235 (unsigned long long)t->thrashing_delay_total, in print_delayacct()
236 average_ms((double)t->thrashing_delay_total, t->thrashing_count), in print_delayacct()
238 (unsigned long long)t->compact_count, in print_delayacct()
239 (unsigned long long)t->compact_delay_total, in print_delayacct()
240 average_ms((double)t->compact_delay_total, t->compact_count), in print_delayacct()
242 (unsigned long long)t->wpcopy_count, in print_delayacct()
243 (unsigned long long)t->wpcopy_delay_total, in print_delayacct()
244 average_ms((double)t->wpcopy_delay_total, t->wpcopy_count), in print_delayacct()
246 (unsigned long long)t->irq_count, in print_delayacct()
247 (unsigned long long)t->irq_delay_total, in print_delayacct()
248 average_ms((double)t->irq_delay_total, t->irq_count)); in print_delayacct()
253 printf("\n\nTask %15s%15s\n" in task_context_switch_counts()
254 " %15llu%15llu\n", in task_context_switch_counts()
256 (unsigned long long)t->nvcsw, (unsigned long long)t->nivcsw); in task_context_switch_counts()
262 "uninterruptible %llu\n", (unsigned long long)c->nr_sleeping, in print_cgroupstats()
263 (unsigned long long)c->nr_io_wait, in print_cgroupstats()
264 (unsigned long long)c->nr_running, in print_cgroupstats()
265 (unsigned long long)c->nr_stopped, in print_cgroupstats()
266 (unsigned long long)c->nr_uninterruptible); in print_cgroupstats()
273 t->ac_comm, in print_ioacct()
274 (unsigned long long)t->read_bytes, in print_ioacct()
275 (unsigned long long)t->write_bytes, in print_ioacct()
276 (unsigned long long)t->cancelled_write_bytes); in print_ioacct()
287 int nl_sd = -1; in main()
288 int len = 0; in main()
289 pid_t tid = 0; in main()
290 pid_t rtid = 0; in main()
292 int fd = 0; in main()
293 int write_file = 0; in main()
294 int maskset = 0; in main()
296 int loop = 0; in main()
297 int containerset = 0; in main()
299 int cfd = 0; in main()
300 int forking = 0; in main()
307 if (c < 0) in main()
335 if (rcvbufsz < 0) in main()
340 cpumask[sizeof(cpumask) - 1] = '\0'; in main()
359 if (sigemptyset(&sigset) == -1) in main()
367 if (tid < 0) in main()
369 if (tid == 0) in main()
370 if (execvp(argv[optind - 1], in main()
371 &argv[optind - 1]) < 0) in main()
372 exit(-1); in main()
388 exit(-1); in main()
395 if (fd == -1) { in main()
402 if (nl_sd < 0) in main()
419 if (rc < 0) { in main()
426 fprintf(stderr, "Select either -t or -C, not both\n"); in main()
443 if (rc < 0) { in main()
451 if (cfd < 0) { in main()
457 if (rc < 0) { in main()
468 rep_len = recv(nl_sd, &msg, sizeof(msg), 0); in main()
471 if (rep_len < 0) { in main()
480 err->error); in main()
491 len = 0; in main()
493 len += NLA_ALIGN(na->nla_len); in main()
494 switch (na->nla_type) { in main()
498 aggr_len = NLA_PAYLOAD(na->nla_len); in main()
499 len2 = 0; in main()
503 switch (na->nla_type) { in main()
522 if (write(fd, NLA_DATA(na), na->nla_len) < 0) { in main()
534 na->nla_type); in main()
537 len2 += NLA_ALIGN(na->nla_len); in main()
539 NLA_ALIGN(na->nla_len)); in main()
548 na->nla_type); in main()
561 if (rc < 0) in main()
570 return 0; in main()