Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
f66a86ef
提交
f66a86ef
2月 13, 2012
创建
作者:
Nickolai Zeldovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make vma objects rcu_freed
上级
8e75c72a
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
32 行增加
和
50 行删除
+32
-50
exec.cc
exec.cc
+1
-1
hwvm.cc
hwvm.cc
+2
-1
kernlet.cc
kernlet.cc
+1
-1
proc.cc
proc.cc
+1
-1
sched.cc
sched.cc
+2
-1
sysproc.cc
sysproc.cc
+2
-1
vm.cc
vm.cc
+13
-43
vm.hh
vm.hh
+10
-1
没有找到文件。
exec.cc
浏览文件 @
f66a86ef
...
...
@@ -12,11 +12,11 @@ extern "C" {
}
#include "file.hh"
#include "vm.hh"
extern
"C"
{
#include "elf.h"
#include "cpu.h"
#include "vm.h"
#include "prof.h"
#include <stddef.h>
}
...
...
hwvm.cc
浏览文件 @
f66a86ef
...
...
@@ -10,10 +10,11 @@ extern "C" {
#include "queue.h"
#include "condvar.h"
#include "proc.h"
#include "vm.h"
#include <stddef.h>
}
#include "vm.hh"
extern
pml4e_t
kpml4
[];
static
pme_t
*
...
...
kernlet.cc
浏览文件 @
f66a86ef
...
...
@@ -5,12 +5,12 @@ extern "C" {
#include "condvar.h"
#include "cpu.h"
#include "proc.h"
#include "vm.h"
#include "fs.h"
#include "wq.h"
#include "ipc.h"
}
#include "vm.hh"
#include "file.hh"
static
void
...
...
proc.cc
浏览文件 @
f66a86ef
...
...
@@ -10,10 +10,10 @@ extern "C" {
#include "cpu.h"
#include "bits.h"
#include "kmtrace.h"
#include "vm.h"
#include "sched.h"
}
#include "vm.hh"
#include "ns.hh"
u64
...
...
sched.cc
浏览文件 @
f66a86ef
...
...
@@ -10,11 +10,12 @@ extern "C" {
#include "cpu.h"
#include "bits.h"
#include "kmtrace.h"
#include "vm.h"
#include "sched.h"
#include <stddef.h>
}
#include "vm.hh"
enum
{
sched_debug
=
0
};
struct
runq
{
...
...
sysproc.cc
浏览文件 @
f66a86ef
...
...
@@ -8,9 +8,10 @@ extern "C" {
#include "queue.h"
#include "proc.h"
#include "cpu.h"
#include "vm.h"
}
#include "vm.hh"
long
sys_fork
(
void
)
{
...
...
vm.cc
浏览文件 @
f66a86ef
...
...
@@ -10,28 +10,15 @@ extern "C" {
#include "queue.h"
#include "condvar.h"
#include "proc.h"
#include "vm.h"
}
#include "vm.hh"
#include "gc.hh"
static
void
vmap_free
(
void
*
p
);
enum
{
vm_debug
=
0
};
static
struct
vma
*
vma_alloc
(
void
)
{
struct
vma
*
e
=
(
struct
vma
*
)
kmalloc
(
sizeof
(
struct
vma
));
if
(
e
==
0
)
return
0
;
memset
(
e
,
0
,
sizeof
(
struct
vma
));
e
->
va_type
=
PRIVATE
;
snprintf
(
e
->
lockname
,
sizeof
(
e
->
lockname
),
"vma:%p"
,
e
);
initlock
(
&
e
->
lock
,
e
->
lockname
,
LOCKSTAT_VM
);
return
e
;
}
static
void
vmn_decref
(
struct
vmnode
*
n
)
{
...
...
@@ -39,27 +26,13 @@ vmn_decref(struct vmnode *n)
vmn_free
(
n
);
}
static
void
vma_free
(
void
*
p
)
vma
::~
vma
()
{
struct
vma
*
e
=
(
struct
vma
*
)
p
;
if
(
e
->
n
)
vmn_decref
(
e
->
n
);
destroylock
(
&
e
->
lock
);
kmfree
(
e
);
if
(
n
)
vmn_decref
(
n
);
destroylock
(
&
lock
);
}
class
vma_delayed
:
public
rcu_freed
{
private
:
vma
*
_e
;
public
:
vma_delayed
(
vma
*
e
)
:
rcu_freed
(
"vma_delayed"
),
_e
(
e
)
{}
virtual
~
vma_delayed
()
{
vma_free
(
_e
);
}
};
static
int
vmn_doallocpg
(
struct
vmnode
*
n
)
{
...
...
@@ -342,7 +315,7 @@ struct state {
static
int
vmap_free_vma
(
struct
clist_range
*
r
,
void
*
st
)
{
vma_free
(
r
->
value
)
;
delete
r
->
value
;
crange_del
(
r
->
cr
,
r
->
key
,
r
->
size
);
return
1
;
}
...
...
@@ -398,7 +371,7 @@ vmap_insert(struct vmap *m, struct vmnode *n, uptr va_start)
return
-
1
;
}
struct
vma
*
e
=
vma_alloc
();
struct
vma
*
e
=
new
vma
();
if
(
e
==
0
)
{
release
(
&
m
->
lock
);
return
-
1
;
...
...
@@ -417,7 +390,7 @@ vmap_copy_vma(struct clist_range *r, void *_st)
{
struct
state
*
st
=
(
struct
state
*
)
_st
;
struct
vma
*
e
=
(
struct
vma
*
)
r
->
value
;
struct
vma
*
c
=
vma_alloc
();
struct
vma
*
c
=
new
vma
();
if
(
c
==
0
)
{
return
0
;
}
...
...
@@ -482,9 +455,7 @@ vmap_remove(struct vmap *m, uptr va_start, u64 len)
return
-
1
;
}
crange_del
(
m
->
cr
,
va_start
,
len
);
vma_delayed
*
vd
=
new
vma_delayed
(
e
);
gc_delayed
(
vd
);
gc_delayed
(
e
);
release
(
&
m
->
lock
);
return
0
;
}
...
...
@@ -497,7 +468,7 @@ vmap_free(void *p)
struct
vmap
*
m
=
(
struct
vmap
*
)
p
;
for
(
u64
i
=
0
;
i
<
NELEM
(
m
->
e
);
i
++
)
{
if
(
m
->
e
[
i
])
vma_free
(
m
->
e
[
i
])
;
delete
m
->
e
[
i
]
;
}
freevm
(
m
->
pml4
);
m
->
pml4
=
0
;
...
...
@@ -543,7 +514,7 @@ vmap_insert(struct vmap *m, struct vmnode *n, uptr va_start)
for
(
u64
i
=
0
;
i
<
NELEM
(
m
->
e
);
i
++
)
{
if
(
m
->
e
[
i
])
continue
;
m
->
e
[
i
]
=
vma_alloc
();
m
->
e
[
i
]
=
new
vma
();
if
(
m
->
e
[
i
]
==
0
)
return
-
1
;
m
->
e
[
i
]
->
va_start
=
va_start
;
...
...
@@ -570,7 +541,7 @@ vmap_copy(struct vmap *m, int share)
for
(
u32
i
=
0
;
i
<
NELEM
(
m
->
e
);
i
++
)
{
if
(
m
->
e
[
i
]
==
0
)
continue
;
c
->
e
[
i
]
=
vma_alloc
();
c
->
e
[
i
]
=
new
vma
();
if
(
c
->
e
[
i
]
==
0
)
{
release
(
&
m
->
lock
);
vmap_free
(
c
);
...
...
@@ -616,8 +587,7 @@ vmap_remove(struct vmap *m, uptr va_start, u64 len)
cprintf
(
"vmap_remove: partial unmap unsupported
\n
"
);
return
-
1
;
}
vma_delayed
*
vd
=
new
vma_delayed
(
m
->
e
[
i
]);
gc_delayed
(
vd
);
gc_delayed
(
m
->
e
[
i
]);
m
->
e
[
i
]
=
0
;
}
}
...
...
vm.h
→
vm.h
h
浏览文件 @
f66a86ef
//#define TREE
#include "gc.hh"
// A mapping of a chunk of an address space to
// a specific memory object.
enum
vmatype
{
PRIVATE
,
COW
};
struct
vma
{
struct
vma
:
public
rcu_freed
{
uptr
va_start
;
// start of mapping
uptr
va_end
;
// one past the last byte
enum
vmatype
va_type
;
struct
vmnode
*
n
;
struct
spinlock
lock
;
// serialize fault/unmap
char
lockname
[
16
];
vma
()
:
rcu_freed
(
"vma"
),
va_start
(
0
),
va_end
(
0
),
va_type
(
PRIVATE
),
n
(
0
)
{
snprintf
(
lockname
,
sizeof
(
lockname
),
"vma:%p"
,
this
);
initlock
(
&
lock
,
lockname
,
LOCKSTAT_VM
);
}
virtual
~
vma
();
};
// A memory object (physical pages or inode).
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论