Lines Matching +full:1 +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)
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()
95 return -1; in create_nl_socket()
114 return -1; in create_nl_socket()
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()
150 buflen -= r; in send_cmd()
152 return -1; in send_cmd()
177 strlen(TASKSTATS_GENL_NAME)+1); 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()
194 #define average_ms(t, c) (t / 1000000ULL / (c ? c : 1))
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()
313 print_delays = 1; in main()
317 print_io_accounting = 1; in main()
321 print_task_context_switch_counts = 1; in main()
324 containerset = 1; in main()
330 write_file = 1; in main()
336 err(1, "Invalid rcv buf size\n"); in main()
340 cpumask[sizeof(cpumask) - 1] = '\0'; in main()
341 maskset = 1; in main()
347 err(1, "Invalid tgid\n"); in main()
353 err(1, "Invalid pid\n"); in main()
359 if (sigemptyset(&sigset) == -1) in main()
360 err(1, "Failed to empty sigset"); in main()
362 err(1, "Failed to set sigchld in sigset"); in main()
368 err(1, "Fork failed\n"); in main()
370 if (execvp(argv[optind - 1], in main()
371 &argv[optind - 1]) < 0) in main()
372 exit(-1); in main()
376 forking = 1; in main()
380 dbg = 1; in main()
384 loop = 1; in main()
388 exit(-1); in main()
395 if (fd == -1) { in main()
397 exit(1); in main()
403 err(1, "error creating Netlink socket\n"); in main()
417 &cpumask, strlen(cpumask) + 1); in main()
426 fprintf(stderr, "Select either -t or -C, not both\n"); in main()
480 err->error); 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()
503 switch (na->nla_type) { in main()
522 if (write(fd, NLA_DATA(na), na->nla_len) < 0) { in main()
523 err(1,"write error\n"); 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()
559 &cpumask, strlen(cpumask) + 1); in main()