Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
21daa928
提交
21daa928
2月 06, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
lockstat tweaks
上级
34b8eecf
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
34 行增加
和
6 行删除
+34
-6
lockstat.c
lockstat.c
+7
-4
lockstat.h
lockstat.h
+4
-1
spinlock.c
spinlock.c
+23
-1
没有找到文件。
lockstat.c
浏览文件 @
21daa928
...
...
@@ -24,7 +24,7 @@ stats(void)
if
(
fd
<
0
)
die
(
"lockstat: open failed"
);
printf
(
1
,
"## name
cycles acquires
\n
"
);
printf
(
1
,
"## name
acquires locking locked
\n
"
);
while
(
1
)
{
r
=
read
(
fd
,
&
ls
,
sz
);
if
(
r
<
0
)
...
...
@@ -34,13 +34,16 @@ stats(void)
if
(
r
!=
sz
)
die
(
"lockstat: unexpected read"
);
u64
cycles
=
0
,
acquires
=
0
;
u64
acquires
=
0
,
locking
=
0
,
locked
=
0
;
for
(
int
i
=
0
;
i
<
NCPU
;
i
++
)
{
cycles
+=
ls
.
cpu
[
i
].
cycles
;
acquires
+=
ls
.
cpu
[
i
].
acquires
;
locking
+=
ls
.
cpu
[
i
].
locking
;
locked
+=
ls
.
cpu
[
i
].
locked
;
}
printf
(
1
,
"%s %lu %lu
\n
"
,
ls
.
name
,
cycles
,
acquires
);
if
(
acquires
>
0
)
printf
(
1
,
"%s %lu %lu %lu
\n
"
,
ls
.
name
,
acquires
,
locking
,
locked
);
}
}
...
...
lockstat.h
浏览文件 @
21daa928
...
...
@@ -2,7 +2,10 @@
struct
cpulockstat
{
u64
acquires
;
u64
cycles
;
u64
locking
;
u64
locked
;
u64
locking_ts
;
u64
locked_ts
;
__padout__
;
}
__mpalign__
;
...
...
spinlock.c
浏览文件 @
21daa928
...
...
@@ -13,6 +13,12 @@
#if LOCKSTAT
static
int
lockstat_enable
;
static
inline
struct
cpulockstat
*
mylockstat
(
struct
spinlock
*
lk
)
{
return
&
lk
->
stat
->
s
.
cpu
[
cpunum
()];
}
#endif
static
inline
void
...
...
@@ -25,6 +31,11 @@ locking(struct spinlock *lk)
}
#endif
#if LOCKSTAT
if
(
lockstat_enable
&&
lk
->
stat
!=
NULL
)
mylockstat
(
lk
)
->
locking_ts
=
rdtsc
();
#endif
mtlock
(
lk
);
}
...
...
@@ -41,7 +52,9 @@ locked(struct spinlock *lk)
#if LOCKSTAT
if
(
lockstat_enable
&&
lk
->
stat
!=
NULL
)
{
lk
->
stat
->
s
.
cpu
[
cpunum
()].
acquires
++
;
struct
cpulockstat
*
s
=
mylockstat
(
lk
);
s
->
acquires
++
;
s
->
locked_ts
=
rdtsc
();
}
#endif
}
...
...
@@ -62,6 +75,15 @@ releasing(struct spinlock *lk)
lk
->
pcs
[
0
]
=
0
;
lk
->
cpu
=
0
;
#endif
#if LOCKSTAT
if
(
lockstat_enable
&&
lk
->
stat
!=
NULL
)
{
struct
cpulockstat
*
s
=
mylockstat
(
lk
);
u64
ts
=
rdtsc
();
s
->
locking
+=
ts
-
s
->
locking_ts
;
s
->
locked
+=
ts
-
s
->
locked_ts
;
}
#endif
}
// Check whether this cpu is holding the lock.
...
...
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论