Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
b76122e4
提交
b76122e4
4月 24, 2012
创建
作者:
Austin Clements
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vm: Support partial mmap/munmap
上级
12e02238
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
34 行增加
和
9 行删除
+34
-9
vm.cc
kernel/vm.cc
+34
-9
没有找到文件。
kernel/vm.cc
浏览文件 @
b76122e4
...
@@ -415,11 +415,9 @@ again:
...
@@ -415,11 +415,9 @@ again:
// new scope to release the search lock before tlbflush
// new scope to release the search lock before tlbflush
u64
len
=
n
->
npages
*
PGSIZE
;
u64
len
=
n
->
npages
*
PGSIZE
;
auto
span
=
vmas
.
search_lock
(
vma_start
,
len
);
auto
span
=
vmas
.
search_lock
(
vma_start
,
len
);
#if VM_CRANGE
// XXX handle overlaps, set replaced=true
for
(
auto
r
:
span
)
{
for
(
auto
r
:
span
)
{
#if VM_RADIX
if
(
!
r
)
continue
;
#endif
if
(
!
fixed
)
if
(
!
fixed
)
goto
again
;
goto
again
;
...
@@ -428,8 +426,27 @@ again:
...
@@ -428,8 +426,27 @@ again:
rvma
,
rvma
->
vma_start
,
rvma
->
vma_end
);
rvma
,
rvma
->
vma_start
,
rvma
->
vma_end
);
return
-
1
;
return
-
1
;
}
}
#endif
// XXX handle overlaps, set replaced=true
#if VM_RADIX
// XXX(austin) span.replace also has to do this scan. It would be
// nice if we could do just one scan.
for
(
auto
r
:
span
)
{
if
(
!
r
)
continue
;
if
(
!
fixed
)
goto
again
;
else
{
// XXX(austin) I don't think anything prevents a page fault
// from reading the old VMA now and installing the new page
// for the old VMA after the updatepages. Certainly not
// PTE_LOCK, since we don't take that here. Why not just use
// the lock in the radix tree? (We can't do that with crange,
// though, since it can only lock complete ranges.)
replaced
=
true
;
break
;
}
}
#endif
e
=
new
vma
(
this
,
vma_start
,
vma_start
+
len
,
PRIVATE
,
n
);
e
=
new
vma
(
this
,
vma_start
,
vma_start
+
len
,
PRIVATE
,
n
);
if
(
e
==
0
)
{
if
(
e
==
0
)
{
...
@@ -450,6 +467,11 @@ again:
...
@@ -450,6 +467,11 @@ again:
updatepages
(
pml4
,
e
->
vma_start
,
e
->
vma_end
,
[
&
needtlb
](
atomic
<
pme_t
>
*
p
)
{
updatepages
(
pml4
,
e
->
vma_start
,
e
->
vma_end
,
[
&
needtlb
](
atomic
<
pme_t
>
*
p
)
{
for
(;;)
{
for
(;;)
{
pme_t
v
=
p
->
load
();
pme_t
v
=
p
->
load
();
// XXX(austin) Huh? Why is it okay to skip it if it's
// locked? The page fault could be faulting in a page from
// the old VMA, in which case we need to shoot it down
// (though if it's already faulting a page from the new VMA,
// we need to *not* shoot it down).
if
(
v
&
PTE_LOCK
)
if
(
v
&
PTE_LOCK
)
continue
;
continue
;
if
(
!
(
v
&
PTE_P
))
if
(
!
(
v
&
PTE_P
))
...
@@ -476,9 +498,11 @@ vmap::remove(uptr vma_start, uptr len)
...
@@ -476,9 +498,11 @@ vmap::remove(uptr vma_start, uptr len)
{
{
{
{
// new scope to release the search lock before tlbflush
// new scope to release the search lock before tlbflush
uptr
vma_end
=
vma_start
+
len
;
auto
span
=
vmas
.
search_lock
(
vma_start
,
len
);
auto
span
=
vmas
.
search_lock
(
vma_start
,
len
);
#if VM_CRANGE
// XXX handle partial unmap
uptr
vma_end
=
vma_start
+
len
;
for
(
auto
r
:
span
)
{
for
(
auto
r
:
span
)
{
vma
*
rvma
=
(
vma
*
)
r
;
vma
*
rvma
=
(
vma
*
)
r
;
if
(
rvma
->
vma_start
<
vma_start
||
rvma
->
vma_end
>
vma_end
)
{
if
(
rvma
->
vma_start
<
vma_start
||
rvma
->
vma_end
>
vma_end
)
{
...
@@ -487,13 +511,14 @@ vmap::remove(uptr vma_start, uptr len)
...
@@ -487,13 +511,14 @@ vmap::remove(uptr vma_start, uptr len)
return
-
1
;
return
-
1
;
}
}
}
}
#endif
// XXX handle partial unmap
#if VM_CRANGE
#if VM_CRANGE
span
.
replace
(
0
);
span
.
replace
(
0
);
#endif
#endif
#if VM_RADIX
#if VM_RADIX
// XXX(austin) If this could tell us that nothing was replaced, we
// could skip the updatepages.
span
.
replace
(
vma_start
,
len
,
0
);
span
.
replace
(
vma_start
,
len
,
0
);
#endif
#endif
}
}
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论