提交 c020c6f1 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

lockstat build fix

上级 d164ddab
......@@ -305,10 +305,12 @@ verifyfree(char *ptr, u64 nbytes)
// Search for pointers in the ptr region
u64 x = *(uptr *)p;
if (KBASE < x && x < KBASE+(128ull<<30)) {
#if 0 /* maybe once this code is C++ */
struct klockstat *kls = (struct klockstat *) x;
if (kls->magic == LOCKSTAT_MAGIC)
panic("LOCKSTAT_MAGIC %p(%lu):%p->%p",
ptr, nbytes, p, kls);
#endif
}
}
#endif
......
......@@ -2,6 +2,9 @@
#define LOCKSTAT_MAGIC 0xb4cd79c1b2e46f40ull
#if __cplusplus
#include "gc.hh"
struct cpulockstat {
u64 acquires;
u64 contends;
......@@ -18,11 +21,17 @@ struct lockstat {
struct cpulockstat cpu[NCPU] __mpalign__;
};
struct klockstat {
struct klockstat : public rcu_freed {
u64 magic;
LIST_ENTRY(klockstat) link;
struct lockstat s;
klockstat() : rcu_freed("klockstat") {}
virtual ~klockstat() {}
};
#else
struct klockstat;
#endif
#define LOCKSTAT_START 1
#define LOCKSTAT_STOP 2
......
......@@ -114,7 +114,7 @@ static struct spinlock lockstat_lock = {
void
lockstat_init(struct spinlock *lk)
{
lk->stat = (struct klockstat*) kmalloc(sizeof(*lk->stat));
lk->stat = new klockstat();
if (lk->stat == NULL)
return;
......@@ -145,8 +145,8 @@ lockstat_clear(void)
if (stat->magic == 0) {
LIST_REMOVE(stat, link);
// So verifyfree doesn't follow le_next
stat->link.le_next = (struct klockstat*) NULL;
gc_delayed(stat, kmfree);
stat->link.le_next = 0;
gc_delayed(stat);
} else {
memset(&stat->s.cpu, 0, sizeof(stat->s.cpu));
}
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论