提交 2db6c3ef 创建 作者: Austin Clements's avatar Austin Clements

Use distributed refcounts to free VMAs

This eliminates all reports of unexpected sharing except a few cases of honest-to-goodness memory reuse.
上级 f08c7712
......@@ -147,18 +147,11 @@ private:
};
class radix_elem : public rcu_freed {
private:
std::atomic<u64> ref_;
public:
radix_elem() : rcu_freed("radix_elem"), ref_(0) {}
radix_elem() : rcu_freed("radix_elem") {}
virtual ~radix_elem() {}
void decref(u64 delta = 1) {
if ((ref_ -= delta) == 0) {
gc_delayed(this);
}
}
void incref(u64 delta = 1) { ref_ += delta; }
virtual void decref(u64 delta = 1) = 0;
virtual void incref(u64 delta = 1) = 0;
};
struct radix_node {
......
......@@ -6,6 +6,7 @@
#include "cpputil.hh"
#include "hwvm.hh"
#include "uwq.hh"
#include "distref.hh"
#define VM_CRANGE 0
#define VM_RADIX 1
......@@ -53,7 +54,7 @@ struct vma
: public range
#endif
#if VM_RADIX
: public radix_elem
: public radix_elem, public distributed_refcnt
#endif
{
const uptr vma_start; // start of mapping
......@@ -64,8 +65,27 @@ struct vma
vma(vmap *vmap, uptr start, uptr end, enum vmatype vtype, vmnode *vmn);
~vma();
NEW_DELETE_OPS(vma);
virtual void do_gc() { delete this; }
NEW_DELETE_OPS(vma)
#if VM_RADIX
void decref(u64 delta)
{
distref_dec(delta);
}
void incref(u64 delta)
{
distref_inc(delta);
}
private:
void distref_free()
{
gc_delayed(this);
}
#endif
};
class print_stream;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论