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

x

上级 6d8e14b0
...@@ -27,9 +27,8 @@ filealloc(void) ...@@ -27,9 +27,8 @@ filealloc(void)
struct file* struct file*
filedup(struct file *f) filedup(struct file *f)
{ {
if(f->ref < 1) if (__sync_fetch_and_add(&f->ref, 1) < 1)
panic("filedup"); panic("filedup");
__sync_fetch_and_add(&f->ref, 1);
return f; return f;
} }
......
...@@ -270,8 +270,8 @@ kmalloc(uint nbytes) ...@@ -270,8 +270,8 @@ kmalloc(uint nbytes)
mtrace_label_register(mtrace_label_heap, mtrace_label_register(mtrace_label_heap,
r, r,
nbytes, nbytes,
"kmalloc", "kmalloc'ed",
sizeof("kmalloc"), sizeof("kmalloc'ed"),
RET_EIP()); RET_EIP());
return r; return r;
} }
...@@ -126,6 +126,7 @@ ns_remove(struct ns *ns, int key, void *v) ...@@ -126,6 +126,7 @@ ns_remove(struct ns *ns, int key, void *v)
break; break;
if (e->key == key && (e->val == v || v == 0)) { if (e->key == key && (e->val == v || v == 0)) {
// XXX annotate as locks for mtrace
if (!__sync_bool_compare_and_swap(&e->next_lock, 0, 1)) if (!__sync_bool_compare_and_swap(&e->next_lock, 0, 1))
goto retry; goto retry;
if (!__sync_bool_compare_and_swap(pelock, 0, 1)) { if (!__sync_bool_compare_and_swap(pelock, 0, 1)) {
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论