Exemplo n.º 1
0
void
showsyscall(void)
{
    int i, ii, l, c;
    uint64_t v;
    static int failcnt = 0;
    static int relabel = 0;
    static char pigs[] = "pigs";
    uint64_t itime;

    if (relabel) {
        labelsyscall();
        relabel = 0;
    }

    cpuswap();
    if (display_mode == TIME) {
        etime = cur.cp_etime;
        /* < 5 ticks - ignore this trash */
        if ((etime * hertz) < 1.0) {
            if (failcnt++ <= MAXFAIL)
                return;
            clear();
            mvprintw(2, 10, "The alternate system clock has died!");
            mvprintw(3, 10, "Reverting to ``pigs'' display.");
            move(CMDLINE, 0);
            refresh();
            failcnt = 0;
            sleep(5);
            command(pigs);
            return;
        }
    } else
        etime = 1.0;
    itime = etime * 100;

    failcnt = 0;

    show_vmstat_top(&s.Total, &s.uvmexp, &s1.uvmexp);

    /* Sort out the values we are going to display */
    for (i = 0; i < (int)__arraycount(s.counts); i++) {
        switch (show) {
        default:
        case SHOW_COUNTS:
            v = s.counts[i] - s1.counts[i];
            break;
        case SHOW_TIMES:
            v = s.times[i] - s1.times[i];
            break;
        case SHOW_COUNTS | SHOW_TIMES:    /* time/count */
            v = s.counts[i] - s1.counts[i];
            v = v ? (s.times[i] - s1.times[i]) / v : 0;
        }

        if (display_mode == TIME)
            v = (v * 100 + itime/2) / itime;

        val[i] = v;

        /*
         * We use an 'infinite response filter' in a vague
         * attempt to stop the data leaping around too much.
         * I suspect there are other/better methods in use.
         */
        if (irf_first) {
            irf[i] = v;
            irf_first = 0;
        } else {
            irf[i] = irf[i] * 7 / 8 + v;
        }
    }

    if (sort_order == COUNTS) {
        /* mergesort() doesn't swap equal values about... */
        mergesort(syscall_sort, __arraycount(syscall_sort),
                  sizeof syscall_sort[0], compare_irf);
    }

    l = SYSCALLROW;
    c = 0;
    move(l, c);
#define FMT "compile kernel with \"options SYSCALL_%s\" to get syscall %s"
    if (counts_mib_len == 0) {
        mvprintw(l, c, FMT, "STATS", "counts");
        l++;
    }
    if (times_mib_len == 0) {
        mvprintw(l, c, FMT, "TIMES", "times");
        l++;
    }
    for (ii = 0; ii < (int)__arraycount(s.counts); ii++) {
        i = syscall_sort[ii];
        if (val[i] == 0 && irf[i] == 0)
            continue;

        if (i < (int)__arraycount(syscallnames)) {
            const char *name = syscallnames[i];
            while (name[0] == '_')
                name++;
            if (name[0] == 'c' && !strcmp(name + 1, "ompat_"))
                name += 7;
            mvprintw(l, c, "%17.17s", name);
        } else
            mvprintw(l, c, "syscall #%d       ", i);

        putuint64(val[i], l, c + 18, 8);
        c += 27;
        if (c + 26 > COLS) {
            c = 0;
            l++;
            if (l >= LINES - 1)
                break;
        }
    }
    if (display_mode == TIME) {
        memcpy(s1.counts, s.counts, sizeof s1.counts);
        memcpy(s1.times, s.times, sizeof s1.times);
    }
    while (l < LINES - 1) {
        clrtoeol();
        move(++l, 0);
    }
}
Exemplo n.º 2
0
void
showkre(void)
{
	float f1, f2;
	int psiz;
	u_int64_t inttotal, intcnt;
	int i, l, c;
	static int failcnt = 0, first_run = 0;

	if (state == TIME) {
		if (!first_run) {
			first_run = 1;
			return;
		}
	}
	etime = 0;
	for (i = 0; i < CPUSTATES; i++) {
		X(time);
		etime += s.time[i];
	}
	if (etime < 5.0) {	/* < 5 ticks - ignore this trash */
		if (failcnt++ >= MAXFAIL) {
			error("The alternate system clock has died!");
			failcnt = 0;
		}
		return;
	}
	failcnt = 0;
	etime /= hertz;
	inttotal = 0;
	for (i = 0; i < nintr; i++) {
		if (s.intrcnt[i] == 0)
			continue;
		if (intrloc[i] == 0) {
			if (nextintsrow == LINES)
				continue;
			intrloc[i] = nextintsrow++;
			mvprintw(intrloc[i], INTSCOL + 9, "%-8.8s",
			    intrname[i]);
		}
		t = intcnt = s.intrcnt[i];
		s.intrcnt[i] -= s1.intrcnt[i];
		intcnt = (u_int64_t)((float)s.intrcnt[i]/etime + 0.5);
		inttotal += intcnt;
		putuint64(intcnt, intrloc[i], INTSCOL, 8);
	}
	putuint64(inttotal, INTSROW + 1, INTSCOL, 8);
	Z(ncs_goodhits); Z(ncs_badhits); Z(ncs_miss);
	Z(ncs_long); Z(ncs_pass2); Z(ncs_2passes);
	s.nchcount = nchtotal.ncs_goodhits + nchtotal.ncs_badhits +
	    nchtotal.ncs_miss + nchtotal.ncs_long;

	putint(sum.ifc_ip, LINES - 3, INTSCOL, 8);
	putint(sum.ifc_op, LINES - 2, INTSCOL, 8);

	psiz = 0;
	f2 = 0.0;

	for (c = 0; c < CPUSTATES; c++) {
		i = cpuorder[c];
		f1 = cputime(i);
		f2 += f1;
		l = (int) ((f2 + 1.0) / 2.0) - psiz;
		putfloat(f1, GRAPHROW, GRAPHCOL + 1 + (10 * c), 5, 1, 0);
		move(GRAPHROW + 2, psiz);
		psiz += l;
		while (l-- > 0)
			addch(cpuchar[c]);
	}

#define pgtokb(pg)	((pg) * (s.uvmexp.pagesize / 1024))

	putint(pgtokb(s.uvmexp.active), MEMROW + 2, MEMCOL + 7, 8);
	putint(pgtokb(s.uvmexp.active + s.uvmexp.swpginuse),    /* XXX */
	    MEMROW + 2, MEMCOL + 17, 8);
	putint(pgtokb(s.uvmexp.npages - s.uvmexp.free), MEMROW + 3, MEMCOL + 7, 8);
	putint(pgtokb(s.uvmexp.npages - s.uvmexp.free + s.uvmexp.swpginuse),
	    MEMROW + 3, MEMCOL + 17, 8);
	putint(pgtokb(s.uvmexp.free), MEMROW + 2, MEMCOL + 26, 8);
	putint(pgtokb(s.uvmexp.free + s.uvmexp.swpages - s.uvmexp.swpginuse),
	    MEMROW + 3, MEMCOL + 26, 8);
	putint(total.t_rq - 1, PROCSROW + 1, PROCSCOL + 3, 3);

	putint(total.t_dw, PROCSROW + 1, PROCSCOL + 6, 3);
	putint(total.t_sl, PROCSROW + 1, PROCSCOL + 9, 3);
	putint(total.t_sw, PROCSROW + 1, PROCSCOL + 12, 3);
	PUTRATE(uvmexp.forks, VMSTATROW + 0, VMSTATCOL + 3, 6);
	PUTRATE(uvmexp.forks_ppwait, VMSTATROW + 1, VMSTATCOL + 3, 6);
	PUTRATE(uvmexp.forks_sharevm, VMSTATROW + 2, VMSTATCOL + 3, 6);
	PUTRATE(uvmexp.fltpgwait, VMSTATROW + 3, VMSTATCOL + 4, 5);
	PUTRATE(uvmexp.fltrelck, VMSTATROW + 4, VMSTATCOL + 3, 6);
	PUTRATE(uvmexp.fltrelckok, VMSTATROW + 5, VMSTATCOL + 3, 6);
	PUTRATE(uvmexp.fltnoram, VMSTATROW + 6, VMSTATCOL + 3, 6);
	PUTRATE(uvmexp.fltamcopy, VMSTATROW + 7, VMSTATCOL + 3, 6);
	PUTRATE(uvmexp.flt_prcopy, VMSTATROW + 8, VMSTATCOL + 3, 6);
	PUTRATE(uvmexp.flt_przero, VMSTATROW + 9, VMSTATCOL + 3, 6);
	PUTRATE(uvmexp.flt_acow, VMSTATROW + 10, VMSTATCOL, 9);
	putint(s.uvmexp.freemin, VMSTATROW + 11, VMSTATCOL, 9);
	putint(s.uvmexp.freetarg, VMSTATROW + 12, VMSTATCOL, 9);
	putint(s.uvmexp.inactarg, VMSTATROW + 13, VMSTATCOL, 9);
	putint(s.uvmexp.wired, VMSTATROW + 14, VMSTATCOL, 9);
	PUTRATE(uvmexp.pdfreed, VMSTATROW + 15, VMSTATCOL, 9);
	if (LINES - 1 > VMSTATROW + 16)
		PUTRATE(uvmexp.pdscans, VMSTATROW + 16, VMSTATCOL, 9);
	if (LINES - 1 > VMSTATROW + 17)
		PUTRATE(uvmexp.zeropages, VMSTATROW + 17, VMSTATCOL, 9);
	if (LINES - 1 > VMSTATROW + 18)
		putint(s.uvmexp.kmapent, VMSTATROW + 18, VMSTATCOL, 9);

	PUTRATE(uvmexp.pageins, PAGEROW + 2, PAGECOL + 5, 5);
	PUTRATE(uvmexp.pdpageouts, PAGEROW + 2, PAGECOL + 10, 5);
	PUTRATE(uvmexp.pgswapin, PAGEROW + 3, PAGECOL + 5, 5);
	PUTRATE(uvmexp.pgswapout, PAGEROW + 3, PAGECOL + 10, 5);

	PUTRATE(uvmexp.swtch, GENSTATROW + 1, GENSTATCOL, 6);
	PUTRATE(uvmexp.traps, GENSTATROW + 1, GENSTATCOL + 6, 6);
	PUTRATE(uvmexp.syscalls, GENSTATROW + 1, GENSTATCOL + 12, 6);
	PUTRATE(uvmexp.intrs, GENSTATROW + 1, GENSTATCOL + 18, 6);
	PUTRATE(uvmexp.softs, GENSTATROW + 1, GENSTATCOL + 24, 6);
	PUTRATE(uvmexp.faults, GENSTATROW + 1, GENSTATCOL + 30, 5);
	mvprintw(DISKROW, DISKCOL + 5, "                              ");
	for (i = 0, c = 0; i < cur.dk_ndrive && c < DRIVESPACE; i++)
		if (cur.dk_select[i] && (c + strlen(dr_name[i])) < DRIVESPACE) {
			l = MAX(5, strlen(dr_name[i]));
			mvprintw(DISKROW, DISKCOL + 5 + c,
			    " %*s", l, dr_name[i]);
			c += 1 + l;
			dinfo(i, c);
		}
	/* and pad the DRIVESPACE */
	l = DRIVESPACE - c;
	for (i = 0; i < 5; i++)
		mvprintw(DISKROW + i, DISKCOL + 5 + c, "%*s", l, "");

	putint(s.nchcount, NAMEIROW + 2, NAMEICOL, 9);
	putint(nchtotal.ncs_goodhits, NAMEIROW + 2, NAMEICOL + 10, 8);
#define nz(x)	((x) ? (x) : 1)
	putfloat(nchtotal.ncs_goodhits * 100.0 / nz(s.nchcount),
	    NAMEIROW + 2, NAMEICOL + 19, 4, 0, 1);
	putint(nchtotal.ncs_pass2, NAMEIROW + 2, NAMEICOL + 24, 7);
	putfloat(nchtotal.ncs_pass2 * 100.0 / nz(s.nchcount),
	    NAMEIROW + 2, NAMEICOL + 33, 4, 0, 1);
	putint(nchtotal.ncs_miss + nchtotal.ncs_long - nchtotal.ncs_pass2,
	   NAMEIROW + 2, NAMEICOL + 38, 7);
	putfloat((nchtotal.ncs_miss + nchtotal.ncs_long - nchtotal.ncs_pass2) *
	    100.0 / nz(s.nchcount), NAMEIROW + 2, NAMEICOL + 45, 4, 0, 1);
#undef nz

}