Lines Matching +full:recv +full:- +full:not +full:- +full:empty

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()
181 rep_len = recv(sd, &ans, sizeof(ans), 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()
199 * Field availability depends on taskstats version (t->version),
204 * version >= 11 - supports COMPACT statistics
205 * version >= 13 - supports WPCOPY statistics
206 * version >= 14 - supports IRQ statistics
207 * version >= 16 - supports *_max and *_min delay statistics
209 * Always verify version before accessing version-dependent fields
215 printf("%-10s%15s%15s%15s%15s%15s%15s%15s\n", \
219 (unsigned long long)(t)->cpu_count, \
220 (unsigned long long)(t)->cpu_run_real_total, \
221 (unsigned long long)(t)->cpu_run_virtual_total, \
222 (unsigned long long)(t)->cpu_delay_total, \
223 average_ms((double)(t)->cpu_delay_total, (t)->cpu_count), \
224 delay_ms((double)(t)->cpu_delay_max), \
225 delay_ms((double)(t)->cpu_delay_min)); \
227 printf("%-10s%15s%15s%15s%15s%15s\n", \
231 (unsigned long long)(t)->cpu_count, \
232 (unsigned long long)(t)->cpu_run_real_total, \
233 (unsigned long long)(t)->cpu_run_virtual_total, \
234 (unsigned long long)(t)->cpu_delay_total, \
235 average_ms((double)(t)->cpu_delay_total, (t)->cpu_count)); \
241 printf("%-10s%15s%15s%15s%15s%15s\n", \
245 (unsigned long long)(t)->count, \
246 (unsigned long long)(t)->total, \
247 average_ms((double)(t)->total, (t)->count), \
248 delay_ms((double)(t)->max), \
249 delay_ms((double)(t)->min)); \
251 printf("%-10s%15s%15s%15s\n", \
254 (unsigned long long)(t)->count, \
255 (unsigned long long)(t)->total, \
256 average_ms((double)(t)->total, (t)->count)); \
264 PRINT_CPU_DELAY(t->version, t); in print_delayacct()
266 PRINT_FILED_DELAY("IO", t->version, t, in print_delayacct()
270 PRINT_FILED_DELAY("SWAP", t->version, t, in print_delayacct()
274 PRINT_FILED_DELAY("RECLAIM", t->version, t, in print_delayacct()
278 PRINT_FILED_DELAY("THRASHING", t->version, t, in print_delayacct()
282 if (t->version >= 11) { in print_delayacct()
283 PRINT_FILED_DELAY("COMPACT", t->version, t, in print_delayacct()
288 if (t->version >= 13) { in print_delayacct()
289 PRINT_FILED_DELAY("WPCOPY", t->version, t, in print_delayacct()
294 if (t->version >= 14) { in print_delayacct()
295 PRINT_FILED_DELAY("IRQ", t->version, t, in print_delayacct()
306 (unsigned long long)t->nvcsw, (unsigned long long)t->nivcsw); in task_context_switch_counts()
312 "uninterruptible %llu\n", (unsigned long long)c->nr_sleeping, in print_cgroupstats()
313 (unsigned long long)c->nr_io_wait, in print_cgroupstats()
314 (unsigned long long)c->nr_running, in print_cgroupstats()
315 (unsigned long long)c->nr_stopped, in print_cgroupstats()
316 (unsigned long long)c->nr_uninterruptible); in print_cgroupstats()
323 t->ac_comm, in print_ioacct()
324 (unsigned long long)t->read_bytes, in print_ioacct()
325 (unsigned long long)t->write_bytes, in print_ioacct()
326 (unsigned long long)t->cancelled_write_bytes); in print_ioacct()
337 int nl_sd = -1; in main()
390 cpumask[sizeof(cpumask) - 1] = '\0'; in main()
409 if (sigemptyset(&sigset) == -1) in main()
410 err(1, "Failed to empty sigset"); in main()
420 if (execvp(argv[optind - 1], in main()
421 &argv[optind - 1]) < 0) in main()
422 exit(-1); in main()
438 exit(-1); in main()
445 if (fd == -1) { in main()
476 fprintf(stderr, "Select either -t or -C, not both\n"); in main()
518 rep_len = recv(nl_sd, &msg, sizeof(msg), 0); in main()
530 err->error); in main()
543 len += NLA_ALIGN(na->nla_len); in main()
544 switch (na->nla_type) { in main()
548 aggr_len = NLA_PAYLOAD(na->nla_len); in main()
553 switch (na->nla_type) { in main()
572 if (write(fd, NLA_DATA(na), na->nla_len) < 0) { in main()
584 na->nla_type); in main()
587 len2 += NLA_ALIGN(na->nla_len); in main()
589 NLA_ALIGN(na->nla_len)); in main()
598 na->nla_type); in main()