Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
19f4b40a
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
19f4b40a
编写于
9月 23, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
!1292 系统优化:优化init内存
Merge pull request !1292 from cheng_jinsong/cpuset
上级
dada4574
58f967d4
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
30 addition
and
9 deletion
+30
-9
services/init/include/init_service.h
services/init/include/init_service.h
+3
-1
services/init/init_common_service.c
services/init/init_common_service.c
+5
-3
services/init/init_service_manager.c
services/init/init_service_manager.c
+14
-3
services/param/adapter/param_selinux.c
services/param/adapter/param_selinux.c
+8
-2
未找到文件。
services/init/include/init_service.h
浏览文件 @
19f4b40a
...
...
@@ -50,6 +50,8 @@ extern "C" {
#define SERVICE_ATTR_NEEDWAIT 0x400 // service should execute waitpid while stopping
#define SERVICE_ATTR_WITHOUT_SANDBOX 0x800 // make service not enter sandbox
#define SERVICE_ATTR_NOTIFY_STATE 0x1000 // service notify state
#define MAX_SERVICE_NAME 32
#define MAX_APL_NAME 32
#define MAX_ENV_NAME 64
...
...
@@ -155,7 +157,7 @@ typedef struct Service_ {
size_t
fdCount
;
TimerHandle
timer
;
ServiceJobs
serviceJobs
;
cpu_set_t
cpuSet
;
cpu_set_t
*
cpuSet
;
struct
ListNode
extDataNode
;
}
Service
;
#pragma pack()
...
...
services/init/init_common_service.c
浏览文件 @
19f4b40a
...
...
@@ -264,15 +264,15 @@ static void PublishHoldFds(Service *service)
static
int
BindCpuCore
(
Service
*
service
)
{
if
(
service
==
NULL
)
{
if
(
service
==
NULL
||
service
->
cpuSet
==
NULL
)
{
return
SERVICE_SUCCESS
;
}
if
(
CPU_COUNT
(
&
service
->
cpuSet
)
==
0
)
{
if
(
CPU_COUNT
(
service
->
cpuSet
)
==
0
)
{
return
SERVICE_SUCCESS
;
}
#ifndef __LITEOS_A__
int
pid
=
getpid
();
INIT_ERROR_CHECK
(
sched_setaffinity
(
pid
,
sizeof
(
service
->
cpuSet
),
&
service
->
cpuSet
)
==
0
,
INIT_ERROR_CHECK
(
sched_setaffinity
(
pid
,
sizeof
(
cpu_set_t
),
service
->
cpuSet
)
==
0
,
return
SERVICE_FAILURE
,
"%s set affinity between process(pid=%d) with CPU's core failed"
,
service
->
name
,
pid
);
INIT_LOGI
(
"%s set affinity between process(pid=%d) with CPU's core successfully"
,
service
->
name
,
pid
);
#endif
...
...
@@ -414,6 +414,8 @@ int ServiceStop(Service *service)
"stop service %s pid %d failed! err %d."
,
service
->
name
,
service
->
pid
,
errno
);
NotifyServiceChange
(
service
,
SERVICE_STOPPING
);
INIT_LOGI
(
"stop service %s, pid %d."
,
service
->
name
,
service
->
pid
);
service
->
pid
=
-
1
;
NotifyServiceChange
(
service
,
SERVICE_STOPPED
);
return
SERVICE_SUCCESS
;
}
...
...
services/init/init_service_manager.c
浏览文件 @
19f4b40a
...
...
@@ -95,7 +95,7 @@ Service *AddService(const char *name)
node
->
data
.
service
=
service
;
service
->
name
=
node
->
name
;
service
->
status
=
SERVICE_IDLE
;
CPU_ZERO
(
&
service
->
cpuSet
)
;
service
->
cpuSet
=
NULL
;
OH_ListInit
(
&
service
->
extDataNode
);
g_serviceSpace
.
serviceCount
++
;
INIT_LOGV
(
"AddService %s"
,
node
->
name
);
...
...
@@ -150,6 +150,10 @@ void ReleaseService(Service *service)
}
service
->
serviceJobs
.
jobsName
[
i
]
=
NULL
;
}
if
(
service
->
cpuSet
!=
NULL
)
{
free
(
service
->
cpuSet
);
service
->
cpuSet
=
NULL
;
}
#ifndef OHOS_LITE
// clear ext data
SERVICE_INFO_CTX
ctx
=
{
0
};
...
...
@@ -684,6 +688,11 @@ static int GetCpuArgs(const cJSON *argJson, const char *name, Service *service)
int
count
=
cJSON_GetArraySize
(
obj
);
int
cpus
=
-
1
;
int
cpuNumMax
=
sysconf
(
_SC_NPROCESSORS_CONF
);
if
(
count
>
0
&&
service
->
cpuSet
==
NULL
)
{
service
->
cpuSet
=
malloc
(
sizeof
(
cpu_set_t
));
INIT_ERROR_CHECK
(
service
->
cpuSet
!=
NULL
,
return
SERVICE_FAILURE
,
"Failed to malloc for cpuset"
);
}
CPU_ZERO
(
service
->
cpuSet
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
cJSON
*
item
=
cJSON_GetArrayItem
(
obj
,
i
);
INIT_ERROR_CHECK
(
item
!=
NULL
,
return
SERVICE_FAILURE
,
"prase invalid"
);
...
...
@@ -692,10 +701,10 @@ static int GetCpuArgs(const cJSON *argJson, const char *name, Service *service)
INIT_LOGW
(
"%s core number %d of CPU cores does not exist"
,
service
->
name
,
cpus
);
continue
;
}
if
(
CPU_ISSET
(
cpus
,
&
service
->
cpuSet
))
{
if
(
CPU_ISSET
(
cpus
,
service
->
cpuSet
))
{
continue
;
}
CPU_SET
(
cpus
,
&
service
->
cpuSet
);
CPU_SET
(
cpus
,
service
->
cpuSet
);
}
return
SERVICE_SUCCESS
;
}
...
...
@@ -836,6 +845,8 @@ int ParseOneService(const cJSON *curItem, Service *service)
INIT_ERROR_CHECK
(
ret
==
0
,
return
SERVICE_FAILURE
,
"Failed to get disabled flag for service %s"
,
service
->
name
);
ret
=
GetServiceAttr
(
curItem
,
service
,
CONSOLE_STR_IN_CFG
,
SERVICE_ATTR_CONSOLE
,
NULL
);
INIT_ERROR_CHECK
(
ret
==
0
,
return
SERVICE_FAILURE
,
"Failed to get console for service %s"
,
service
->
name
);
ret
=
GetServiceAttr
(
curItem
,
service
,
"notify-state"
,
SERVICE_ATTR_NOTIFY_STATE
,
NULL
);
INIT_ERROR_CHECK
(
ret
==
0
,
return
SERVICE_FAILURE
,
"Failed to get notify-state for service %s"
,
service
->
name
);
ParseOneServiceArgs
(
curItem
,
service
);
ret
=
GetServiceSandbox
(
curItem
,
service
);
...
...
services/param/adapter/param_selinux.c
浏览文件 @
19f4b40a
...
...
@@ -295,9 +295,15 @@ static int UpdaterCheckParamPermission(const ParamSecurityLabel *srcLabel, const
static
int
OpenPermissionWorkSpace
(
const
char
*
path
)
{
static
int
loadLabels
=
0
;
UNUSED
(
path
);
int
ret
=
0
;
if
(
loadLabels
==
0
)
{
// open workspace by readonly
return
SelinuxGetAllLabel
(
1
);
ret
=
SelinuxGetAllLabel
(
1
);
}
loadLabels
=
1
;
return
ret
;
}
INIT_LOCAL_API
int
RegisterSecuritySelinuxOps
(
ParamSecurityOps
*
ops
,
int
isInit
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录