Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
0ee57d47
提交
0ee57d47
4月 27, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
差异文件
Merge..i confused git somehow..
上级
156d2e74
4c59fc07
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
38 行增加
和
39 行删除
+38
-39
kalloc.hh
include/kalloc.hh
+0
-1
ns.hh
include/ns.hh
+2
-2
percpu.hh
include/percpu.hh
+4
-4
radix.hh
include/radix.hh
+2
-0
wquser.hh
include/wquser.hh
+0
-1
fs.cc
kernel/fs.cc
+1
-1
futex.cc
kernel/futex.cc
+0
-3
idle.cc
kernel/idle.cc
+3
-3
main.cc
kernel/main.cc
+1
-1
proc.cc
kernel/proc.cc
+0
-6
sched.cc
kernel/sched.cc
+0
-3
trap.cc
kernel/trap.cc
+3
-2
uwq.cc
kernel/uwq.cc
+3
-3
vm.cc
kernel/vm.cc
+16
-6
wqkern.cc
kernel/wqkern.cc
+1
-1
wqlib.cc
lib/wqlib.cc
+2
-2
没有找到文件。
include/kalloc.hh
浏览文件 @
0ee57d47
...
...
@@ -72,4 +72,3 @@ enum {
};
extern
percpu
<
kmem
>
kmems
;
extern
percpu
<
kmem
>
slabmem
[
slab_type_max
];
include/ns.hh
浏览文件 @
0ee57d47
...
...
@@ -102,7 +102,7 @@ class xns : public rcu_freed {
e
->
next
=
root
.
load
();
if
(
cmpxch
(
&
table
[
i
].
chain
,
e
->
next
.
load
(),
e
))
{
int
c
=
my
cpu
id
();
int
c
=
myid
();
acquire
(
&
percore_lock
[
c
]);
e
->
percore_c
=
c
;
e
->
percore_next
=
percore
[
c
].
load
();
...
...
@@ -180,7 +180,7 @@ class xns : public rcu_freed {
template
<
class
CB
>
void
enumerate
(
CB
cb
)
{
scoped_gc_epoch
gc
;
int
cpuoffset
=
my
cpu
id
();
int
cpuoffset
=
myid
();
for
(
int
i
=
0
;
i
<
NCPU
;
i
++
)
{
auto
e
=
percore
[(
i
+
cpuoffset
)
%
NCPU
].
load
();
while
(
e
)
{
...
...
include/percpu.hh
浏览文件 @
0ee57d47
#pragma once
extern
int
mycpuid
(
void
);
#include "cpu.hh"
template
<
typename
T
>
struct
percpu
{
...
...
@@ -11,15 +11,15 @@ struct percpu {
percpu
&
operator
=
(
const
percpu
&
o
)
=
delete
;
T
*
get
()
const
{
return
cpu
(
my
cpu
id
());
return
cpu
(
myid
());
}
T
*
operator
->
()
const
{
return
cpu
(
my
cpu
id
());
return
cpu
(
myid
());
}
T
&
operator
*
()
const
{
return
*
cpu
(
my
cpu
id
());
return
*
cpu
(
myid
());
}
T
&
operator
[](
int
id
)
const
{
...
...
include/radix.hh
浏览文件 @
0ee57d47
...
...
@@ -243,6 +243,8 @@ struct radix_iterator {
}
radix_elem
*
operator
*
()
const
{
// XXX(austin) If we don't hold a lock on this element, it's
// possible it will morph into a node under us.
return
path_
[
level_
]
->
load
().
elem
();
}
...
...
include/wquser.hh
浏览文件 @
0ee57d47
...
...
@@ -5,7 +5,6 @@
#include "uwq.hh"
#include "wqtypes.hh"
int
mycpuid
(
void
);
uwq_ipcbuf
*
allocipc
(
void
);
static
inline
void
*
...
...
kernel/fs.cc
浏览文件 @
0ee57d47
...
...
@@ -191,7 +191,7 @@ ialloc(u32 dev, short type)
struct
superblock
sb
;
readsb
(
dev
,
&
sb
);
for
(
int
k
=
my
cpu
id
()
*
IPB
;
k
<
sb
.
ninodes
;
k
+=
(
NCPU
*
IPB
))
{
for
(
int
k
=
myid
()
*
IPB
;
k
<
sb
.
ninodes
;
k
+=
(
NCPU
*
IPB
))
{
for
(
int
inum
=
k
;
inum
<
k
+
IPB
&&
inum
<
sb
.
ninodes
;
inum
++
){
if
(
inum
==
0
)
continue
;
...
...
kernel/futex.cc
浏览文件 @
0ee57d47
...
...
@@ -269,7 +269,4 @@ initfutex(void)
nsfutex
=
new
xns
<
futexkey_t
,
futexaddr
*
,
futexkey_hash
>
(
false
);
if
(
nsfutex
==
0
)
panic
(
"initfutex"
);
for
(
int
i
=
0
;
i
<
NCPU
;
i
++
)
new
(
&
nscache_
[
i
])
nscache
();
}
kernel/idle.cc
浏览文件 @
0ee57d47
...
...
@@ -149,9 +149,9 @@ initidle(void)
assert
((
u16
)
ebx
==
0x40
);
}
}
SLIST_INIT
(
&
idlem
[
myid
()].
zombies
);
initlock
(
&
idlem
[
myid
()].
lock
,
"idle_lock"
,
LOCKSTAT_IDLE
);
SLIST_INIT
(
&
idlem
->
zombies
);
initlock
(
&
idlem
->
lock
,
"idle_lock"
,
LOCKSTAT_IDLE
);
snprintf
(
p
->
name
,
sizeof
(
p
->
name
),
"idle_%u"
,
myid
());
mycpu
()
->
proc
=
p
;
...
...
kernel/main.cc
浏览文件 @
0ee57d47
...
...
@@ -141,7 +141,7 @@ cmain(u64 mbmagic, u64 mbaddr)
initmp
();
inittls
();
// thread local storage
// Some global constructors require mycpu()->id (via my
cpu
id())
// Some global constructors require mycpu()->id (via myid())
// which we setup in inittls
extern
const
uptr
sctors
[],
ectors
[];
for
(
const
uptr
*
ctorva
=
ectors
;
ctorva
>
sctors
;
)
{
...
...
kernel/proc.cc
浏览文件 @
0ee57d47
...
...
@@ -21,12 +21,6 @@ proc::hash(const u32 &p)
return
p
;
}
int
mycpuid
(
void
)
{
return
mycpu
()
->
id
;
}
xns
<
u32
,
proc
*
,
proc
::
hash
>
*
xnspid
__mpalign__
;
struct
proc
*
bootproc
__mpalign__
;
...
...
kernel/sched.cc
浏览文件 @
0ee57d47
...
...
@@ -339,9 +339,6 @@ statread(struct inode *inode, char *dst, u32 off, u32 n)
void
initsched
(
void
)
{
for
(
int
i
=
0
;
i
<
NCPU
;
i
++
)
new
(
&
schedule_
[
i
])
schedule
();
devsw
[
MAJ_STAT
].
write
=
nullptr
;
devsw
[
MAJ_STAT
].
read
=
statread
;
}
kernel/trap.cc
浏览文件 @
0ee57d47
...
...
@@ -174,7 +174,7 @@ trap(struct trapframe *tf)
// In user space, assume process misbehaved.
uerr
.
println
(
"pid "
,
myproc
()
->
pid
,
' '
,
myproc
()
->
name
,
": trap "
,
(
u64
)
tf
->
trapno
,
" err "
,
(
u32
)
tf
->
err
,
" on cpu "
,
my
cpu
id
(),
" rip "
,
shex
(
tf
->
rip
),
" on cpu "
,
myid
(),
" rip "
,
shex
(
tf
->
rip
),
" rsp "
,
shex
(
tf
->
rsp
),
" addr "
,
shex
(
rcr2
()),
"--kill proc"
);
myproc
()
->
killed
=
1
;
...
...
@@ -291,7 +291,8 @@ getcallerpcs(void *v, uptr pcs[], int n)
if
(
rbp
==
0
||
rbp
<
(
uptr
*
)
KBASE
||
rbp
==
(
uptr
*
)(
~
0UL
)
||
(
rbp
>=
(
uptr
*
)
KBASEEND
&&
rbp
<
(
uptr
*
)
KCODE
))
break
;
pcs
[
i
]
=
rbp
[
1
];
// saved %rip
pcs
[
i
]
=
rbp
[
1
]
-
1
;
// saved %rip; - 1 so it points to the call
// instruction
rbp
=
(
uptr
*
)
rbp
[
0
];
// saved %rbp
}
for
(;
i
<
n
;
i
++
)
...
...
kernel/uwq.cc
浏览文件 @
0ee57d47
...
...
@@ -28,7 +28,7 @@ uwq_trywork(void)
for
(
i
=
0
;
i
<
NCPU
;
i
++
)
{
u64
j
=
(
i
+
k
)
%
NCPU
;
if
(
j
==
my
cpu
id
())
if
(
j
==
myid
())
continue
;
struct
cpu
*
c
=
&
cpus
[
j
];
...
...
@@ -199,7 +199,7 @@ uwq::tryworker(void)
proc
*
p
=
w
->
proc_
;
acquire
(
&
p
->
lock
);
p
->
cpuid
=
my
cpu
id
();
p
->
cpuid
=
myid
();
release
(
&
p
->
lock
);
w
->
running_
=
true
;
...
...
@@ -226,7 +226,7 @@ again:
w
->
running_
=
true
;
acquire
(
&
p
->
lock
);
p
->
cpuid
=
my
cpu
id
();
p
->
cpuid
=
myid
();
addrun
(
p
);
release
(
&
p
->
lock
);
...
...
kernel/vm.cc
浏览文件 @
0ee57d47
...
...
@@ -270,9 +270,9 @@ vmap::replace_vma(vma *a, vma *b)
assert
(
a
->
vma_start
==
b
->
vma_start
);
assert
(
a
->
vma_end
==
b
->
vma_end
);
auto
span
=
vmas
.
search_lock
(
a
->
vma_start
,
a
->
vma_end
-
a
->
vma_start
);
#if VM_CRANGE
if
(
a
->
deleted
())
return
false
;
#if VM_CRANGE
for
(
auto
e
:
span
)
assert
(
a
==
e
);
span
.
replace
(
b
);
...
...
@@ -477,11 +477,6 @@ again:
updatepages
(
pml4
,
e
->
vma_start
,
e
->
vma_end
,
[
&
needtlb
](
atomic
<
pme_t
>
*
p
)
{
for
(;;)
{
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
)
continue
;
if
(
!
(
v
&
PTE_P
))
...
...
@@ -623,7 +618,12 @@ vmap::pagefault(uptr va, u32 err)
}
scoped_gc_epoch
gc
;
#if VM_CRANGE
vma
*
m
=
lookup
(
va
,
1
);
#elif VM_RADIX
auto
vma_it
=
vmas
.
find
(
va
);
vma
*
m
=
static_cast
<
vma
*>
(
*
vma_it
);
#endif
if
(
m
==
0
)
return
-
1
;
...
...
@@ -664,10 +664,20 @@ vmap::pagefault(uptr va, u32 err)
if
(
!
cmpxch
(
pte
,
ptev
,
ptev
|
PTE_LOCK
))
goto
retry
;
#if VM_CRANGE
if
(
m
->
deleted
())
{
*
pte
=
ptev
;
goto
retry
;
}
#elif VM_RADIX
// The radix tree is the source of truth about where the VMA is
// mapped. It might have been unmapped from this va but still be
// around, so we can't just test if it's deleted.
if
(
*
vma_it
!=
m
)
{
*
pte
=
ptev
;
goto
retry
;
}
#endif
if
(
m
->
va_type
==
COW
)
{
*
pte
=
v2p
(
m
->
n
->
page
[
npg
])
|
PTE_P
|
PTE_U
|
PTE_COW
;
...
...
kernel/wqkern.cc
浏览文件 @
0ee57d47
...
...
@@ -31,7 +31,7 @@ int
wq_push
(
work
*
w
)
{
assert
(
wq_
);
return
wq_
->
push
(
w
,
my
cpu
id
());
return
wq_
->
push
(
w
,
myid
());
}
void
...
...
lib/wqlib.cc
浏览文件 @
0ee57d47
...
...
@@ -158,7 +158,7 @@ wq::trywork(bool dosteal)
// A "random" victim CPU
k
=
rdtsc
();
w
=
pop
(
my
cpu
id
());
w
=
pop
(
myid
());
if
(
w
!=
nullptr
)
{
w
->
run
();
return
1
;
...
...
@@ -170,7 +170,7 @@ wq::trywork(bool dosteal)
for
(
i
=
0
;
i
<
NCPU
;
i
++
)
{
u64
j
=
(
i
+
k
)
%
NCPU
;
if
(
j
==
my
cpu
id
())
if
(
j
==
myid
())
continue
;
w
=
steal
(
j
);
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论