Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
c724d1f0
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
1 年多 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c724d1f0
编写于
2月 09, 2022
作者:
O
openharmony_ci
提交者:
Gitee
2月 09, 2022
浏览文件
操作
浏览文件
下载
差异文件
!295 Fix: 修复 CPU 多核绑定
Merge pull request !295 from 熊磊/0209
上级
bfaa6c20
6ff67227
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
16 deletion
+12
-16
services/init/init_common_service.c
services/init/init_common_service.c
+12
-16
未找到文件。
services/init/init_common_service.c
浏览文件 @
c724d1f0
...
@@ -236,21 +236,6 @@ static void PublishHoldFds(Service *service)
...
@@ -236,21 +236,6 @@ static void PublishHoldFds(Service *service)
}
}
}
}
static
int
SetAffinityBetweenProcAndCore
(
pid_t
pid
,
int
cpuIndex
)
{
cpu_set_t
setMask
;
CPU_ZERO
(
&
setMask
);
CPU_SET
(
cpuIndex
,
&
setMask
);
int
ret
=
sched_setaffinity
(
pid
,
sizeof
(
cpu_set_t
),
&
setMask
);
if
(
ret
!=
0
)
{
INIT_LOGI
(
"Set affinity between process(pid=%d) with CPU's core %d failed"
,
pid
,
cpuIndex
);
return
SERVICE_FAILURE
;
}
else
{
INIT_LOGE
(
"Set affinity between process(pid=%d) with CPU's core %d successfully"
,
pid
,
cpuIndex
);
}
return
SERVICE_SUCCESS
;
}
static
int
BindCpuCore
(
Service
*
service
)
static
int
BindCpuCore
(
Service
*
service
)
{
{
if
(
service
==
NULL
||
service
->
cpuInfo
.
cpuNum
<=
0
)
{
if
(
service
==
NULL
||
service
->
cpuInfo
.
cpuNum
<=
0
)
{
...
@@ -260,13 +245,24 @@ static int BindCpuCore(Service *service)
...
@@ -260,13 +245,24 @@ static int BindCpuCore(Service *service)
INIT_ERROR_CHECK
(
service
->
cpuInfo
.
cpuNum
<=
cpuNum
,
return
SERVICE_FAILURE
,
INIT_ERROR_CHECK
(
service
->
cpuInfo
.
cpuNum
<=
cpuNum
,
return
SERVICE_FAILURE
,
"%s cpus cores exceeds total number of device cores"
,
service
->
name
);
"%s cpus cores exceeds total number of device cores"
,
service
->
name
);
int
index
=
0
;
int
index
=
0
;
cpu_set_t
setMask
;
CPU_ZERO
(
&
setMask
);
int
pid
=
getpid
();
for
(
int
i
=
0
;
i
<
service
->
cpuInfo
.
cpuNum
;
i
++
)
{
for
(
int
i
=
0
;
i
<
service
->
cpuInfo
.
cpuNum
;
i
++
)
{
index
=
(
int
)
service
->
cpuInfo
.
cpus
[
i
];
index
=
(
int
)
service
->
cpuInfo
.
cpus
[
i
];
if
((
int
)
cpuNum
<=
index
)
{
if
((
int
)
cpuNum
<=
index
)
{
INIT_LOGW
(
"%s core number %d of CPU cores does not exist"
,
service
->
name
,
index
);
INIT_LOGW
(
"%s core number %d of CPU cores does not exist"
,
service
->
name
,
index
);
continue
;
continue
;
}
}
(
void
)
SetAffinityBetweenProcAndCore
(
getpid
(),
index
);
if
(
CPU_ISSET
(
index
,
&
setMask
))
{
continue
;
}
CPU_SET
(
index
,
&
setMask
);
}
if
(
sched_setaffinity
(
pid
,
sizeof
(
setMask
),
&
setMask
)
!=
0
)
{
INIT_LOGI
(
"%s set affinity between process(pid=%d) with CPU's core failed"
,
service
->
name
,
pid
);
}
else
{
INIT_LOGE
(
"%s set affinity between process(pid=%d) with CPU's core successfully"
,
service
->
name
,
pid
);
}
}
return
SERVICE_SUCCESS
;
return
SERVICE_SUCCESS
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录