#define INVOCATIONS(n) static int _invocations = 0; \ if (_invocations++ % (n) ? 0 : (_invocations = 1)) #define PROP_GRANULARITY 10000 /* 1ms */ #define NBUCKETS (1000000/PROP_GRANULARITY) void prop_collect_stats(struct buf *new) { /* cscan_collect_stats is a prerequisite and should be called first */ } #define pprintf(x...) do { } while(0) /* #define pprintf printf */ int prop_evaluate(volatile struct buf *last, volatile struct buf *next) { quad_t wait[NRC], tot_wait = 0; int i, all_okay = 1; struct proc *p; quad_t minstart = QUAD_MAX; for (i = 0; i < NRC; i++) { if (rc[i].pending) { if (rc[i].start < minstart) minstart = rc[i].start; } } #define falling_behind(r) (r.start + thresh(r) < minstart) #define stt bpinfo(next).rc, (state == IDLE ? "idle" : state == WAIT ? "wait" : "busy") for (i = 0; i < NRC; i++) if (falling_behind(rc[i])) pprintf("behind %d ", i); pprintf("\n"); if (falling_behind(RC(next))) { /* if that can happen */ pprintf("[%d] %s: 0: self falling behind\n", stt); return 0; } for (i = 0; i < NRC; i++) if (falling_behind(rc[i])) all_okay = 0; if (all_okay) { pprintf("[%d] %s: 0: nobody falling behind\n", stt); return 0; } for (i = 0; i < NRC; i++) wait[i] = QUAD_MAX; #define pentity (*pinfo(p)) LIST_FOREACH(p, &allproc, p_list) { i = pinfo(p)->rc; if (falling_behind(rc[i])) { if (pentity.expected_thinktime < 0 || pentity.expected_thinktime > 9*MAXTIME/10) continue; pprintf("<%d> mostthinktime = %lld\n", i, pentity.expected_most_thinktime); wait[i] = qmin(wait[i], pentity.expected_most_thinktime); } } tot_wait = QUAD_MAX; for (i = 0; i < NRC; i++) { /* if (wait[i] == QUAD_MAX) wait[i] = -1; */ pprintf("wait<%d>:%lld ", i, wait[i]); tot_wait = qmin(tot_wait, wait[i]); } if (tot_wait == QUAD_MAX) tot_wait = -1; pprintf("\n"); if (tot_wait < 0) pprintf("[%d] %s: -1: hopeless\n", stt); else pprintf("[%d] %s: %lld: wait\n", stt, tot_wait); return tot_wait; }