提交 8e75c72a 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

Merge branch 'scale-amd64' of git+ssh://amsterdam.csail.mit.edu/home/am0/6.828/xv6 into scale-amd64

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