mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-12-18 22:36:16 +02:00
m1/perf/sched.c: added asserts and list poisoning
This commit is contained in:
parent
16b4a9a55b
commit
60cf6f5e9a
@ -22,6 +22,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include <fpvm/is.h>
|
#include <fpvm/is.h>
|
||||||
#include <fpvm/fpvm.h>
|
#include <fpvm/fpvm.h>
|
||||||
@ -135,6 +136,21 @@ static void get_registers(struct fpvm_fragment *fragment,
|
|||||||
* Use the naming conventions of include/linux/list.h
|
* 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)
|
static void list_init(struct list *list)
|
||||||
{
|
{
|
||||||
list->next = list->prev = list;
|
list->next = list->prev = list;
|
||||||
@ -143,8 +159,10 @@ static void list_init(struct list *list)
|
|||||||
|
|
||||||
static void list_del(struct list *item)
|
static void list_del(struct list *item)
|
||||||
{
|
{
|
||||||
|
assert(item->next != item);
|
||||||
item->prev->next = item->next;
|
item->prev->next = item->next;
|
||||||
item->next->prev = item->prev;
|
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;
|
b->prev->next = a;
|
||||||
a->prev = b->prev;
|
a->prev = b->prev;
|
||||||
}
|
}
|
||||||
list_init(b);
|
list_poison(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -249,12 +267,14 @@ static void put_reg(int vm_reg)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
vm_idx = reg2idx(vm_reg);
|
vm_idx = reg2idx(vm_reg);
|
||||||
|
assert(sc->regs[vm_idx].refs);
|
||||||
if (--sc->regs[vm_idx].refs)
|
if (--sc->regs[vm_idx].refs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Dprintf(" free reg %d\n", regs[vm_idx].pfpu_reg);
|
Dprintf(" free reg %d\n", regs[vm_idx].pfpu_reg);
|
||||||
|
|
||||||
#ifdef REG_STATS
|
#ifdef REG_STATS
|
||||||
|
assert(sc->curr_regs);
|
||||||
sc->curr_regs--;
|
sc->curr_regs--;
|
||||||
#endif
|
#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",
|
Dprintf("insn %lu: reg %d setter %lu unresolved %d\n",
|
||||||
insn-sc->insns, reg_num, reg->setter-sc->insns,
|
insn-sc->insns, reg_num, reg->setter-sc->insns,
|
||||||
insn->unresolved);
|
insn->unresolved);
|
||||||
} else {
|
|
||||||
list_init(&ref->more);
|
|
||||||
}
|
}
|
||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
@ -428,6 +446,7 @@ static void issue(struct insn *insn, int cycle, unsigned *code)
|
|||||||
foreach (ref, &insn->dependants) {
|
foreach (ref, &insn->dependants) {
|
||||||
if (ref->insn->earliest <= end)
|
if (ref->insn->earliest <= end)
|
||||||
ref->insn->earliest = end+1;
|
ref->insn->earliest = end+1;
|
||||||
|
assert(ref->insn->unresolved);
|
||||||
if (!--ref->insn->unresolved) {
|
if (!--ref->insn->unresolved) {
|
||||||
Dprintf(" unlocked %lu -> %u\n", ref->insn-insns,
|
Dprintf(" unlocked %lu -> %u\n", ref->insn-insns,
|
||||||
ref->insn->earliest);
|
ref->insn->earliest);
|
||||||
@ -509,7 +528,7 @@ static int schedule(unsigned int *code)
|
|||||||
end = PFPU_PROGSIZE;
|
end = PFPU_PROGSIZE;
|
||||||
while (i != end) {
|
while (i != end) {
|
||||||
if (FIELD(code[i]).dest)
|
if (FIELD(code[i]).dest)
|
||||||
last = i+1; /* @@@ ? */
|
last = i+1;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return last;
|
return last;
|
||||||
|
Loading…
Reference in New Issue
Block a user