diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-05-14 12:31:22 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-05-14 12:31:22 +0000 |
commit | ca1cf5ebdbe3ffefe771df4b2ea17c999916b5b9 (patch) | |
tree | 67a8227617199c9082d4ed0b1734388cb7d0afa4 /usr.bin/systat | |
parent | 832b912d736e085430a113151047cf4410f2bb7b (diff) |
Stopping counting and reporting CPU time spent spinning on a lock as
system time.
Introduce a new CP_SPIN "scheduler state" and modify userland tools
to display the % of timer a CPU spents spinning.
Based on a diff from jmatthew@, ok pirofti@, bluhm@, visa@, deraadt@
Diffstat (limited to 'usr.bin/systat')
-rw-r--r-- | usr.bin/systat/cpu.c | 29 | ||||
-rw-r--r-- | usr.bin/systat/vmstat.c | 10 |
2 files changed, 21 insertions, 18 deletions
diff --git a/usr.bin/systat/cpu.c b/usr.bin/systat/cpu.c index 90cdeeed6c2..ac7e2ba000e 100644 --- a/usr.bin/systat/cpu.c +++ b/usr.bin/systat/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.5 2016/01/02 20:02:40 benno Exp $ */ +/* $OpenBSD: cpu.c,v 1.6 2018/05/14 12:31:21 mpi Exp $ */ /* * Copyright (c) 2013 Reyk Floeter <reyk@openbsd.org> @@ -68,21 +68,23 @@ field_def fields_cpu[] = { { "User", 10, 20, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0 }, { "Nice", 10, 20, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0 }, { "System", 10, 20, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0 }, + { "Spin", 10, 20, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0 }, { "Interrupt", 10, 20, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0 }, { "Idle", 10, 20, 1, FLD_ALIGN_RIGHT, -1, 0, 0, 0 }, }; #define FLD_CPU_CPU FIELD_ADDR(fields_cpu, 0) -#define FLD_CPU_INT FIELD_ADDR(fields_cpu, 1) -#define FLD_CPU_SYS FIELD_ADDR(fields_cpu, 2) -#define FLD_CPU_USR FIELD_ADDR(fields_cpu, 3) -#define FLD_CPU_NIC FIELD_ADDR(fields_cpu, 4) -#define FLD_CPU_IDLE FIELD_ADDR(fields_cpu, 5) +#define FLD_CPU_USR FIELD_ADDR(fields_cpu, 1) +#define FLD_CPU_NIC FIELD_ADDR(fields_cpu, 2) +#define FLD_CPU_SYS FIELD_ADDR(fields_cpu, 3) +#define FLD_CPU_SPIN FIELD_ADDR(fields_cpu, 4) +#define FLD_CPU_INT FIELD_ADDR(fields_cpu, 5) +#define FLD_CPU_IDLE FIELD_ADDR(fields_cpu, 6) /* Define views */ field_def *view_cpu_0[] = { - FLD_CPU_CPU, - FLD_CPU_INT, FLD_CPU_SYS, FLD_CPU_USR, FLD_CPU_NIC, FLD_CPU_IDLE, NULL + FLD_CPU_CPU, FLD_CPU_USR, FLD_CPU_NIC, FLD_CPU_SYS, FLD_CPU_SPIN, + FLD_CPU_INT, FLD_CPU_IDLE, NULL }; /* Define view managers */ @@ -232,11 +234,12 @@ initcpu(void) do { \ if (cur >= dispstart && cur < end) { \ print_fld_size(FLD_CPU_CPU, (v)); \ - print_fld_percentage(FLD_CPU_INT, (cs[0])); \ - print_fld_percentage(FLD_CPU_SYS, (cs[1])); \ - print_fld_percentage(FLD_CPU_USR, (cs[2])); \ - print_fld_percentage(FLD_CPU_NIC, (cs[3])); \ - print_fld_percentage(FLD_CPU_IDLE, (cs[4])); \ + print_fld_percentage(FLD_CPU_USR, (cs[CP_USER]));\ + print_fld_percentage(FLD_CPU_NIC, (cs[CP_NICE]));\ + print_fld_percentage(FLD_CPU_SYS, (cs[CP_SYS]));\ + print_fld_percentage(FLD_CPU_SPIN, (cs[CP_SPIN]));\ + print_fld_percentage(FLD_CPU_INT, (cs[CP_INTR]));\ + print_fld_percentage(FLD_CPU_IDLE, (cs[CP_IDLE])); \ end_line(); \ } \ if (++cur >= end) \ diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c index a515b73f958..13feb293b6e 100644 --- a/usr.bin/systat/vmstat.c +++ b/usr.bin/systat/vmstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmstat.c,v 1.83 2018/05/03 07:49:18 otto Exp $ */ +/* $OpenBSD: vmstat.c,v 1.84 2018/05/14 12:31:21 mpi Exp $ */ /* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */ /*- @@ -268,7 +268,7 @@ labelkre(void) mvprintw(GENSTATROW, GENSTATCOL, " Csw Trp Sys Int Sof Flt"); mvprintw(GRAPHROW, GRAPHCOL, - " . %%Int . %%Sys . %%Usr . %%Nic . %%Idle"); + " . %%Int . %%Sys . %%Usr . %%Spn . %%Idle"); mvprintw(PROCSROW, PROCSCOL, "Proc:r d s w"); mvprintw(GRAPHROW + 1, GRAPHCOL, "| | | | | | | | | | |"); @@ -306,8 +306,8 @@ labelkre(void) } while (0) #define MAXFAIL 5 -static char cpuchar[CPUSTATES] = { '|', '=', '>', '-', ' ' }; -static char cpuorder[CPUSTATES] = { CP_INTR, CP_SYS, CP_USER, CP_NICE, CP_IDLE }; +static char cpuchar[] = { '|', '=', '>', '-', ' ' }; +static char cpuorder[] = { CP_INTR, CP_SYS, CP_USER, CP_SPIN, CP_IDLE }; void showkre(void) @@ -367,7 +367,7 @@ showkre(void) psiz = 0; f2 = 0.0; - for (c = 0; c < CPUSTATES; c++) { + for (c = 0; c < nitems(cpuorder); c++) { i = cpuorder[c]; f1 = cputime(i); f2 += f1; |