Lines Matching +full:entry +full:- +full:latency

1 // SPDX-License-Identifier: GPL-2.0
44 C(FUNC_TR, "function-trace"), \
45 C(DISP_GR, "display-graph"), \
134 "No latency tracers are supported by your kernel!\n";
184 struct entry {
222 struct entry entries[QUEUE_SIZE];
271 count -= r;
519 future->tv_sec += time_us / USEC_PER_SEC;
520 nsec = future->tv_nsec + (time_us * NSEC_PER_USEC) % NSEC_PER_SEC;
522 future->tv_nsec = nsec % NSEC_PER_SEC;
523 future->tv_sec += 1;
532 if (now.tv_sec > time->tv_sec)
534 if (now.tv_sec < time->tv_sec)
536 return (now.tv_nsec >= time->tv_nsec);
560 if (state->opt_valid[i] && state->opt[i] != cur[i]) {
561 r = set_trace_opt(optstr[i], state->opt[i]);
564 optstr[i], bool2str(state->opt[i]));
568 bool2str(state->opt[i]));
588 if (r && r[psize - 1] == '\n')
589 r[psize - 1] = '\0';
631 printf("The maximum detected latency was: %sus\n", maxlat);
661 static int printstate_next_ticket(struct entry *req)
666 req->ticket = r;
667 req->ticket_completed_ref = printstate.ticket_completed;
673 void printstate_mark_req_completed(const struct entry *req)
675 if (req->ticket > printstate.ticket_completed)
676 printstate.ticket_completed = req->ticket;
680 bool printstate_has_new_req_arrived(const struct entry *req)
682 return (printstate.ticket_counter != req->ticket);
700 value = --printstate.cnt;
716 bool prev_req_won_race(const struct entry *req)
718 return (printstate.ticket_completed != req->ticket_completed_ref);
726 msg->len = 0;
728 bytes = snprintf(msg->buf, sizeof(msg->buf),
731 bytes = snprintf(msg->buf, sizeof(msg->buf),
736 msg->len = bytes;
746 sleeptable.table = &probabilities[PROB_TABLE_MAX_SIZE - size];
756 j--;
761 static int table_get_probability(const struct entry *req,
764 int diff = req->ticket - req->ticket_completed_ref;
767 msg->len = 0;
768 diff--;
776 if (diff >= (sleeptable.size - 1)) {
777 rval = sleeptable.table[sleeptable.size - 1];
789 q->next_prod_idx = 0;
790 q->next_cons_idx = 0;
791 mutex_init(&q->mutex, NULL);
792 errno = pthread_cond_init(&q->cond, NULL);
799 if (q->next_prod_idx >= q->next_cons_idx)
800 return q->next_prod_idx - q->next_cons_idx;
802 return QUEUE_SIZE - q->next_cons_idx + q->next_prod_idx;
807 int nr_free = QUEUE_SIZE - queue_len(q);
824 const struct entry *e)
826 q->entries[q->next_prod_idx] = *e;
827 queue_idx_inc(&q->next_prod_idx);
830 static __always_inline struct entry queue_pop_from_front(struct queue *q)
832 struct entry e = q->entries[q->next_cons_idx];
834 queue_idx_inc(&q->next_cons_idx);
840 cond_signal(&q->cond);
845 cond_wait(&q->cond, &q->mutex);
849 const struct entry *e)
853 mutex_lock(&q->mutex);
856 cond_signal(&q->cond);
858 r = -1;
859 mutex_unlock(&q->mutex);
863 static struct entry queue_wait_for_entry(struct queue *q)
865 struct entry e;
867 mutex_lock(&q->mutex);
875 mutex_unlock(&q->mutex);
884 while (p->name != NULL) {
885 if (!strcmp(name, p->name))
897 while (p->name != NULL) {
898 if (p->policy == policy)
899 return p->name;
948 printf("The following latency tracers are available on your system:\n");
1009 static long go_to_sleep(const struct entry *req)
1024 delay = -1;
1074 size_t bufspace, const struct entry *req, bool excuse,
1082 sec = timestamp->tv_sec;
1083 us = timestamp->tv_nsec / 1000;
1085 if (resize_msg != NULL && resize_msg->len > 0) {
1086 strncpy(p, resize_msg->buf, resize_msg->len);
1087 bytes += resize_msg->len;
1088 p += resize_msg->len;
1089 bufspace -= resize_msg->len;
1094 "%ld.%06ld Latency %d printout skipped due to %s\n",
1095 sec, us, req->ticket, str);
1097 r = snprintf(p, bufspace, "%ld.%06ld Latency %d detected\n",
1098 sec, us, req->ticket);
1113 size_t bufspace, const struct entry *req,
1121 size_t bufspace, const struct entry *req,
1131 const struct entry *req)
1142 bufspace = bufspace - reserve - 1;
1144 if (resize_msg != NULL && resize_msg->len > 0) {
1145 bytes = resize_msg->len;
1146 strncpy(p, resize_msg->buf, bytes);
1149 bufspace -= bytes;
1159 sec = timestamp->tv_sec;
1160 us = timestamp->tv_nsec / 1000;
1165 "%ld.%06ld Latency %d randomly sleep for %ld ms before print\n",
1166 sec, us, req->ticket, slept_ms);
1169 "%ld.%06ld Latency %d immediate print\n", sec,
1170 us, req->ticket);
1178 bufspace -= bytes;
1191 bufspace -= bytes;
1207 bufspace -= bytes;
1334 state->opt[i] = get_trace_opt(allopt, optstr[i],
1335 &state->opt_valid[i]);
1393 "Use the -F [--force] option to disregard the current tracer.\n", tracer);
1420 if (state->opt_valid[i] &&
1421 state->opt[i] != new[i]) {
1459 struct entry req;
1513 if ((event->mask & IN_MODIFY) != 0)
1515 p += istructsize + event->len;
1544 modified--;
1556 struct entry req;
1589 * latency tracer. Thus by randomly sleeping we try to avoid
1591 * we will sometimes get the first latency, some other times
1675 "The occurrence of a latency is detected by monitoring the file\n"
1680 "-l, --list\t\tList the latency tracers that are supported by the\n"
1685 "-t, --tracer TR\t\tUse the tracer TR. The default is to use the first\n"
1698 "-F, --force\t\tProceed even if another ftrace tracer is active. Without\n"
1702 "-s, --threshold TH\tConfigure ftrace to use a threshold of TH microseconds\n"
1708 "-f, --function\t\tEnable the function-trace option in trace_options. With\n"
1710 "\t\t\texecuted during a latency, without it we only get the\n"
1713 "-g, --graph\t\tEnable the display-graph option in trace_option. This\n"
1717 "-c, --policy POL\tRun the program with scheduling policy POL. POL can be\n"
1722 "-p, --priority PRI\tRun the program with priority PRI. The acceptable range\n"
1725 "-n, --notrace\t\tIf latency is detected, do not print out the content of\n"
1728 "-t, --threads NRTHR\tRun NRTHR threads for printing. Default is %d.\n\n"
1730 "-r, --random\t\tArbitrarily sleep a certain amount of time, default\n"
1739 "-a, --nrlat NRLAT\tFor the purpose of arbitrary delay, assume that there\n"
1744 "\t\t\timplies -r. We need to know this number in order to\n"
1748 "\t\t\t1/NRLAT 1/(NRLAT - 1) ... 1/3 1/2 1\n\n"
1750 "\t\t\t1 - P, where P is from the series above\n\n"
1757 "\t\t\tThis means, when a latency is detected we will sleep\n"
1758 "\t\t\twith 50%% probability. If we ever detect another latency\n"
1763 "-v, --verbose\t\tIncrease the verbosity. If this option is given once,\n"
1770 "-u, --time TIME\t\tArbitrarily sleep for a specified time TIME ms before\n"
1772 "\t\t\tis %ld ms. This option implies -r.\n\n"
1774 "-x, --no-ftrace\t\tDo not configure ftrace. This assume that the user\n"
1778 "-i, --tracefile FILE\tUse FILE as trace file. The default is\n"
1780 "\t\t\tThis options implies -x\n\n"
1782 "-m, --max-lat FILE\tUse FILE as tracing_max_latency file. The default is\n"
1784 "\t\t\tThis options implies -x\n\n"
1846 { "no-ftrace", no_argument, 0, 'x' },
1848 { "max-lat", required_argument, 0, 'm' },
1865 if (c == -1)
1876 warnx("%s is not a known latency tracer!\n",
1890 check_alldigits(optarg, "-s [--threshold]");
1902 sched_policy = p->policy;
1905 sched_pri = p->default_pri;
1915 check_alldigits(optarg, "-p [--priority]");
1928 check_alldigits(optarg, "-e [--threads]");
1939 check_alldigits(optarg, "-u [--time]");
1958 check_alldigits(optarg, "-a [--nrlat]");