From 60cf6f5e9afa2db2ad98370ddcc94967d9e8362c Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 18 Sep 2011 19:11:17 -0300 Subject: [PATCH] m1/perf/sched.c: added asserts and list poisoning --- m1/perf/sched.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/m1/perf/sched.c b/m1/perf/sched.c index 9e3fb76..d00aa3f 100644 --- a/m1/perf/sched.c +++ b/m1/perf/sched.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -135,6 +136,21 @@ static void get_registers(struct fpvm_fragment *fragment, * Use the naming conventions of include/linux/list.h */ + +#ifdef DEBUG + +static void list_poison(struct list *list) +{ + list->next = list->prev = NULL; +} + +#else /* DEBUG */ + +#define list_poison(list) + +#endif /* !DEBUG */ + + static void list_init(struct list *list) { list->next = list->prev = list; @@ -143,8 +159,10 @@ static void list_init(struct list *list) static void list_del(struct list *item) { + assert(item->next != item); item->prev->next = item->next; item->next->prev = item->prev; + list_poison(item); } @@ -186,7 +204,7 @@ static void list_concat(struct list *a, struct list *b) b->prev->next = a; a->prev = b->prev; } - list_init(b); + list_poison(b); } @@ -249,12 +267,14 @@ static void put_reg(int vm_reg) return; vm_idx = reg2idx(vm_reg); + assert(sc->regs[vm_idx].refs); if (--sc->regs[vm_idx].refs) return; Dprintf(" free reg %d\n", regs[vm_idx].pfpu_reg); #ifdef REG_STATS + assert(sc->curr_regs); sc->curr_regs--; #endif @@ -335,8 +355,6 @@ static struct vm_reg *add_data_ref(struct insn *insn, struct data_ref *ref, Dprintf("insn %lu: reg %d setter %lu unresolved %d\n", insn-sc->insns, reg_num, reg->setter-sc->insns, insn->unresolved); - } else { - list_init(&ref->more); } return reg; } @@ -428,6 +446,7 @@ static void issue(struct insn *insn, int cycle, unsigned *code) foreach (ref, &insn->dependants) { if (ref->insn->earliest <= end) ref->insn->earliest = end+1; + assert(ref->insn->unresolved); if (!--ref->insn->unresolved) { Dprintf(" unlocked %lu -> %u\n", ref->insn-insns, ref->insn->earliest); @@ -509,7 +528,7 @@ static int schedule(unsigned int *code) end = PFPU_PROGSIZE; while (i != end) { if (FIELD(code[i]).dest) - last = i+1; /* @@@ ? */ + last = i+1; i++; } return last;