Permalink
Browse files

kernel - Add vmmeter counter for token collisions

* Add vmmeter counter for token collisions.

* Add token collisions to systat -pv's display.
  • Loading branch information...
1 parent de4d4cb commit 574339e6ad6d65d2b0324c54ef8db4373c7c2267 Matthew Dillon committed Sep 21, 2012
Showing with 6 additions and 72 deletions.
  1. +2 −69 sys/kern/lwkt_thread.c
  2. +1 −1 sys/sys/vmmeter.h
  3. +3 −2 usr.bin/systat/vmmeter.c
View
@@ -90,7 +90,6 @@ static __int64_t switch_count = 0;
static __int64_t preempt_hit = 0;
static __int64_t preempt_miss = 0;
static __int64_t preempt_weird = 0;
-static __int64_t token_contention_count[TDPRI_MAX+1] __debugvar;
static int lwkt_use_spin_port;
static struct objcache *thread_cache;
@@ -122,72 +121,6 @@ SYSCTL_QUAD(_lwkt, OID_AUTO, preempt_miss, CTLFLAG_RW, &preempt_miss, 0,
"Failed preemption events");
SYSCTL_QUAD(_lwkt, OID_AUTO, preempt_weird, CTLFLAG_RW, &preempt_weird, 0,
"Number of preempted threads.");
-#ifdef INVARIANTS
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_00, CTLFLAG_RW,
- &token_contention_count[0], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_01, CTLFLAG_RW,
- &token_contention_count[1], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_02, CTLFLAG_RW,
- &token_contention_count[2], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_03, CTLFLAG_RW,
- &token_contention_count[3], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_04, CTLFLAG_RW,
- &token_contention_count[4], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_05, CTLFLAG_RW,
- &token_contention_count[5], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_06, CTLFLAG_RW,
- &token_contention_count[6], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_07, CTLFLAG_RW,
- &token_contention_count[7], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_08, CTLFLAG_RW,
- &token_contention_count[8], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_09, CTLFLAG_RW,
- &token_contention_count[9], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_10, CTLFLAG_RW,
- &token_contention_count[10], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_11, CTLFLAG_RW,
- &token_contention_count[11], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_12, CTLFLAG_RW,
- &token_contention_count[12], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_13, CTLFLAG_RW,
- &token_contention_count[13], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_14, CTLFLAG_RW,
- &token_contention_count[14], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_15, CTLFLAG_RW,
- &token_contention_count[15], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_16, CTLFLAG_RW,
- &token_contention_count[16], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_17, CTLFLAG_RW,
- &token_contention_count[17], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_18, CTLFLAG_RW,
- &token_contention_count[18], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_19, CTLFLAG_RW,
- &token_contention_count[19], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_20, CTLFLAG_RW,
- &token_contention_count[20], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_21, CTLFLAG_RW,
- &token_contention_count[21], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_22, CTLFLAG_RW,
- &token_contention_count[22], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_23, CTLFLAG_RW,
- &token_contention_count[23], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_24, CTLFLAG_RW,
- &token_contention_count[24], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_25, CTLFLAG_RW,
- &token_contention_count[25], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_26, CTLFLAG_RW,
- &token_contention_count[26], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_27, CTLFLAG_RW,
- &token_contention_count[27], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_28, CTLFLAG_RW,
- &token_contention_count[28], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_29, CTLFLAG_RW,
- &token_contention_count[29], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_30, CTLFLAG_RW,
- &token_contention_count[30], 0, "spinning due to token contention");
-SYSCTL_QUAD(_lwkt, OID_AUTO, token_contention_count_31, CTLFLAG_RW,
- &token_contention_count[31], 0, "spinning due to token contention");
-#endif
static int fairq_enable = 0;
SYSCTL_INT(_lwkt, OID_AUTO, fairq_enable, CTLFLAG_RW,
&fairq_enable, 0, "Turn on fairq priority accumulators");
@@ -765,9 +698,9 @@ lwkt_switch(void)
* the next tick whenever the current head is not the current thread.
*/
#ifdef INVARIANTS
- ++token_contention_count[ntd->td_pri];
++ntd->td_contended;
#endif
+ ++gd->gd_cnt.v_token_colls;
if (fairq_bypass > 0)
goto skip;
@@ -793,9 +726,9 @@ lwkt_switch(void)
goto havethread;
}
#ifdef INVARIANTS
- ++token_contention_count[ntd->td_pri];
++ntd->td_contended;
#endif
+ ++gd->gd_cnt.v_token_colls;
}
skip:
View
@@ -102,7 +102,7 @@ struct vmmeter {
u_int v_waitsys; /* calls to waitsys() */
u_int v_smpinvltlb; /* nasty global invltlbs */
u_int v_ppwakeups; /* wakeups on processes stalled on VM */
- u_int v_reserved1;
+ u_int v_token_colls;
u_int v_reserved2;
u_int v_reserved3;
u_int v_reserved4;
View
@@ -84,8 +84,6 @@ showvmm(void)
DRAW_ROW(n, CPU_START + i, 8, "%*u", D(i, v_ipi));
DRAW_ROW(n, CPU_START + i, 8, "%*u", D(i, v_intr));
-#undef D
-
#define CPUD(dif, idx, field) \
do { \
dif.cp_##field = vmm_cptime_cur[idx].cp_##field - \
@@ -110,7 +108,9 @@ do { \
DRAW_ROW(n, CPU_START + i, 7, "%*.1f", CPUV(d, sys));
DRAW_ROW(n, CPU_START + i, 7, "%*.1f", CPUV(d, intr));
DRAW_ROW(n, CPU_START + i, 7, "%*.1f", CPUV(d, idle));
+ DRAW_ROW(n, CPU_START + i, 8, "%*u", D(i, v_token_colls));
+#undef D
#undef CPUV
#undef CPUD
#define CPUC(idx, field) vmm_cptime_cur[idx].cp_##field
@@ -155,6 +155,7 @@ labelvmm(void)
DRAW_ROW(n, CPU_START - 1, 7, "%*s", "sys%");
DRAW_ROW(n, CPU_START - 1, 7, "%*s", "intr%");
DRAW_ROW(n, CPU_START - 1, 7, "%*s", "idle%");
+ DRAW_ROW(n, CPU_START - 1, 8, "%*s", "tokcol");
for (i = 0; i < vmm_ncpus; ++i)
mvprintw(CPU_START + i, X_START, "cpu%d", i);

0 comments on commit 574339e

Please sign in to comment.