count: cleanup count_syscall

* count.c (shortest): Remove.
(overhead): Initialize to zero.
(call_summary_pers): Remove shortest handling.
(count_syscall): Remove dead code.  The remaining code does the same
wrong calculations as before the change, though.
This commit is contained in:
Дмитрий Левин 2018-03-16 00:55:58 +00:00
parent 24c5884e0e
commit b66af24f61

53
count.c
View File

@ -46,60 +46,32 @@ struct call_counts {
static struct call_counts *countv[SUPPORTED_PERSONALITIES];
#define counts (countv[current_personality])
static struct timeval shortest = { 1000000, 0 };
static struct timeval overhead;
void
count_syscall(struct tcb *tcp, const struct timeval *syscall_exiting_tv)
{
struct timeval wtv;
struct timeval *tv = &wtv;
struct call_counts *cc;
if (!scno_in_range(tcp->scno))
return;
if (!counts)
counts = xcalloc(nsyscalls, sizeof(*counts));
cc = &counts[tcp->scno];
struct call_counts *cc = &counts[tcp->scno];
cc->calls++;
if (syserror(tcp))
cc->errors++;
/* tv = wall clock time spent while in syscall */
tv_sub(tv, syscall_exiting_tv, &tcp->etime);
if (count_wallclock) {
/* wall clock time spent while in syscall */
struct timeval wtv;
tv_sub(&wtv, syscall_exiting_tv, &tcp->etime);
/* Spent more wall clock time than spent system time? (usually yes) */
if (tv_cmp(tv, &tcp->dtime) > 0) {
static struct timeval one_tick = { -1, 0 };
if (one_tick.tv_sec == -1) {
/* Initialize it. */
struct itimerval it;
memset(&it, 0, sizeof(it));
it.it_interval.tv_usec = 1;
setitimer(ITIMER_REAL, &it, NULL);
getitimer(ITIMER_REAL, &it);
one_tick = it.it_interval;
//FIXME: this hack doesn't work (tested on linux-3.6.11): one_tick = 0.000000
//tprintf(" one_tick.tv_usec:%u\n", (unsigned)one_tick.tv_usec);
}
if (tv_nz(&tcp->dtime))
/* tv = system time spent, if it isn't 0 */
tv = &tcp->dtime;
else if (tv_cmp(tv, &one_tick) > 0) {
/* tv = smallest "sane" time interval */
if (tv_cmp(&shortest, &one_tick) < 0)
tv = &shortest;
else
tv = &one_tick;
}
tv_add(&cc->time, &cc->time, &wtv);
} else {
/* system CPU time spent while in syscall */
tv_add(&cc->time, &cc->time, &tcp->dtime);
}
if (tv_cmp(tv, &shortest) < 0)
shortest = *tv;
tv_add(&cc->time, &cc->time, count_wallclock ? &wtv : tv);
}
static int
@ -127,7 +99,6 @@ count_cmp(void *a, void *b)
}
static int (*sortfun)();
static struct timeval overhead = { -1, -1 };
void
set_sortby(const char *sortby)
@ -173,10 +144,6 @@ call_summary_pers(FILE *outf)
sorted_count = xcalloc(sizeof(sorted_count[0]), nsyscalls);
call_cum = error_cum = tv_cum.tv_sec = tv_cum.tv_usec = 0;
if (overhead.tv_sec == -1) {
tv_mul(&overhead, &shortest, 8);
tv_div(&overhead, &overhead, 10);
}
for (i = 0; i < nsyscalls; i++) {
sorted_count[i] = i;
if (counts == NULL || counts[i].calls == 0)