Compare commits
64 Commits
weekly_202
...
weekly_202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
180bf8e5cd | ||
|
|
dbbb96c427 | ||
|
|
e3eaae1b1c | ||
|
|
9b5892e0a6 | ||
|
|
6a4d0be681 | ||
|
|
8fe4080d08 | ||
|
|
cfa0209c14 | ||
|
|
a235c4c106 | ||
|
|
c2cb0435b2 | ||
|
|
4fbb41b7d5 | ||
|
|
04f971084b | ||
|
|
6daecc8d26 | ||
|
|
173cdeb077 | ||
|
|
e28271d650 | ||
|
|
27eb4e2334 | ||
|
|
bd57ef7e2c | ||
|
|
342a3eb5c1 | ||
|
|
63885154d2 | ||
|
|
95d1eb890a | ||
|
|
0bc453c2cd | ||
|
|
73bcf0ec9a | ||
|
|
49bfc90a63 | ||
|
|
b0708886fa | ||
|
|
a388a3f565 | ||
|
|
145ff76ab6 | ||
|
|
280769ae42 | ||
|
|
1f3a6c8143 | ||
|
|
6c0b0dde23 | ||
|
|
76228c3617 | ||
|
|
5de241eb2a | ||
|
|
5e68558280 | ||
|
|
9c71de6a2e | ||
|
|
243b1e26a4 | ||
|
|
47a4fe030b | ||
|
|
577d29aaba | ||
|
|
d9e9631286 | ||
|
|
2bd5b686cf | ||
|
|
8452488bdb | ||
|
|
a04ab13c76 | ||
|
|
338f5d7e7d | ||
|
|
fa68ebfcd1 | ||
|
|
24aa6858ee | ||
|
|
5fb9165c08 | ||
|
|
13f68dcf9c | ||
|
|
f332a06e4c | ||
|
|
1ba32406bb | ||
|
|
249ea71a11 | ||
|
|
814f5affd0 | ||
|
|
4ff66c7f40 | ||
|
|
8f937c8771 | ||
|
|
2845efe801 | ||
|
|
8cc5209181 | ||
|
|
f995c7c7af | ||
|
|
a104497e08 | ||
|
|
b5ae9e25c6 | ||
|
|
c2b5a5897f | ||
|
|
f924cc775b | ||
|
|
5dc9a0f1a6 | ||
|
|
806bd80841 | ||
|
|
c141a92544 | ||
|
|
10c5e2e666 | ||
|
|
da9ce464dd | ||
|
|
f0a435dce1 | ||
|
|
b45cdbda3e |
18
BUILD.gn
18
BUILD.gn
@@ -202,6 +202,10 @@ config("warn_config") {
|
||||
]
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-Wno-address-of-packed-member" ]
|
||||
cflags += [
|
||||
"-Wno-unused-but-set-variable",
|
||||
"-Wno-strict-prototypes",
|
||||
]
|
||||
}
|
||||
asmflags = cflags
|
||||
}
|
||||
@@ -251,7 +255,13 @@ config("container_config") {
|
||||
"-DLOSCFG_IPC_CONTAINER",
|
||||
"-DLOSCFG_TIME_CONTAINER",
|
||||
"-DLOSCFG_USER_CONTAINER",
|
||||
"-DLOSCFG_NET_CONTAINER",
|
||||
"-DLOSCFG_PROC_PROCESS_DIR",
|
||||
"-DLOSCFG_KERNEL_PLIMITS",
|
||||
"-DLOSCFG_KERNEL_MEM_PLIMIT",
|
||||
"-DLOSCFG_KERNEL_IPC_PLIMIT",
|
||||
"-DLOSCFG_KERNEL_DEV_PLIMIT",
|
||||
"-DLOSCFG_KERNEL_SCHED_PLIMIT",
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -289,7 +299,7 @@ config("public") {
|
||||
|
||||
configs += [
|
||||
"$HDFTOPDIR:public",
|
||||
"//drivers/liteos:public",
|
||||
"$DRIVERS_LITEOS_DIR:public",
|
||||
]
|
||||
|
||||
if (HAVE_DEVICE_SDK) {
|
||||
@@ -314,8 +324,8 @@ group("modules") {
|
||||
]
|
||||
|
||||
deps += [
|
||||
"//drivers/liteos",
|
||||
HDFTOPDIR,
|
||||
"$DRIVERS_LITEOS_DIR",
|
||||
"$HDFTOPDIR",
|
||||
]
|
||||
|
||||
if (HAVE_DEVICE_SDK) {
|
||||
@@ -341,7 +351,7 @@ group("liteos_a") {
|
||||
deps += [
|
||||
":apps",
|
||||
":tests",
|
||||
"//third_party/musl/scripts/build_lite:strip",
|
||||
"$THIRDPARTY_MUSL_DIR/scripts/build_lite:strip",
|
||||
]
|
||||
if (liteos_skip_make == false) {
|
||||
deps += [ ":make" ]
|
||||
|
||||
256
CHANGELOG.md
256
CHANGELOG.md
@@ -8,64 +8,64 @@
|
||||
* A核代码静态告警定期清理 ([9ba725c](https://gitee.com/openharmony/kernel_liteos_a/commits/9ba725c3d486dd28fe9b2489b0f95a65354d7d86)), closes [#I4I0O8](https://gitee.com/openharmony/kernel_liteos_a/issues/I4I0O8)
|
||||
* change default permission of procfs to 0550 ([a776c04](https://gitee.com/openharmony/kernel_liteos_a/commits/a776c04a3da414f73ef7136a543c029cc6dd75be)), closes [#I4NY49](https://gitee.com/openharmony/kernel_liteos_a/issues/I4NY49)
|
||||
* change the execFile field in TCB to execVnode ([e4a0662](https://gitee.com/openharmony/kernel_liteos_a/commits/e4a06623ceb49b5bead60d45c0534db88b9c666f)), closes [#I4CLL9](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CLL9)
|
||||
* close file when process interpretor failed ([a375bf5](https://gitee.com/openharmony/kernel_liteos_a/commits/a375bf5668a5e86e082d0e124b538e423023a259)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* codex 清理 ([9ab3e35](https://gitee.com/openharmony/kernel_liteos_a/commits/9ab3e351d38cdae2ec083048a50a253bc2a3b604)), closes [#I4BL3](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BL3)
|
||||
* close file when process interpretor failed ([a375bf5](https://gitee.com/openharmony/kernel_liteos_a/commits/a375bf5668a5e86e082d0e124b538e423023a259)), closes [#I4ATQX](https://gitee.com/openharmony/kernel_liteos_a/issues/I4ATQX)
|
||||
* codex 清理 ([9ab3e35](https://gitee.com/openharmony/kernel_liteos_a/commits/9ab3e351d38cdae2ec083048a50a253bc2a3b604)), closes [#I4BL3S](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BL3S)
|
||||
* dyload open close failed ([5e87d8c](https://gitee.com/openharmony/kernel_liteos_a/commits/5e87d8c183471166294e2caa041ab4da8570c6a1)), closes [#I452Z7](https://gitee.com/openharmony/kernel_liteos_a/issues/I452Z7)
|
||||
* fix ppoll ([a55f68f](https://gitee.com/openharmony/kernel_liteos_a/commits/a55f68f957e9f8ad74bd9e0c1b3d27775e0f8c75))
|
||||
* fix some function declarations ([63fd8bc](https://gitee.com/openharmony/kernel_liteos_a/commits/63fd8bc39b21fffb6990f74e879eefecafad6c88))
|
||||
* implicit declaration of function 'syscall' in apps/shell ([bd0c083](https://gitee.com/openharmony/kernel_liteos_a/commits/bd0c0835fc58ed5f941dbbc9adfac74253eeb874))
|
||||
* LOS_Panic和魔法键功能中的使用PRINTK打印,依赖任务调度,特殊情况下存在打印不出来的问题 ([53addea](https://gitee.com/openharmony/kernel_liteos_a/commits/53addea304de09e0df457b690403ac652bbcea72)), closes [#I4NOC7](https://gitee.com/openharmony/kernel_liteos_a/issues/I4NOC7)
|
||||
* los_stat_pri.h中缺少依赖的头文件 ([2cd03c5](https://gitee.com/openharmony/kernel_liteos_a/commits/2cd03c55b7a614c648adc965ebfe494d491fe20f)), closes [#I4KEZ1](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KEZ1)
|
||||
* los_trace.h接口注释错误修正 ([6d24961](https://gitee.com/openharmony/kernel_liteos_a/commits/6d249618aecc216388f9b1a2b48fe0ac6dd19ff2)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* MMU竞态问题修复 ([748e0d8](https://gitee.com/openharmony/kernel_liteos_a/commits/748e0d8ffb6ee9c8757ed056f575e3abc6c10702)), closes [#I2](https://gitee.com/openharmony/kernel_liteos_a/issues/I2)
|
||||
* **mtd:** 去除mtd对hisilicon驱动的依赖 ([f7d010d](https://gitee.com/openharmony/kernel_liteos_a/commits/f7d010dfa4cb825096267528e131a9e2735d7505)), closes [#I49](https://gitee.com/openharmony/kernel_liteos_a/issues/I49)
|
||||
* OsFutexWaitParamCheck函数中absTime为0时,直接返回,不需要打印 ([3f71be7](https://gitee.com/openharmony/kernel_liteos_a/commits/3f71be75355f11037d9de80cc4d7da0f01905003)), closes [#I4D67](https://gitee.com/openharmony/kernel_liteos_a/issues/I4D67)
|
||||
* OsLockDepCheckIn异常处理中存在g_lockdepAvailable锁嵌套调用, ([bf030b6](https://gitee.com/openharmony/kernel_liteos_a/commits/bf030b6bb5843151a5b8b8736246a1376a5fb9d0)), closes [#I457](https://gitee.com/openharmony/kernel_liteos_a/issues/I457)
|
||||
* los_trace.h接口注释错误修正 ([6d24961](https://gitee.com/openharmony/kernel_liteos_a/commits/6d249618aecc216388f9b1a2b48fe0ac6dd19ff2)), closes [#I4CYPZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CYPZ)
|
||||
* MMU竞态问题修复 ([748e0d8](https://gitee.com/openharmony/kernel_liteos_a/commits/748e0d8ffb6ee9c8757ed056f575e3abc6c10702)), closes [#I2WARC](https://gitee.com/openharmony/kernel_liteos_a/issues/I2WARC)
|
||||
* **mtd:** 去除mtd对hisilicon驱动的依赖 ([f7d010d](https://gitee.com/openharmony/kernel_liteos_a/commits/f7d010dfa4cb825096267528e131a9e2735d7505)), closes [#I49FKL](https://gitee.com/openharmony/kernel_liteos_a/issues/I49FKL)
|
||||
* OsFutexWaitParamCheck函数中absTime为0时,直接返回,不需要打印 ([3f71be7](https://gitee.com/openharmony/kernel_liteos_a/commits/3f71be75355f11037d9de80cc4d7da0f01905003)), closes [#I4D67E](https://gitee.com/openharmony/kernel_liteos_a/issues/I4D67E)
|
||||
* OsLockDepCheckIn异常处理中存在g_lockdepAvailable锁嵌套调用, ([bf030b6](https://gitee.com/openharmony/kernel_liteos_a/commits/bf030b6bb5843151a5b8b8736246a1376a5fb9d0)), closes [#I457ZZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I457ZZ)
|
||||
* pr模板补充说明 ([e3cd485](https://gitee.com/openharmony/kernel_liteos_a/commits/e3cd485db528490a16a8932d734faab263b44bc9))
|
||||
* same file mode for procfs files ([c79bcd0](https://gitee.com/openharmony/kernel_liteos_a/commits/c79bcd028e1be34b45cba000077230fa2ef95e68)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* same file mode for procfs files ([c79bcd0](https://gitee.com/openharmony/kernel_liteos_a/commits/c79bcd028e1be34b45cba000077230fa2ef95e68)), closes [#I4ACTC](https://gitee.com/openharmony/kernel_liteos_a/issues/I4ACTC)
|
||||
* shell支持exit退出,完善帮助信息,特殊处理不可见字符 ([cc6e112](https://gitee.com/openharmony/kernel_liteos_a/commits/cc6e11281e63b6bdc9be8e5d3c39f1258eb2ceaa))
|
||||
* smp初始化中副核冗余的启动框架调用 ([5ce70a5](https://gitee.com/openharmony/kernel_liteos_a/commits/5ce70a50c3733b6ec8cc4b444837e366ec837f69)), closes [#I4F8A5](https://gitee.com/openharmony/kernel_liteos_a/issues/I4F8A5)
|
||||
* solve SIGCHLD ignored in sigsuspend() ([5a80d4e](https://gitee.com/openharmony/kernel_liteos_a/commits/5a80d4e1a34c94204a0bb01443bf25a4fdb12750)), closes [#I47](https://gitee.com/openharmony/kernel_liteos_a/issues/I47)
|
||||
* solve SIGCHLD ignored in sigsuspend() ([5a80d4e](https://gitee.com/openharmony/kernel_liteos_a/commits/5a80d4e1a34c94204a0bb01443bf25a4fdb12750)), closes [#I47CKK](https://gitee.com/openharmony/kernel_liteos_a/issues/I47CKK)
|
||||
* syscall review bugfix ([214f44e](https://gitee.com/openharmony/kernel_liteos_a/commits/214f44e935277c29d347c50b553a31ea7df36448)), closes [#149](https://gitee.com/openharmony/kernel_liteos_a/issues/149)
|
||||
* **test:** misc09用例因依赖hosts文件而失败 ([f2f5c5f](https://gitee.com/openharmony/kernel_liteos_a/commits/f2f5c5fdc3202610de173e7046adab4df5e59142)), closes [re#I48IZ0](https://gitee.com/re/issues/I48IZ0)
|
||||
* **test:** 修复sys部分用例因依赖passwd、group文件而失败 ([614cdcc](https://gitee.com/openharmony/kernel_liteos_a/commits/614cdccf91bd2d220c4c76418b53400ce714c6cb)), closes [re#I48](https://gitee.com/re/issues/I48)
|
||||
* 中断中调用PRINTK概率卡死,导致系统不能正常响应中断 ([9726ba1](https://gitee.com/openharmony/kernel_liteos_a/commits/9726ba11a79f3d2d1e616e12ef0bb44e4fc5cd20)), closes [#I4C9](https://gitee.com/openharmony/kernel_liteos_a/issues/I4C9)
|
||||
* **test:** misc09用例因依赖hosts文件而失败 ([f2f5c5f](https://gitee.com/openharmony/kernel_liteos_a/commits/f2f5c5fdc3202610de173e7046adab4df5e59142)), closes [#I48IZ0](https://gitee.com/openharmony/kernel_liteos_a/issues/I48IZ0)
|
||||
* **test:** 修复sys部分用例因依赖passwd、group文件而失败 ([614cdcc](https://gitee.com/openharmony/kernel_liteos_a/commits/614cdccf91bd2d220c4c76418b53400ce714c6cb)), closes [#I48IUC](https://gitee.com/openharmony/kernel_liteos_a/issues/I48IUC)
|
||||
* 中断中调用PRINTK概率卡死,导致系统不能正常响应中断 ([9726ba1](https://gitee.com/openharmony/kernel_liteos_a/commits/9726ba11a79f3d2d1e616e12ef0bb44e4fc5cd20)), closes [#I4C9GC](https://gitee.com/openharmony/kernel_liteos_a/issues/I4C9GC)
|
||||
* 临终遗言重定向内容缺失task相关信息,对应的shell命令中申请的内存需要cacheline对齐 ([48ca854](https://gitee.com/openharmony/kernel_liteos_a/commits/48ca854bf07f8dcda9657f950601043a485a1b33)), closes [#I482S5](https://gitee.com/openharmony/kernel_liteos_a/issues/I482S5)
|
||||
* 优化liteipc任务状态,删除功能重复字段 ([5004ef4](https://gitee.com/openharmony/kernel_liteos_a/commits/5004ef4d87b54fb6d7f748ca8212ae155bcefac5)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 优化trace buffer初始化,删除swtmr 桩中的无效参数 ([b551270](https://gitee.com/openharmony/kernel_liteos_a/commits/b551270ef50cb206360e2eee3dd20ace5cecccb7)), closes [#I4DQ1](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DQ1)
|
||||
* 修复 virpart.c 不适配的格式化打印问题 ([de29140](https://gitee.com/openharmony/kernel_liteos_a/commits/de29140edf2567f4847876cb1ed5e0b6857420f3)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 修复A核文档失效的问题 ([456d255](https://gitee.com/openharmony/kernel_liteos_a/commits/456d255a81c2031be8ebecc2bf897af80c3d3c7a)), closes [#I4U7](https://gitee.com/openharmony/kernel_liteos_a/issues/I4U7)
|
||||
* 修复A核测试用例失败的问题 ([59329ce](https://gitee.com/openharmony/kernel_liteos_a/commits/59329ce7c6b6a00084df427748e6283287a773c0)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 修复A核测试用例失败的问题 ([be68dc8](https://gitee.com/openharmony/kernel_liteos_a/commits/be68dc8bcaf8d965039ae1d792775f00a08adfac)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 优化liteipc任务状态,删除功能重复字段 ([5004ef4](https://gitee.com/openharmony/kernel_liteos_a/commits/5004ef4d87b54fb6d7f748ca8212ae155bcefac5)), closes [#I4FVHK](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FVHK)
|
||||
* 优化trace buffer初始化,删除swtmr 桩中的无效参数 ([b551270](https://gitee.com/openharmony/kernel_liteos_a/commits/b551270ef50cb206360e2eee3dd20ace5cecccb7)), closes [#I4DQ1X](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DQ1X)
|
||||
* 修复 virpart.c 不适配的格式化打印问题 ([de29140](https://gitee.com/openharmony/kernel_liteos_a/commits/de29140edf2567f4847876cb1ed5e0b6857420f3)), closes [#I4PEVP](https://gitee.com/openharmony/kernel_liteos_a/issues/I4PEVP)
|
||||
* 修复A核文档失效的问题 ([456d255](https://gitee.com/openharmony/kernel_liteos_a/commits/456d255a81c2031be8ebecc2bf897af80c3d3c7a)), closes [#I4U7TF](https://gitee.com/openharmony/kernel_liteos_a/issues/I4U7TF)
|
||||
* 修复A核测试用例失败的问题 ([59329ce](https://gitee.com/openharmony/kernel_liteos_a/commits/59329ce7c6b6a00084df427748e6283287a773c0)), closes [#I4SQDR](https://gitee.com/openharmony/kernel_liteos_a/issues/I4SQDR)
|
||||
* 修复A核测试用例失败的问题 ([be68dc8](https://gitee.com/openharmony/kernel_liteos_a/commits/be68dc8bcaf8d965039ae1d792775f00a08adfac)), closes [#I4SQDP](https://gitee.com/openharmony/kernel_liteos_a/issues/I4SQDP)
|
||||
* 修复dispatch单词拼写错误。 ([9b07aec](https://gitee.com/openharmony/kernel_liteos_a/commits/9b07aece2dfa3494cf35e8b388410341508d6224)), closes [#I4BLE8](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BLE8)
|
||||
* 修复futime提示错误22的BUG ([f2861dd](https://gitee.com/openharmony/kernel_liteos_a/commits/f2861ddfb424af7b99c278273601ce0fab1f37e6))
|
||||
* 修复jffs2适配层错误释放锁的BUG ([011a55f](https://gitee.com/openharmony/kernel_liteos_a/commits/011a55ff21d95f969abac60bcff96f4c4d7a326d)), closes [#I4FH9](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FH9)
|
||||
* 修复los_vm_scan.c中内部函数OsInactiveListIsLow冗余代码 ([bc32a1e](https://gitee.com/openharmony/kernel_liteos_a/commits/bc32a1ec0fa5d19c6d2672bcf4a01de5e1be3afb)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 修复jffs2适配层错误释放锁的BUG ([011a55f](https://gitee.com/openharmony/kernel_liteos_a/commits/011a55ff21d95f969abac60bcff96f4c4d7a326d)), closes [#I4FH9M](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FH9M)
|
||||
* 修复los_vm_scan.c中内部函数OsInactiveListIsLow冗余代码 ([bc32a1e](https://gitee.com/openharmony/kernel_liteos_a/commits/bc32a1ec0fa5d19c6d2672bcf4a01de5e1be3afb)), closes [#I4HKFF](https://gitee.com/openharmony/kernel_liteos_a/issues/I4HKFF)
|
||||
* 修复LOSCFG_FS_FAT_CACHE宏关闭后编译失败的BUG ([63e71fe](https://gitee.com/openharmony/kernel_liteos_a/commits/63e71feca05a8d46a49822c713258738740f0712)), closes [#I3T3N0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3T3N0)
|
||||
* 修复OsVmPhysFreeListAdd和OsVmPhysFreeListAddUnsafe函数内容重复 ([6827bd2](https://gitee.com/openharmony/kernel_liteos_a/commits/6827bd2a22b78aa05e20d6460412fc7b2d738929)), closes [#I4FL95](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FL95)
|
||||
* 修复PR520缺陷 ([4033891](https://gitee.com/openharmony/kernel_liteos_a/commits/40338918d9132399ee0494d331930a05b7a13c67)), closes [re#I4DEG5](https://gitee.com/re/issues/I4DEG5)
|
||||
* 修复shcmd.h需要用宏包起来的问题 ([6c4e4b1](https://gitee.com/openharmony/kernel_liteos_a/commits/6c4e4b16abe9c68fea43d40b2d39b4f0ed4bfc9c)), closes [#I4N50](https://gitee.com/openharmony/kernel_liteos_a/issues/I4N50)
|
||||
* 修复xts权限用例压测异常问题 ([b0d31cb](https://gitee.com/openharmony/kernel_liteos_a/commits/b0d31cb43f5a8d1c3da574b2b957e3b0e98b3067)), closes [#I3ZJ1](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZJ1)
|
||||
* 修复硬随机不可用时,地址随机化不可用问题 ([665c152](https://gitee.com/openharmony/kernel_liteos_a/commits/665c152c27bb86395ddd0395279255f6cdaf7255)), closes [#I4D4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4D4)
|
||||
* 修复进程用例导致门禁概率失败 ([1ed28b4](https://gitee.com/openharmony/kernel_liteos_a/commits/1ed28b4c80cfd222be08b0c2e71e6287e52bb276)), closes [#I4FO0](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FO0)
|
||||
* 修复进程线程不稳定用例 ([f6ac03d](https://gitee.com/openharmony/kernel_liteos_a/commits/f6ac03d3e3c56236adc5734d4c059f1fbcc9e0c1)), closes [#I4F1](https://gitee.com/openharmony/kernel_liteos_a/issues/I4F1)
|
||||
* 修复重复执行内存用例导致系统卡死问题 ([6c2b163](https://gitee.com/openharmony/kernel_liteos_a/commits/6c2b163c7d7c696ef89b17a0275f3cddb3d7cefb)), closes [#I4F7](https://gitee.com/openharmony/kernel_liteos_a/issues/I4F7)
|
||||
* 修改MMU模块的注释错误 ([1a8e22d](https://gitee.com/openharmony/kernel_liteos_a/commits/1a8e22dcf15944153e013d004fd7bbf24557a8c7)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 共享内存问题修复 ([9fdb80f](https://gitee.com/openharmony/kernel_liteos_a/commits/9fdb80f85f92d0167a0456455a94fc6f679797ce)), closes [#I47X2](https://gitee.com/openharmony/kernel_liteos_a/issues/I47X2)
|
||||
* 内核ERR打印,无进程和线程信息,不方便问题定位。 ([cb423f8](https://gitee.com/openharmony/kernel_liteos_a/commits/cb423f845462b8cc474c3cba261dadf3943a08ef)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 修复PR520缺陷 ([4033891](https://gitee.com/openharmony/kernel_liteos_a/commits/40338918d9132399ee0494d331930a05b7a13c67)), closes [#I4DEG5](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DEG5)
|
||||
* 修复shcmd.h需要用宏包起来的问题 ([6c4e4b1](https://gitee.com/openharmony/kernel_liteos_a/commits/6c4e4b16abe9c68fea43d40b2d39b4f0ed4bfc9c)), closes [#I4N50W](https://gitee.com/openharmony/kernel_liteos_a/issues/I4N50W)
|
||||
* 修复xts权限用例压测异常问题 ([b0d31cb](https://gitee.com/openharmony/kernel_liteos_a/commits/b0d31cb43f5a8d1c3da574b2b957e3b0e98b3067)), closes [#I3ZJ1D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZJ1D)
|
||||
* 修复硬随机不可用时,地址随机化不可用问题 ([665c152](https://gitee.com/openharmony/kernel_liteos_a/commits/665c152c27bb86395ddd0395279255f6cdaf7255)), closes [#I4D4TK](https://gitee.com/openharmony/kernel_liteos_a/issues/I4D4TK)
|
||||
* 修复进程用例导致门禁概率失败 ([1ed28b4](https://gitee.com/openharmony/kernel_liteos_a/commits/1ed28b4c80cfd222be08b0c2e71e6287e52bb276)), closes [#I4FO0N](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FO0N)
|
||||
* 修复进程线程不稳定用例 ([f6ac03d](https://gitee.com/openharmony/kernel_liteos_a/commits/f6ac03d3e3c56236adc5734d4c059f1fbcc9e0c1)), closes [#I4F1XL](https://gitee.com/openharmony/kernel_liteos_a/issues/I4F1XL)
|
||||
* 修复重复执行内存用例导致系统卡死问题 ([6c2b163](https://gitee.com/openharmony/kernel_liteos_a/commits/6c2b163c7d7c696ef89b17a0275f3cddb3d7cefb)), closes [#I4F7PO](https://gitee.com/openharmony/kernel_liteos_a/issues/I4F7PO)
|
||||
* 修改MMU模块的注释错误 ([1a8e22d](https://gitee.com/openharmony/kernel_liteos_a/commits/1a8e22dcf15944153e013d004fd7bbf24557a8c7)), closes [#I4KMMJ](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KMMJ)
|
||||
* 共享内存问题修复 ([9fdb80f](https://gitee.com/openharmony/kernel_liteos_a/commits/9fdb80f85f92d0167a0456455a94fc6f679797ce)), closes [#I47X2Z](https://gitee.com/openharmony/kernel_liteos_a/issues/I47X2Z)
|
||||
* 内核ERR打印,无进程和线程信息,不方便问题定位。 ([cb423f8](https://gitee.com/openharmony/kernel_liteos_a/commits/cb423f845462b8cc474c3cba261dadf3943a08ef)), closes [#I4DAKM](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DAKM)
|
||||
* 内核ERR级别及以上的打印输出当前进程和线程名 ([540b201](https://gitee.com/openharmony/kernel_liteos_a/commits/540b2017c5460e300365d2039a08abd5945cec6b))
|
||||
* 内源检视测试用例问题修复 ([a6ac759](https://gitee.com/openharmony/kernel_liteos_a/commits/a6ac7597f85043ba6de3a1b395ca676d85c65ea7))
|
||||
* 删除冗余的头文件 ([8e614bb](https://gitee.com/openharmony/kernel_liteos_a/commits/8e614bb1616b75bc89eee7ad7da49b7a9c285b47)), closes [#I4KN63](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KN63)
|
||||
* 增加pselect SYSCALL函数及测试用例 ([f601c16](https://gitee.com/openharmony/kernel_liteos_a/commits/f601c16b9e67d531dda51fc18389a53db4360b7b)), closes [#I45](https://gitee.com/openharmony/kernel_liteos_a/issues/I45)
|
||||
* 增加内核epoll系统调用 ([2251b8a](https://gitee.com/openharmony/kernel_liteos_a/commits/2251b8a2d1f649422dd67f8551b085a7e0c63ec7)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 实现了musl库net模块中的一些函数接口和相应的测试用例 ([3d00a7d](https://gitee.com/openharmony/kernel_liteos_a/commits/3d00a7d23a96f29c138cfc1672825b90b9e0c05e)), closes [#I4JQI1](https://gitee.com/openharmony/kernel_liteos_a/issues/I4JQI1)
|
||||
* 添加进程线程冒烟用例 ([2be5968](https://gitee.com/openharmony/kernel_liteos_a/commits/2be59680f2fb0801b43522cd38cc387c8ff38766)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 用户态进程主线程退出时,其他子线程刚好进入异常处理流程会导致系统卡死 ([d955790](https://gitee.com/openharmony/kernel_liteos_a/commits/d955790a44a679421798ec1ac2900b4d75dd75a4)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 增加pselect SYSCALL函数及测试用例 ([f601c16](https://gitee.com/openharmony/kernel_liteos_a/commits/f601c16b9e67d531dda51fc18389a53db4360b7b)), closes [#I45SXU](https://gitee.com/openharmony/kernel_liteos_a/issues/I45SXU)
|
||||
* 增加内核epoll系统调用 ([2251b8a](https://gitee.com/openharmony/kernel_liteos_a/commits/2251b8a2d1f649422dd67f8551b085a7e0c63ec7)), closes [#I4FXPT](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FXPT)
|
||||
* 实现了musl库net模块中的一些函数接口和相应的测试用例 ([3d00a7d](https://gitee.com/openharmony/kernel_liteos_a/commits/3d00a7d23a96f29c138cfc1672825b90b9e0c05e)), closes [#I4JQI1](https://gitee.com/openharmony/third_party_musl/issues/I4JQI1)
|
||||
* 添加进程线程冒烟用例 ([2be5968](https://gitee.com/openharmony/kernel_liteos_a/commits/2be59680f2fb0801b43522cd38cc387c8ff38766)), closes [#I4EOGA](https://gitee.com/openharmony/kernel_liteos_a/issues/I4EOGA)
|
||||
* 用户态进程主线程退出时,其他子线程刚好进入异常处理流程会导致系统卡死 ([d955790](https://gitee.com/openharmony/kernel_liteos_a/commits/d955790a44a679421798ec1ac2900b4d75dd75a4)), closes [#I4KGBT](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KGBT)
|
||||
* 编码规范修改 ([d161a0b](https://gitee.com/openharmony/kernel_liteos_a/commits/d161a0b03de046c05fff45a2b625631b4e45a347))
|
||||
* 编码规范问题修复 ([f60bc94](https://gitee.com/openharmony/kernel_liteos_a/commits/f60bc94cf231bc615ff6603ca0393b8fe33a8c47))
|
||||
* 编译框架在做编译入口的统一 ([bdb9864](https://gitee.com/openharmony/kernel_liteos_a/commits/bdb9864436a6f128a4c3891bbd63e3c60352689f)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 解决dmesg -s参数double lock问题 ([e151256](https://gitee.com/openharmony/kernel_liteos_a/commits/e1512566e322eb1fbc8f5d5997f9bfcd022feac7)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 进程退出前自己回收vmspace中的所有region ([298ccea](https://gitee.com/openharmony/kernel_liteos_a/commits/298ccea3fedaccc651b38973f0455fa1ce12e516)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 编译框架在做编译入口的统一 ([bdb9864](https://gitee.com/openharmony/kernel_liteos_a/commits/bdb9864436a6f128a4c3891bbd63e3c60352689f)), closes [#I4KRQN](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KRQN)
|
||||
* 解决dmesg -s参数double lock问题 ([e151256](https://gitee.com/openharmony/kernel_liteos_a/commits/e1512566e322eb1fbc8f5d5997f9bfcd022feac7)), closes [#I4HIJK](https://gitee.com/openharmony/kernel_liteos_a/issues/I4HIJK)
|
||||
* 进程退出前自己回收vmspace中的所有region ([298ccea](https://gitee.com/openharmony/kernel_liteos_a/commits/298ccea3fedaccc651b38973f0455fa1ce12e516)), closes [#I4CKQC](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CKQC)
|
||||
* 通过g_uart_fputc_en关闭打印后,shell进程不能正常启动 ([d21b05c](https://gitee.com/openharmony/kernel_liteos_a/commits/d21b05c0f69877130366ad37b852a0f30c11809d)), closes [#I4CTY2](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CTY2)
|
||||
* 针对pr是否同步至release分支,增加原因说明规则 ([b37a7b7](https://gitee.com/openharmony/kernel_liteos_a/commits/b37a7b79292d93dae6c4914952b5f3bb509e8721))
|
||||
* 非当前进程销毁时,销毁liteipc时错误的销毁了当前进程的liteipc资源 ([0f0e85b](https://gitee.com/openharmony/kernel_liteos_a/commits/0f0e85b7a6bf76d540925fbf661c483c8dba1cba)), closes [#I4FSA7](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FSA7)
|
||||
@@ -79,22 +79,22 @@
|
||||
### Features
|
||||
|
||||
|
||||
* add option SIOCGIFBRDADDR for ioctl ([4ecc473](https://gitee.com/openharmony/kernel_liteos_a/commits/4ecc473843207d259613d26b8ee176d75e7f00fd)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* add sync() to vfs ([f67c4da](https://gitee.com/openharmony/kernel_liteos_a/commits/f67c4dae5141914df2e069dce0196b14780649d8)), closes [#I480](https://gitee.com/openharmony/kernel_liteos_a/issues/I480)
|
||||
* add option SIOCGIFBRDADDR for ioctl ([4ecc473](https://gitee.com/openharmony/kernel_liteos_a/commits/4ecc473843207d259613d26b8ee176d75e7f00fd)), closes [#I4DNRF](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DNRF)
|
||||
* add sync() to vfs ([f67c4da](https://gitee.com/openharmony/kernel_liteos_a/commits/f67c4dae5141914df2e069dce0196b14780649d8)), closes [#I480HV](https://gitee.com/openharmony/kernel_liteos_a/issues/I480HV)
|
||||
* **build:** support gcc toolchain ([6e886d4](https://gitee.com/openharmony/kernel_liteos_a/commits/6e886d4233dec3b82a27642f174b920e5f98f6aa))
|
||||
* L0-L1 支持Perf ([6e0a3f1](https://gitee.com/openharmony/kernel_liteos_a/commits/6e0a3f10bbbfe29d110c050da927684b6d77b961)), closes [#I47I9](https://gitee.com/openharmony/kernel_liteos_a/issues/I47I9)
|
||||
* L0~L1 支持Lms ([e748fdb](https://gitee.com/openharmony/kernel_liteos_a/commits/e748fdbe578a1ddd8eb10b2e207042676231ba26)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* liteipc 静态内存优化 ([5237924](https://gitee.com/openharmony/kernel_liteos_a/commits/52379242c109e0cf442784dbe811ff9d42d5f33a)), closes [#I4G4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4G4)
|
||||
* page cache backed by vnode instead of filep ([38a6b80](https://gitee.com/openharmony/kernel_liteos_a/commits/38a6b804e9291d2fdbd189825ebd7d56165ec51c)), closes [#I44](https://gitee.com/openharmony/kernel_liteos_a/issues/I44)
|
||||
* L0-L1 支持Perf ([6e0a3f1](https://gitee.com/openharmony/kernel_liteos_a/commits/6e0a3f10bbbfe29d110c050da927684b6d77b961)), closes [#I47I9A](https://gitee.com/openharmony/kernel_liteos_a/issues/I47I9A)
|
||||
* L0~L1 支持Lms ([e748fdb](https://gitee.com/openharmony/kernel_liteos_a/commits/e748fdbe578a1ddd8eb10b2e207042676231ba26)), closes [#I4HYAV](https://gitee.com/openharmony/kernel_liteos_a/issues/I4HYAV)
|
||||
* liteipc 静态内存优化 ([5237924](https://gitee.com/openharmony/kernel_liteos_a/commits/52379242c109e0cf442784dbe811ff9d42d5f33a)), closes [#I4G4HP](https://gitee.com/openharmony/kernel_liteos_a/issues/I4G4HP)
|
||||
* page cache backed by vnode instead of filep ([38a6b80](https://gitee.com/openharmony/kernel_liteos_a/commits/38a6b804e9291d2fdbd189825ebd7d56165ec51c)), closes [#I44TBS](https://gitee.com/openharmony/kernel_liteos_a/issues/I44TBS)
|
||||
* 提供低功耗默认处理框架 ([212d1bd](https://gitee.com/openharmony/kernel_liteos_a/commits/212d1bd1e806530fe7e7a16ea986cb2c6fb084ed)), closes [#I4KBG9](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KBG9)
|
||||
* 支持AT_RANDOM以增强用户态栈保护能力 ([06ea037](https://gitee.com/openharmony/kernel_liteos_a/commits/06ea03715f0cfb8728fadd0d9c19a403dc8f6028)), closes [#I4CB8](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CB8)
|
||||
* 支持L1 低功耗框架 ([64e49ab](https://gitee.com/openharmony/kernel_liteos_a/commits/64e49aba7c9c7d2280c5b3f29f04b17b63209855)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 支持LOS_TaskJoin 和 LOS_TaskDetach ([37bc11f](https://gitee.com/openharmony/kernel_liteos_a/commits/37bc11fa8837a3019a0a56702f401ec1845f6547)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 新增解析异常和backtrace信息脚本 ([7019fdf](https://gitee.com/openharmony/kernel_liteos_a/commits/7019fdfcbb33c660e8aa9fd399d5fccbd7e23b49)), closes [#I47](https://gitee.com/openharmony/kernel_liteos_a/issues/I47)
|
||||
* 支持AT_RANDOM以增强用户态栈保护能力 ([06ea037](https://gitee.com/openharmony/kernel_liteos_a/commits/06ea03715f0cfb8728fadd0d9c19a403dc8f6028)), closes [#I4CB8M](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CB8M)
|
||||
* 支持L1 低功耗框架 ([64e49ab](https://gitee.com/openharmony/kernel_liteos_a/commits/64e49aba7c9c7d2280c5b3f29f04b17b63209855)), closes [#I4JSOT](https://gitee.com/openharmony/kernel_liteos_a/issues/I4JSOT)
|
||||
* 支持LOS_TaskJoin 和 LOS_TaskDetach ([37bc11f](https://gitee.com/openharmony/kernel_liteos_a/commits/37bc11fa8837a3019a0a56702f401ec1845f6547)), closes [#I4EENF](https://gitee.com/openharmony/kernel_liteos_a/issues/I4EENF)
|
||||
* 新增解析异常和backtrace信息脚本 ([7019fdf](https://gitee.com/openharmony/kernel_liteos_a/commits/7019fdfcbb33c660e8aa9fd399d5fccbd7e23b49)), closes [#I47EVQ](https://gitee.com/openharmony/kernel_liteos_a/issues/I47EVQ)
|
||||
* 调度tick响应时间计算优化 ([f47da44](https://gitee.com/openharmony/kernel_liteos_a/commits/f47da44b39be7fa3e9b5031d7b79b9bef1fd4fbc))
|
||||
* 调度去进程化,优化进程线程依赖关系 ([dc479fb](https://gitee.com/openharmony/kernel_liteos_a/commits/dc479fb7bd9cb8441e4e47d44b42110ea07d76a2))
|
||||
* 调度相关模块间依赖优化 ([0e3936c](https://gitee.com/openharmony/kernel_liteos_a/commits/0e3936c4f8b8bcfc48d283a6d53413e0fc0619b3)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 进程cpup占用率结构优化为动态分配 ([f06e090](https://gitee.com/openharmony/kernel_liteos_a/commits/f06e090a1085a654fd726fbc3c3a1c2bc703d663)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_a/issues/I4)
|
||||
* 调度相关模块间依赖优化 ([0e3936c](https://gitee.com/openharmony/kernel_liteos_a/commits/0e3936c4f8b8bcfc48d283a6d53413e0fc0619b3)), closes [#I4RPRW](https://gitee.com/openharmony/kernel_liteos_a/issues/I4RPRW)
|
||||
* 进程cpup占用率结构优化为动态分配 ([f06e090](https://gitee.com/openharmony/kernel_liteos_a/commits/f06e090a1085a654fd726fbc3c3a1c2bc703d663)), closes [#I4GLNT](https://gitee.com/openharmony/kernel_liteos_a/issues/I4GLNT)
|
||||
* 进程rlimit修改为动态分配,减少静态内存占用 ([cf8446c](https://gitee.com/openharmony/kernel_liteos_a/commits/cf8446c94112ed6993a2e6e71e793d83a72689d5)), closes [#I4EZY5](https://gitee.com/openharmony/kernel_liteos_a/issues/I4EZY5)
|
||||
|
||||
### BREAKING CHANGES
|
||||
@@ -137,33 +137,33 @@ LOS_LmsAddrDisableProtect去能指定内存段的访问保护
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* A核代码告警清零 ([698756d](https://gitee.com/openharmony/kernel_liteos_a/commits/698756d1e6dfb11b9f874c02ce6a1496646f2c27)), closes [#I4378](https://gitee.com/openharmony/kernel_liteos_a/issues/I4378)
|
||||
* A核代码告警清零 ([698756d](https://gitee.com/openharmony/kernel_liteos_a/commits/698756d1e6dfb11b9f874c02ce6a1496646f2c27)), closes [#I4378T](https://gitee.com/openharmony/kernel_liteos_a/issues/I4378T)
|
||||
* A核告警消除 ([d16bfd0](https://gitee.com/openharmony/kernel_liteos_a/commits/d16bfd005a6dae78df2df3ad55cf21e0716dfae9)), closes [#I46KF6](https://gitee.com/openharmony/kernel_liteos_a/issues/I46KF6)
|
||||
* 3518平台, 异常测试进程无法正常退出 ([23937a2](https://gitee.com/openharmony/kernel_liteos_a/commits/23937a239f50d1487e89f3184e4f4b933d6842c6)), closes [#I3V8R5](https://gitee.com/openharmony/kernel_liteos_a/issues/I3V8R5)
|
||||
* add (void) to GetFileMappingList method ([56b8eca](https://gitee.com/openharmony/kernel_liteos_a/commits/56b8ecaf171671c0fe97f1dd1f191bebb7812a51)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* add (void) to GetFileMappingList method ([56b8eca](https://gitee.com/openharmony/kernel_liteos_a/commits/56b8ecaf171671c0fe97f1dd1f191bebb7812a51)), closes [#I3XPXY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XPXY)
|
||||
* add capability and amend smoke testcase ([c9d69e2](https://gitee.com/openharmony/kernel_liteos_a/commits/c9d69e2d1bde57c67068cc36f6a79327d5db5daf))
|
||||
* add fchdir api ([e828cbd](https://gitee.com/openharmony/kernel_liteos_a/commits/e828cbdeac7d60bfd6ed98c75a9958ee8ec7b672))
|
||||
* add fchmod api ([2f214bf](https://gitee.com/openharmony/kernel_liteos_a/commits/2f214bf4de6c31875c77e84b1763e96bc5ceb669))
|
||||
* add fststfs api and unitest ([4c57aa2](https://gitee.com/openharmony/kernel_liteos_a/commits/4c57aa26ad3644ce2429effc8e8fe7fd3c52ebc2))
|
||||
* add product_path parameter for driver build ([88fe4eb](https://gitee.com/openharmony/kernel_liteos_a/commits/88fe4eb3e1eafa6d1e32c7b96579a07f5a8c6e35)), closes [#I3PQ10](https://gitee.com/openharmony/kernel_liteos_a/issues/I3PQ10)
|
||||
* add product_path parameter for driver build ([88fe4eb](https://gitee.com/openharmony/kernel_liteos_a/commits/88fe4eb3e1eafa6d1e32c7b96579a07f5a8c6e35)), closes [#I3PQ10](https://gitee.com/openharmony/drivers_adapter/issues/I3PQ10)
|
||||
* add syscall for ppoll & add 2 testcases ([defedb6](https://gitee.com/openharmony/kernel_liteos_a/commits/defedb6fdf0806da4a39e22408544cdfb405f2ff))
|
||||
* avoid compile warning ignored ([eca711b](https://gitee.com/openharmony/kernel_liteos_a/commits/eca711bb64a7c806ae34c8483cac73fe22b0104f)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* A核codex修改 ([ec977a1](https://gitee.com/openharmony/kernel_liteos_a/commits/ec977a1c7e9ba4ea6621ceb1d0d10e586148208d)), closes [#I40B1](https://gitee.com/openharmony/kernel_liteos_a/issues/I40B1)
|
||||
* BBOX使用预留物理内存缓存故障日志 ([2ad176e](https://gitee.com/openharmony/kernel_liteos_a/commits/2ad176e587d5ed7106831a25d386a88e26192e2b)), closes [#I41](https://gitee.com/openharmony/kernel_liteos_a/issues/I41)
|
||||
* avoid compile warning ignored ([eca711b](https://gitee.com/openharmony/kernel_liteos_a/commits/eca711bb64a7c806ae34c8483cac73fe22b0104f)), closes [#I3VOAO](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VOAO)
|
||||
* A核codex修改 ([ec977a1](https://gitee.com/openharmony/kernel_liteos_a/commits/ec977a1c7e9ba4ea6621ceb1d0d10e586148208d)), closes [#I40B1S](https://gitee.com/openharmony/kernel_liteos_a/issues/I40B1S)
|
||||
* BBOX使用预留物理内存缓存故障日志 ([2ad176e](https://gitee.com/openharmony/kernel_liteos_a/commits/2ad176e587d5ed7106831a25d386a88e26192e2b)), closes [#I41YIZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I41YIZ)
|
||||
* bootargs解析与rootfs挂载解耦,并支持自定义bootargs参数 ([80473f0](https://gitee.com/openharmony/kernel_liteos_a/commits/80473f0975fe6fd4c4eae3a8a473674ad2dd1293)), closes [#I41CL8](https://gitee.com/openharmony/kernel_liteos_a/issues/I41CL8)
|
||||
* **build:** clang10.0.1支持lto,去掉冗余判断 ([73223ae](https://gitee.com/openharmony/kernel_liteos_a/commits/73223ae7e652b7cd9f1e1848c32b2b2573d07b2a))
|
||||
* **build:** fix rootfsdir.sh target directory not exist ([21bf2b8](https://gitee.com/openharmony/kernel_liteos_a/commits/21bf2b889931787fb18ca7ea238291fd57e76d51)), closes [#I3NHQ0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NHQ0)
|
||||
* **build:** 去除冗余单板相关的宏配置 ([471de36](https://gitee.com/openharmony/kernel_liteos_a/commits/471de3663ea8b63f7448162edc0293b8723dcefc))
|
||||
* clang10 lld could not recognized Oz ([87a0006](https://gitee.com/openharmony/kernel_liteos_a/commits/87a0006d5e1976fdf5efe4be383921610eb04ec6))
|
||||
* clang相关编译选项隔离 ([77dcef4](https://gitee.com/openharmony/kernel_liteos_a/commits/77dcef4bc0c92d0141f7a3be0addd4d5cb533b0b)), closes [#I444](https://gitee.com/openharmony/kernel_liteos_a/issues/I444)
|
||||
* clang相关编译选项隔离 ([77dcef4](https://gitee.com/openharmony/kernel_liteos_a/commits/77dcef4bc0c92d0141f7a3be0addd4d5cb533b0b)), closes [#I444AV](https://gitee.com/openharmony/kernel_liteos_a/issues/I444AV)
|
||||
* codex ([101a55d](https://gitee.com/openharmony/kernel_liteos_a/commits/101a55d1199530d621f809976f0024aa8295cce8))
|
||||
* codex clean ([b5370af](https://gitee.com/openharmony/kernel_liteos_a/commits/b5370af822c8e81ed2248ac8aa3bb479a0db9dae)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* codex clean ([b5370af](https://gitee.com/openharmony/kernel_liteos_a/commits/b5370af822c8e81ed2248ac8aa3bb479a0db9dae)), closes [#I3UOFN](https://gitee.com/openharmony/kernel_liteos_a/issues/I3UOFN)
|
||||
* compile error when fatfs disabled ([fd3f407](https://gitee.com/openharmony/kernel_liteos_a/commits/fd3f4072b5c3dff710013ccdaddf114b0e13f435))
|
||||
* console compile bug fix ([f8441a0](https://gitee.com/openharmony/kernel_liteos_a/commits/f8441a0cdea301449416b0c0477dc48a05b6ab4e))
|
||||
* correct spelling ([c66fe03](https://gitee.com/openharmony/kernel_liteos_a/commits/c66fe0313f76ba41992b4864c93cf82934378ad3))
|
||||
* Correctly handle the return value of LOS_EventRead in QuickstartListen. ([0e0ab81](https://gitee.com/openharmony/kernel_liteos_a/commits/0e0ab81ff9474cffd5e60a8ee741840eac5d737b)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* Correctly handle the return value of LOS_EventRead in QuickstartListen. ([0e0ab81](https://gitee.com/openharmony/kernel_liteos_a/commits/0e0ab81ff9474cffd5e60a8ee741840eac5d737b)), closes [#I3PSLZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I3PSLZ)
|
||||
* Ctrl-C move out of LOS_MAGIC_KEY_ENABLE ([40f239a](https://gitee.com/openharmony/kernel_liteos_a/commits/40f239a7d4673dc740c853b1011b5072e48385b7))
|
||||
* Delete useless 'exc interaction' macros and function declarations. ([d2f2679](https://gitee.com/openharmony/kernel_liteos_a/commits/d2f26790716c9f76589c4a7d6fa5518f9ccd743c)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* Delete useless 'exc interaction' macros and function declarations. ([d2f2679](https://gitee.com/openharmony/kernel_liteos_a/commits/d2f26790716c9f76589c4a7d6fa5518f9ccd743c)), closes [#I3SDKY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SDKY)
|
||||
* dereference NULL point bug fix ([deaa564](https://gitee.com/openharmony/kernel_liteos_a/commits/deaa564a66b83c9fe19a37b8a061ec9064ece354))
|
||||
* do not build toybox temporarily ([044f2c7](https://gitee.com/openharmony/kernel_liteos_a/commits/044f2c7c17c68e10aeccc3af0c222cfc722d194c))
|
||||
* do not override existing libs ([8118408](https://gitee.com/openharmony/kernel_liteos_a/commits/8118408123e75f7f5a4ab9101e388be6bba0dcda))
|
||||
@@ -173,21 +173,21 @@ LOS_LmsAddrDisableProtect去能指定内存段的访问保护
|
||||
* Fix kernel page fault exception handling causing system exception. ([a89fb57](https://gitee.com/openharmony/kernel_liteos_a/commits/a89fb57f5795236b93fd19ee2d7a059cae1b2b1b)), closes [#I3RAN4](https://gitee.com/openharmony/kernel_liteos_a/issues/I3RAN4)
|
||||
* fix length typo ([12d98b1](https://gitee.com/openharmony/kernel_liteos_a/commits/12d98b144b70e726d3fd31ddc9d17ed855d0ec1b))
|
||||
* fix mq function by enable mq_notify api ([4427142](https://gitee.com/openharmony/kernel_liteos_a/commits/4427142d734df8f95f4599093392904abacc5c93))
|
||||
* Fix quickstart codingstyle ([2e011b6](https://gitee.com/openharmony/kernel_liteos_a/commits/2e011b672f6b96ea7e0db066a07e3f9fb6ba5df3)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* Fix quickstart codingstyle ([2e011b6](https://gitee.com/openharmony/kernel_liteos_a/commits/2e011b672f6b96ea7e0db066a07e3f9fb6ba5df3)), closes [#I3OPOM](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OPOM)
|
||||
* fix stored typo ([d25560f](https://gitee.com/openharmony/kernel_liteos_a/commits/d25560f8ac3216670d198cbbb25891c394e0b3c2))
|
||||
* fix syscall faccessat,fstatfs,fstatat & add 6 testcases ([aa1cd24](https://gitee.com/openharmony/kernel_liteos_a/commits/aa1cd245a5711e5b53c328b688da5ddc2e783d5f))
|
||||
* fix the inappropriate errno in FatFs ([af61187](https://gitee.com/openharmony/kernel_liteos_a/commits/af61187587411dca38ff62e720451f08f19c1c82)), closes [#I3O8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3O8)
|
||||
* fix the inappropriate errno in FatFs ([af61187](https://gitee.com/openharmony/kernel_liteos_a/commits/af61187587411dca38ff62e720451f08f19c1c82)), closes [#I3O8IF](https://gitee.com/openharmony/kernel_liteos_a/issues/I3O8IF)
|
||||
* fix typo in quickstart ([3b2ff4b](https://gitee.com/openharmony/kernel_liteos_a/commits/3b2ff4b71fc5ae1dc74180c33fd66f69da0059d1)), closes [#I3M1S8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3M1S8)
|
||||
* Fix wrong judgment in los_trace.c to avoid null pointer access. ([4d863e9](https://gitee.com/openharmony/kernel_liteos_a/commits/4d863e985b6372f7895db57b602b662dba5cadd0)), closes [#I3RT9](https://gitee.com/openharmony/kernel_liteos_a/issues/I3RT9)
|
||||
* Fix wrong judgment in los_trace.c to avoid null pointer access. ([4d863e9](https://gitee.com/openharmony/kernel_liteos_a/commits/4d863e985b6372f7895db57b602b662dba5cadd0)), closes [#I3RT9F](https://gitee.com/openharmony/kernel_liteos_a/issues/I3RT9F)
|
||||
* Identical condition 'ret<0', second condition is always false. :bug: ([1348809](https://gitee.com/openharmony/kernel_liteos_a/commits/1348809807548dd481286a55a6677a9169fcd705))
|
||||
* init进程收到子进程退出信号后,调用fork重新拉起进程,会导致系统卡死 ([35a2f3a](https://gitee.com/openharmony/kernel_liteos_a/commits/35a2f3af33a5dba1e0ba36587efced8fead97223)), closes [#I41](https://gitee.com/openharmony/kernel_liteos_a/issues/I41)
|
||||
* init进程收到子进程退出信号后,调用fork重新拉起进程,会导致系统卡死 ([35a2f3a](https://gitee.com/openharmony/kernel_liteos_a/commits/35a2f3af33a5dba1e0ba36587efced8fead97223)), closes [#I41HOY](https://gitee.com/openharmony/kernel_liteos_a/issues/I41HOY)
|
||||
* kernel crashed after rmdir the umounted folder ([ac0d083](https://gitee.com/openharmony/kernel_liteos_a/commits/ac0d083b1c89c4ad3fdaab0347d11f174d0185cb))
|
||||
* kernel crashed when delete a umounted folder ([f305d1f](https://gitee.com/openharmony/kernel_liteos_a/commits/f305d1f702a770010125a0f4f0152ffefeeec5c4))
|
||||
* kernel crashed when delete a umounted folder ([c6e9212](https://gitee.com/openharmony/kernel_liteos_a/commits/c6e921241b1cf26bcbfeea44e20f6b596512e259))
|
||||
* **kernel_test:** 内核mem/shm冒烟用例重复运行失败 ([0676578](https://gitee.com/openharmony/kernel_liteos_a/commits/0676578aae09c101d79e7a276823e849df293e29)), closes [#I3TH4](https://gitee.com/openharmony/kernel_liteos_a/issues/I3TH4)
|
||||
* L1 toybox 命令功能实现 ([2ff44c4](https://gitee.com/openharmony/kernel_liteos_a/commits/2ff44c4938d2e66ce60e9497c505eb6e97efc8c2)), closes [#I41N2](https://gitee.com/openharmony/kernel_liteos_a/issues/I41N2)
|
||||
* **kernel_test:** 内核mem/shm冒烟用例重复运行失败 ([0676578](https://gitee.com/openharmony/kernel_liteos_a/commits/0676578aae09c101d79e7a276823e849df293e29)), closes [#I3TH4W](https://gitee.com/openharmony/kernel_liteos_a/issues/I3TH4W)
|
||||
* L1 toybox 命令功能实现 ([2ff44c4](https://gitee.com/openharmony/kernel_liteos_a/commits/2ff44c4938d2e66ce60e9497c505eb6e97efc8c2)), closes [#I41N2A](https://gitee.com/openharmony/third_party_toybox/issues/I41N2A)
|
||||
* liteipc max data size too small ([4dc421e](https://gitee.com/openharmony/kernel_liteos_a/commits/4dc421e3decdaae60219d533c4a93dbc9334e35f))
|
||||
* LiteOS_A BBOX Codex整改 ([6a5a032](https://gitee.com/openharmony/kernel_liteos_a/commits/6a5a0326d2b18ffacce5d38fb351530973c2f245)), closes [#I43](https://gitee.com/openharmony/kernel_liteos_a/issues/I43)
|
||||
* LiteOS_A BBOX Codex整改 ([6a5a032](https://gitee.com/openharmony/kernel_liteos_a/commits/6a5a0326d2b18ffacce5d38fb351530973c2f245)), closes [#I43RQU](https://gitee.com/openharmony/kernel_liteos_a/issues/I43RQU)
|
||||
* Liteos-a创建的文件夹在Ubuntu中不可见 ([a9fc1e0](https://gitee.com/openharmony/kernel_liteos_a/commits/a9fc1e0e5d3e5eb8a34c568a8d147320a9afebe1)), closes [#I3XMY6](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XMY6)
|
||||
* lookup new vnode may cause parent vnode freeing ([902a11d](https://gitee.com/openharmony/kernel_liteos_a/commits/902a11de9a4b08e799820fb87942cb2171b9e095)), closes [#I3MYP4](https://gitee.com/openharmony/kernel_liteos_a/issues/I3MYP4)
|
||||
* **mini:** fix compile error in mini liteos_a ([e13cb3b](https://gitee.com/openharmony/kernel_liteos_a/commits/e13cb3bcc4e74d4c49c31d290d686f99a4e81e3f))
|
||||
@@ -196,117 +196,117 @@ LOS_LmsAddrDisableProtect去能指定内存段的访问保护
|
||||
* mkdir -p is more robust ([e38f9a9](https://gitee.com/openharmony/kernel_liteos_a/commits/e38f9a98c9d373db8381af707c5996d1fefef64e))
|
||||
* mksh compile bug fix ([d8263b1](https://gitee.com/openharmony/kernel_liteos_a/commits/d8263b1e91d76706d52df321ef642c1c8297e8e4)), closes [#I3ZMR7](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZMR7)
|
||||
* modify event API description ([937734b](https://gitee.com/openharmony/kernel_liteos_a/commits/937734b1e9f5fc52e0ac727549bd2e4b4c864e3c))
|
||||
* move nuttx head file back ([4c8a86e](https://gitee.com/openharmony/kernel_liteos_a/commits/4c8a86ece7cafa8f74441bacc74c7788c0a1b780)), closes [#I4443](https://gitee.com/openharmony/kernel_liteos_a/issues/I4443)
|
||||
* nanosleep 接口的rmtp参数被错误清零 ([9458de9](https://gitee.com/openharmony/kernel_liteos_a/commits/9458de9ac664cd75540c8b638b9a6caf82812fc8)), closes [#I41U0](https://gitee.com/openharmony/kernel_liteos_a/issues/I41U0)
|
||||
* move nuttx head file back ([4c8a86e](https://gitee.com/openharmony/kernel_liteos_a/commits/4c8a86ece7cafa8f74441bacc74c7788c0a1b780)), closes [#I4443Q](https://gitee.com/openharmony/kernel_liteos_a/issues/I4443Q)
|
||||
* nanosleep 接口的rmtp参数被错误清零 ([9458de9](https://gitee.com/openharmony/kernel_liteos_a/commits/9458de9ac664cd75540c8b638b9a6caf82812fc8)), closes [#I41U0R](https://gitee.com/openharmony/kernel_liteos_a/issues/I41U0R)
|
||||
* no exception information output, when the system is abnormal ([5bf4d1c](https://gitee.com/openharmony/kernel_liteos_a/commits/5bf4d1c7128e6718611bbec23cb4373bcb3bfe55))
|
||||
* no exception information output, when the system is abnormal ([28aa777](https://gitee.com/openharmony/kernel_liteos_a/commits/28aa777191e7b41e4f1f346ab79f8688edc59c6d))
|
||||
* no exception information output, when the system is abnormal after holding ([0ed8adf](https://gitee.com/openharmony/kernel_liteos_a/commits/0ed8adfe3ae59672e284331d40ef3b9e0bc8e094))
|
||||
* Optimiz macro of quickstart cmd ([cb140a4](https://gitee.com/openharmony/kernel_liteos_a/commits/cb140a4442c02dd0b1925cc58deecbf4da36dcea)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* Optimize /dev/quickstart permissions. ([4e24b57](https://gitee.com/openharmony/kernel_liteos_a/commits/4e24b572897c33e1b2723122c0e13d3931096bae)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* Optimiz macro of quickstart cmd ([cb140a4](https://gitee.com/openharmony/kernel_liteos_a/commits/cb140a4442c02dd0b1925cc58deecbf4da36dcea)), closes [#I3OSYT](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OSYT)
|
||||
* Optimize /dev/quickstart permissions. ([4e24b57](https://gitee.com/openharmony/kernel_liteos_a/commits/4e24b572897c33e1b2723122c0e13d3931096bae)), closes [#I3OYUQ](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OYUQ)
|
||||
* Optimize quickstart node implementation ([4abd2e0](https://gitee.com/openharmony/kernel_liteos_a/commits/4abd2e0247b14718bb21756fb446142140d30a88)), closes [#I3R8O8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3R8O8)
|
||||
* OsGerCurrSchedTimeCycle 函数存在拼写错误 ([53ced1a](https://gitee.com/openharmony/kernel_liteos_a/commits/53ced1a85edc3d06230225ced3916772f432243f)), closes [#I446](https://gitee.com/openharmony/kernel_liteos_a/issues/I446)
|
||||
* OsGetArgsAddr声明所在头文件不正确 ([14bd753](https://gitee.com/openharmony/kernel_liteos_a/commits/14bd753aa8beb49af887c8d0aedaefa446409760)), closes [#I41](https://gitee.com/openharmony/kernel_liteos_a/issues/I41)
|
||||
* parent point of vnode found by VfsHashGet should be updated ([f32caa5](https://gitee.com/openharmony/kernel_liteos_a/commits/f32caa52c67eca20d58676be4e0439acbb4c5ac3)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* OsGerCurrSchedTimeCycle 函数存在拼写错误 ([53ced1a](https://gitee.com/openharmony/kernel_liteos_a/commits/53ced1a85edc3d06230225ced3916772f432243f)), closes [#I446CX](https://gitee.com/openharmony/kernel_liteos_a/issues/I446CX)
|
||||
* OsGetArgsAddr声明所在头文件不正确 ([14bd753](https://gitee.com/openharmony/kernel_liteos_a/commits/14bd753aa8beb49af887c8d0aedaefa446409760)), closes [#I41MWM](https://gitee.com/openharmony/kernel_liteos_a/issues/I41MWM)
|
||||
* parent point of vnode found by VfsHashGet should be updated ([f32caa5](https://gitee.com/openharmony/kernel_liteos_a/commits/f32caa52c67eca20d58676be4e0439acbb4c5ac3)), closes [#I3NNFA](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NNFA)
|
||||
* PathCacheFree try to free name field in struct PathCache ([9f47faf](https://gitee.com/openharmony/kernel_liteos_a/commits/9f47faff732609cf2249f104b94ed55f3ef133bb)), closes [#I3NTH9](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NTH9)
|
||||
* PathCacheMemoryDump miscalculate the RAM usage of PathCache ([87da7c7](https://gitee.com/openharmony/kernel_liteos_a/commits/87da7c794c9bc8e311ae5242820fbf8aefd8d558)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* PathCacheMemoryDump miscalculate the RAM usage of PathCache ([87da7c7](https://gitee.com/openharmony/kernel_liteos_a/commits/87da7c794c9bc8e311ae5242820fbf8aefd8d558)), closes [#I3OBXY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OBXY)
|
||||
* Provide a separate configuration macro for boot environment in RAM. ([e28e06b](https://gitee.com/openharmony/kernel_liteos_a/commits/e28e06b08f5b28091153e584cb9d93014a9f2b10))
|
||||
* Provide a separate configuration macro for boot environment in RAM. ([bc67393](https://gitee.com/openharmony/kernel_liteos_a/commits/bc67393a67f714e0a8165b6103e53699c676341c))
|
||||
* Provide a separate configuration macro for boot environment in RAM. ([f13b90e](https://gitee.com/openharmony/kernel_liteos_a/commits/f13b90e4308ba3d60683799b9ce62fb3705ac277)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* race condition in liteipc ([7e2aef2](https://gitee.com/openharmony/kernel_liteos_a/commits/7e2aef2480b15f71ee0e089cef4443f578e03dbb)), closes [#I3PW5](https://gitee.com/openharmony/kernel_liteos_a/issues/I3PW5)
|
||||
* Provide a separate configuration macro for boot environment in RAM. ([f13b90e](https://gitee.com/openharmony/kernel_liteos_a/commits/f13b90e4308ba3d60683799b9ce62fb3705ac277)), closes [#I3OADR](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OADR)
|
||||
* race condition in liteipc ([7e2aef2](https://gitee.com/openharmony/kernel_liteos_a/commits/7e2aef2480b15f71ee0e089cef4443f578e03dbb)), closes [#I3PW5Y](https://gitee.com/openharmony/kernel_liteos_a/issues/I3PW5Y)
|
||||
* rebuild mksh depends on rebuild.sh script ([bef4ab9](https://gitee.com/openharmony/kernel_liteos_a/commits/bef4ab9835dec865898c74337dfb7154718b94aa))
|
||||
* remove redundant headfile ([73a7777](https://gitee.com/openharmony/kernel_liteos_a/commits/73a777777e1b834192f6bb2c0e8bd03c69765c11)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* Remove redundant invalid codes ([fe05df4](https://gitee.com/openharmony/kernel_liteos_a/commits/fe05df40ae710632adb1bd54fb04ad4a8e0c1429)), closes [#I3R70](https://gitee.com/openharmony/kernel_liteos_a/issues/I3R70)
|
||||
* Show conflicting files for git apply or patch -p command ([35f7957](https://gitee.com/openharmony/kernel_liteos_a/commits/35f79579758644cbcac6005f894be21f34f42b99)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* remove redundant headfile ([73a7777](https://gitee.com/openharmony/kernel_liteos_a/commits/73a777777e1b834192f6bb2c0e8bd03c69765c11)), closes [#I3RTNR](https://gitee.com/openharmony/kernel_liteos_a/issues/I3RTNR)
|
||||
* Remove redundant invalid codes ([fe05df4](https://gitee.com/openharmony/kernel_liteos_a/commits/fe05df40ae710632adb1bd54fb04ad4a8e0c1429)), closes [#I3R70T](https://gitee.com/openharmony/kernel_liteos_a/issues/I3R70T)
|
||||
* Show conflicting files for git apply or patch -p command ([35f7957](https://gitee.com/openharmony/kernel_liteos_a/commits/35f79579758644cbcac6005f894be21f34f42b99)), closes [#I3NNUS](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NNUS)
|
||||
* SIOCGIFCONF ioctl malloc size error in kernel ([bfd27e7](https://gitee.com/openharmony/kernel_liteos_a/commits/bfd27e78b259eedbd4c30548e80c9b4d789d26e1)), closes [#I3XEZ3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XEZ3)
|
||||
* smp启动代码解耦及内存映射关系解耦 ([3bb3173](https://gitee.com/openharmony/kernel_liteos_a/commits/3bb3173604dc4dea09301f61da402974185dc112)), closes [#I41P8](https://gitee.com/openharmony/kernel_liteos_a/issues/I41P8)
|
||||
* some branch in format does not release the vnode mutex properly ([9b2b700](https://gitee.com/openharmony/kernel_liteos_a/commits/9b2b700fa0e3a8edadb38f09c917a3e3f013347f)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* smp启动代码解耦及内存映射关系解耦 ([3bb3173](https://gitee.com/openharmony/kernel_liteos_a/commits/3bb3173604dc4dea09301f61da402974185dc112)), closes [#I41P8Y](https://gitee.com/openharmony/kernel_liteos_a/issues/I41P8Y)
|
||||
* some branch in format does not release the vnode mutex properly ([9b2b700](https://gitee.com/openharmony/kernel_liteos_a/commits/9b2b700fa0e3a8edadb38f09c917a3e3f013347f)), closes [#I3OFAY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OFAY)
|
||||
* Sortlink, the response time to insert the node should be inserted into the back of the existing node. ([1323874](https://gitee.com/openharmony/kernel_liteos_a/commits/1323874389030c55fb053fead12ca1c6654d8851)), closes [#I3PSJ8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3PSJ8)
|
||||
* statfs can't get f_bfree and f_bavail of a FAT12/FAT16 partition ([9503c4a](https://gitee.com/openharmony/kernel_liteos_a/commits/9503c4a9fc30aaa8ea2031d4fb794436f3c98055)), closes [#I3Q0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Q0)
|
||||
* SysOpenat返回值应该为进程fd,而非系统全局fd。 ([3457c0b](https://gitee.com/openharmony/kernel_liteos_a/commits/3457c0b11debb2cf5d4abe325c2510a750654512)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* the total used vnode number not increased after unlink a file under ([4f514a1](https://gitee.com/openharmony/kernel_liteos_a/commits/4f514a16af5a3f3b9c4ea182de774297afb17f66)), closes [#I3TS1](https://gitee.com/openharmony/kernel_liteos_a/issues/I3TS1)
|
||||
* tick 动态化计算优化,消除中断执行时间对系统总体时间的影响,保证软件定时器的响应精度。 ([8df3e8c](https://gitee.com/openharmony/kernel_liteos_a/commits/8df3e8c96515a1907455a9bbc61426f43c803c62)), closes [#I43](https://gitee.com/openharmony/kernel_liteos_a/issues/I43)
|
||||
* statfs can't get f_bfree and f_bavail of a FAT12/FAT16 partition ([9503c4a](https://gitee.com/openharmony/kernel_liteos_a/commits/9503c4a9fc30aaa8ea2031d4fb794436f3c98055)), closes [#I3Q0VS](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Q0VS)
|
||||
* SysOpenat返回值应该为进程fd,而非系统全局fd。 ([3457c0b](https://gitee.com/openharmony/kernel_liteos_a/commits/3457c0b11debb2cf5d4abe325c2510a750654512)), closes [#I3TNAK](https://gitee.com/openharmony/kernel_liteos_a/issues/I3TNAK)
|
||||
* the total used vnode number not increased after unlink a file under ([4f514a1](https://gitee.com/openharmony/kernel_liteos_a/commits/4f514a16af5a3f3b9c4ea182de774297afb17f66)), closes [#I3TS1Y](https://gitee.com/openharmony/kernel_liteos_a/issues/I3TS1Y)
|
||||
* tick 动态化计算优化,消除中断执行时间对系统总体时间的影响,保证软件定时器的响应精度。 ([8df3e8c](https://gitee.com/openharmony/kernel_liteos_a/commits/8df3e8c96515a1907455a9bbc61426f43c803c62)), closes [#I43UQJ](https://gitee.com/openharmony/kernel_liteos_a/issues/I43UQJ)
|
||||
* toybox update ([c3245b3](https://gitee.com/openharmony/kernel_liteos_a/commits/c3245b3ce317eb58c8dad58fdfc7f094b9b9794b))
|
||||
* toybox命令升级 ([76f45b3](https://gitee.com/openharmony/kernel_liteos_a/commits/76f45b3fb2783d1cab45a6ba08787c29dfa2c948)), closes [#I41N2](https://gitee.com/openharmony/kernel_liteos_a/issues/I41N2)
|
||||
* toybox命令升级 ([76f45b3](https://gitee.com/openharmony/kernel_liteos_a/commits/76f45b3fb2783d1cab45a6ba08787c29dfa2c948)), closes [#I41N2A](https://gitee.com/openharmony/third_party_toybox/issues/I41N2A)
|
||||
* update LOS_DL_LIST_IS_END comment ([900269b](https://gitee.com/openharmony/kernel_liteos_a/commits/900269bd4645252d898f6d3b73de01d8548c960c))
|
||||
* userfs分区的起始地址与大小改为通过bootargs配置 ([2e2b142](https://gitee.com/openharmony/kernel_liteos_a/commits/2e2b14205f4b81c7483ab42d62f144487097e9a4)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* VnodeInUseIter and VnodeFreeAll used to be recursive ([5f6656c](https://gitee.com/openharmony/kernel_liteos_a/commits/5f6656cb36a2ffb0b290aeb53981aba7501e80b2)), closes [#I3NN3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NN3)
|
||||
* 以g_sysSchedStartTime是否为0判断时间轴是否生效存在极限场景导致调度时间不生效 ([67ac8c4](https://gitee.com/openharmony/kernel_liteos_a/commits/67ac8c4c586adc371ece56700fd42371ca7fc885)), closes [#I45HP5](https://gitee.com/openharmony/kernel_liteos_a/issues/I45HP5)
|
||||
* userfs分区的起始地址与大小改为通过bootargs配置 ([2e2b142](https://gitee.com/openharmony/kernel_liteos_a/commits/2e2b14205f4b81c7483ab42d62f144487097e9a4)), closes [#I3XNEY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XNEY)
|
||||
* VnodeInUseIter and VnodeFreeAll used to be recursive ([5f6656c](https://gitee.com/openharmony/kernel_liteos_a/commits/5f6656cb36a2ffb0b290aeb53981aba7501e80b2)), closes [#I3NN3U](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NN3U)
|
||||
* 以g_sysSchedStartTime是否为0判断时间轴是否生效存在极限场景导致调度时间不生效 ([67ac8c4](https://gitee.com/openharmony/kernel_liteos_a/commits/67ac8c4c586adc371ece56700fd42371ca7fc885)), closes [#I45HP5](https://gitee.com/openharmony/kernel_liteos_m/issues/I45HP5)
|
||||
* 修复FATFS中不同内部接口不支持FAT12/FAT16 FAT表结束标志 ([33f5c70](https://gitee.com/openharmony/kernel_liteos_a/commits/33f5c70e6c8781758d2bfde0f60ca3d6ec7d543f)), closes [#I409R6](https://gitee.com/openharmony/kernel_liteos_a/issues/I409R6)
|
||||
* 修复kill进程时,因liteipc阻塞的进程概率无法退出问题 ([7de43bb](https://gitee.com/openharmony/kernel_liteos_a/commits/7de43bb004a12f926550f0b36ca3c2fa610feb27)), closes [#I3XX7](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XX7)
|
||||
* 修复kill进程时,因liteipc阻塞的进程概率无法退出问题 ([7de43bb](https://gitee.com/openharmony/kernel_liteos_a/commits/7de43bb004a12f926550f0b36ca3c2fa610feb27)), closes [#I3XX7K](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XX7K)
|
||||
* 修复MagicKey数组越界访问 ([071cd62](https://gitee.com/openharmony/kernel_liteos_a/commits/071cd6268aeaaef702387dacaf4ef1ffbb7618fc)), closes [#I3U4N9](https://gitee.com/openharmony/kernel_liteos_a/issues/I3U4N9)
|
||||
* 修复mprotect修改地址区间的权限后,相应的区间名丢失问题 ([e425187](https://gitee.com/openharmony/kernel_liteos_a/commits/e425187d176a5e09bc5253faefc9cfc8454da0a3)), closes [#I43R40](https://gitee.com/openharmony/kernel_liteos_a/issues/I43R40)
|
||||
* 修复mq_close关闭后仍然占用文件描述符的问题 ([590c7b4](https://gitee.com/openharmony/kernel_liteos_a/commits/590c7b4e22662781d05ad035a785e985d573ec33)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* 修复mqueue问题 ([26ee8b8](https://gitee.com/openharmony/kernel_liteos_a/commits/26ee8b836e346e641de4ecd72284f5d377bca6f8)), closes [#I43P4](https://gitee.com/openharmony/kernel_liteos_a/issues/I43P4)
|
||||
* 修复sigwait等待到的信号值与获取的siginfo中的值不一致 ([ed7defb](https://gitee.com/openharmony/kernel_liteos_a/commits/ed7defbd439c345a07159d40eb04433afd530004)), closes [#I3M12](https://gitee.com/openharmony/kernel_liteos_a/issues/I3M12)
|
||||
* 修复了LOSCFG_FS_FAT_VIRTUAL_PARTITION宏开关错误作用域引起的功能错误 ([acda419](https://gitee.com/openharmony/kernel_liteos_a/commits/acda419a2d773ea890052a16ee66b4872f941fbb)), closes [#I3W1](https://gitee.com/openharmony/kernel_liteos_a/issues/I3W1)
|
||||
* 修复了内核的VFAT测试用例 ([a8384b5](https://gitee.com/openharmony/kernel_liteos_a/commits/a8384b5db2274d50a350910d7cfd3fc36b4f4103)), closes [#I3XF3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XF3)
|
||||
* 修复mq_close关闭后仍然占用文件描述符的问题 ([590c7b4](https://gitee.com/openharmony/kernel_liteos_a/commits/590c7b4e22662781d05ad035a785e985d573ec33)), closes [#I3ZQDA](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZQDA)
|
||||
* 修复mqueue问题 ([26ee8b8](https://gitee.com/openharmony/kernel_liteos_a/commits/26ee8b836e346e641de4ecd72284f5d377bca6f8)), closes [#I43P4T](https://gitee.com/openharmony/kernel_liteos_a/issues/I43P4T)
|
||||
* 修复sigwait等待到的信号值与获取的siginfo中的值不一致 ([ed7defb](https://gitee.com/openharmony/kernel_liteos_a/commits/ed7defbd439c345a07159d40eb04433afd530004)), closes [#I3M12H](https://gitee.com/openharmony/kernel_liteos_a/issues/I3M12H)
|
||||
* 修复了LOSCFG_FS_FAT_VIRTUAL_PARTITION宏开关错误作用域引起的功能错误 ([acda419](https://gitee.com/openharmony/kernel_liteos_a/commits/acda419a2d773ea890052a16ee66b4872f941fbb)), closes [#I3W1IW](https://gitee.com/openharmony/kernel_liteos_a/issues/I3W1IW)
|
||||
* 修复了内核的VFAT测试用例 ([a8384b5](https://gitee.com/openharmony/kernel_liteos_a/commits/a8384b5db2274d50a350910d7cfd3fc36b4f4103)), closes [#I3XF3R](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XF3R)
|
||||
* 修复内核access chmod chown接口 ([56a95b9](https://gitee.com/openharmony/kernel_liteos_a/commits/56a95b9ec903f815f9199ac65ca318e00a83b2ed)), closes [#I3Z5L6](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Z5L6)
|
||||
* 修复内核c库的makefile中被优化函数替换的高频函数依然参与了编译的问题 ([6f6dc4f](https://gitee.com/openharmony/kernel_liteos_a/commits/6f6dc4f24c8ab05a6d42da46a9fa41d74a477bd7)), closes [#I3XGM8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XGM8)
|
||||
* 修复内核堆完整性检查逻辑中访问非法指针导致系统异常问题。 ([30f5ab8](https://gitee.com/openharmony/kernel_liteos_a/commits/30f5ab89b72d45f596b15af82a8e8e01add7977d)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* 修复启动框架debug模式下-Werror=maybe-uninitialized告警以及符号链接不进镜像的隐患 ([4c02415](https://gitee.com/openharmony/kernel_liteos_a/commits/4c024159a9600745863e49ee955308470a5b657b)), closes [#I3T5](https://gitee.com/openharmony/kernel_liteos_a/issues/I3T5)
|
||||
* 修复内核堆完整性检查逻辑中访问非法指针导致系统异常问题。 ([30f5ab8](https://gitee.com/openharmony/kernel_liteos_a/commits/30f5ab89b72d45f596b15af82a8e8e01add7977d)), closes [#I3VJZT](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VJZT)
|
||||
* 修复启动框架debug模式下-Werror=maybe-uninitialized告警以及符号链接不进镜像的隐患 ([4c02415](https://gitee.com/openharmony/kernel_liteos_a/commits/4c024159a9600745863e49ee955308470a5b657b)), closes [#I3T5HR](https://gitee.com/openharmony/kernel_liteos_a/issues/I3T5HR)
|
||||
* 修复开机概率挂死 ([2e82c36](https://gitee.com/openharmony/kernel_liteos_a/commits/2e82c361f73b2119613c3571c48faae8ec41d4eb)), closes [#I3SWY2](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SWY2)
|
||||
* 修复文档链接失效问题 ([42a3a6c](https://gitee.com/openharmony/kernel_liteos_a/commits/42a3a6c51bfca4ade8ce94084ea2f8eb1c86a137)), closes [#I45297](https://gitee.com/openharmony/kernel_liteos_a/issues/I45297)
|
||||
* 修改/proc/mounts显示格式 ([6860246](https://gitee.com/openharmony/kernel_liteos_a/commits/6860246cfaac6f540665e79bbc4c3d54c419b092)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* 修改clock_gettime接口适配posix标准测试用例011输入clk_id错误时返回值ESRCH为EINVAL. ([f8cf6e6](https://gitee.com/openharmony/kernel_liteos_a/commits/f8cf6e6439ee017fe8e0d4ecfc9949c28fa6775f)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* 修改DoNanoSleep 以纳秒为单位 ([6917e08](https://gitee.com/openharmony/kernel_liteos_a/commits/6917e08431689ccbd5a30e9a39b67016ffb64d0a)), closes [#I3Z9](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Z9)
|
||||
* 修改某些平台保存bbox日志失败的问题 ([8f6a1dd](https://gitee.com/openharmony/kernel_liteos_a/commits/8f6a1dd33c59164070e8d2fb5abbd3e76ef8ac8e)), closes [#I41](https://gitee.com/openharmony/kernel_liteos_a/issues/I41)
|
||||
* 修改默认窗口宽度到400 ([09c491c](https://gitee.com/openharmony/kernel_liteos_a/commits/09c491ca1fd6d3110eafb0d07e45b25bdc3bd5d0)), closes [#I40](https://gitee.com/openharmony/kernel_liteos_a/issues/I40)
|
||||
* 关闭jffs和fat后,rootfs配置也被相应关闭,导致nand介质的rootfs不可用。 ([0ea476b](https://gitee.com/openharmony/kernel_liteos_a/commits/0ea476b9741fabd3c255c2770688f587920cf509)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* 修改/proc/mounts显示格式 ([6860246](https://gitee.com/openharmony/kernel_liteos_a/commits/6860246cfaac6f540665e79bbc4c3d54c419b092)), closes [#I3XGCS](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XGCS)
|
||||
* 修改clock_gettime接口适配posix标准测试用例011输入clk_id错误时返回值ESRCH为EINVAL. ([f8cf6e6](https://gitee.com/openharmony/kernel_liteos_a/commits/f8cf6e6439ee017fe8e0d4ecfc9949c28fa6775f)), closes [#I3OUHI](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OUHI)
|
||||
* 修改DoNanoSleep 以纳秒为单位 ([6917e08](https://gitee.com/openharmony/kernel_liteos_a/commits/6917e08431689ccbd5a30e9a39b67016ffb64d0a)), closes [#I3Z9DP](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Z9DP)
|
||||
* 修改某些平台保存bbox日志失败的问题 ([8f6a1dd](https://gitee.com/openharmony/kernel_liteos_a/commits/8f6a1dd33c59164070e8d2fb5abbd3e76ef8ac8e)), closes [#I41UTP](https://gitee.com/openharmony/kernel_liteos_a/issues/I41UTP)
|
||||
* 修改默认窗口宽度到400 ([09c491c](https://gitee.com/openharmony/kernel_liteos_a/commits/09c491ca1fd6d3110eafb0d07e45b25bdc3bd5d0)), closes [#I40LQX](https://gitee.com/openharmony/kernel_liteos_a/issues/I40LQX)
|
||||
* 关闭jffs和fat后,rootfs配置也被相应关闭,导致nand介质的rootfs不可用。 ([0ea476b](https://gitee.com/openharmony/kernel_liteos_a/commits/0ea476b9741fabd3c255c2770688f587920cf509)), closes [#I3SBYN](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SBYN)
|
||||
* 内核态在console初始化完成后,使用printf无法正常打印 ([44ce696](https://gitee.com/openharmony/kernel_liteos_a/commits/44ce6969048c2e252f3f9d66fa485c77bdab8ae7)), closes [#I3UG00](https://gitee.com/openharmony/kernel_liteos_a/issues/I3UG00)
|
||||
* 去掉冗余的strip操作 ([7819d15](https://gitee.com/openharmony/kernel_liteos_a/commits/7819d15b3619681ae37a1349a6bec2440c829ae9)), closes [#I43767](https://gitee.com/openharmony/kernel_liteos_a/issues/I43767)
|
||||
* 合并进程栈两个地址连续的region ([42f374d](https://gitee.com/openharmony/kernel_liteos_a/commits/42f374dd7a353f1c8227e92fa92827c1c7b32424)), closes [#I43](https://gitee.com/openharmony/kernel_liteos_a/issues/I43)
|
||||
* 在内核提示No idle TCB时,增加打印当前系统任务信息,以方便问题定位。 ([11a9b00](https://gitee.com/openharmony/kernel_liteos_a/commits/11a9b00d43a6dbe9fba9f6eb07d78a9d226c28f8)), closes [#I434](https://gitee.com/openharmony/kernel_liteos_a/issues/I434)
|
||||
* 合并进程栈两个地址连续的region ([42f374d](https://gitee.com/openharmony/kernel_liteos_a/commits/42f374dd7a353f1c8227e92fa92827c1c7b32424)), closes [#I43QYJ](https://gitee.com/openharmony/kernel_liteos_a/issues/I43QYJ)
|
||||
* 在内核提示No idle TCB时,增加打印当前系统任务信息,以方便问题定位。 ([11a9b00](https://gitee.com/openharmony/kernel_liteos_a/commits/11a9b00d43a6dbe9fba9f6eb07d78a9d226c28f8)), closes [#I434UC](https://gitee.com/openharmony/kernel_liteos_a/issues/I434UC)
|
||||
* 增加表头,内容以制表符分栏。 ([e9ad6b7](https://gitee.com/openharmony/kernel_liteos_a/commits/e9ad6b71c3b1136414672cd21b339ded7a02dfb9)), closes [#I3W2M9](https://gitee.com/openharmony/kernel_liteos_a/issues/I3W2M9)
|
||||
* 将用户态内存调测解析脚本移至tools目录下 ([85b4cb7](https://gitee.com/openharmony/kernel_liteos_a/commits/85b4cb7a67b717984d3ebf68115c7139cc61d690)), closes [#I42T9](https://gitee.com/openharmony/kernel_liteos_a/issues/I42T9)
|
||||
* 将用户态内存调测解析脚本移至tools目录下 ([85b4cb7](https://gitee.com/openharmony/kernel_liteos_a/commits/85b4cb7a67b717984d3ebf68115c7139cc61d690)), closes [#I42T9A](https://gitee.com/openharmony/kernel_liteos_a/issues/I42T9A)
|
||||
* 恢复了FATFS设置卷标的功能 ([9515d53](https://gitee.com/openharmony/kernel_liteos_a/commits/9515d53dccc9a6458bfbaf8e15143928f05cb660)), closes [#I3Y5G8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Y5G8)
|
||||
* 解决kill进程时无法保证进程的已持有的内核资源合理释放. ([cf89f01](https://gitee.com/openharmony/kernel_liteos_a/commits/cf89f016e93f28f8d72e6f5de08640d08a155908)), closes [#I3S0N0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3S0N0)
|
||||
* 解决不同环境下计算的rootfs的size偏小,导致mcopy造成的disk full错误 ([c54879b](https://gitee.com/openharmony/kernel_liteos_a/commits/c54879b54875abece53b1f64072cfacbd2e1970e)), closes [#I3IA06](https://gitee.com/openharmony/kernel_liteos_a/issues/I3IA06)
|
||||
* 设置qemu默认userfs大小/修改qemu驱动目录 ([1d952a2](https://gitee.com/openharmony/kernel_liteos_a/commits/1d952a254a6e7ec2f70f7112eb27355cfd01ba4d)), closes [#I3XW96](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XW96) [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* 设置qemu默认userfs大小/修改qemu驱动目录 ([1d952a2](https://gitee.com/openharmony/kernel_liteos_a/commits/1d952a254a6e7ec2f70f7112eb27355cfd01ba4d)), closes [#I3XW96](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XW96)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* active mksh & toybox ([cacb4f0](https://gitee.com/openharmony/kernel_liteos_a/commits/cacb4f0103ecb2d1b7af54d84957f88d3e9443d2)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* active mksh & toybox ([cacb4f0](https://gitee.com/openharmony/kernel_liteos_a/commits/cacb4f0103ecb2d1b7af54d84957f88d3e9443d2)), closes [#I3VEOG](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VEOG)
|
||||
* Add /dev/quickstart to support synchronous communication between processes in user mode startup. ([46b63f7](https://gitee.com/openharmony/kernel_liteos_a/commits/46b63f71537789743ed2f3f337c1809ee4900d71)), closes [#I3OHO5](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OHO5)
|
||||
* add /proc/fd file to dump the pid/fd/path information ([600dded](https://gitee.com/openharmony/kernel_liteos_a/commits/600dded31e80df275ed08c326c0ce3d1857d8dd8)), closes [#I3WB5](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WB5)
|
||||
* add /proc/fs_cache to display cache info ([231cb6b](https://gitee.com/openharmony/kernel_liteos_a/commits/231cb6be27380948bc48136ae2e02c28450f47a8)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* add /proc/fs_cache to display cache info ([53c6d96](https://gitee.com/openharmony/kernel_liteos_a/commits/53c6d96c6f97cb006216769f8b73f50fba3bc325)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* add /proc/fd file to dump the pid/fd/path information ([600dded](https://gitee.com/openharmony/kernel_liteos_a/commits/600dded31e80df275ed08c326c0ce3d1857d8dd8)), closes [#I3WB5U](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WB5U)
|
||||
* add /proc/fs_cache to display cache info ([231cb6b](https://gitee.com/openharmony/kernel_liteos_a/commits/231cb6be27380948bc48136ae2e02c28450f47a8)), closes [#I3WWBD](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WWBD)
|
||||
* add /proc/fs_cache to display cache info ([53c6d96](https://gitee.com/openharmony/kernel_liteos_a/commits/53c6d96c6f97cb006216769f8b73f50fba3bc325)), closes [#I3WESD](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WESD)
|
||||
* add and fix some syscall ([ce849f2](https://gitee.com/openharmony/kernel_liteos_a/commits/ce849f2145e1569517c5244c9ffcaebed53f3a66))
|
||||
* add blackbox for liteos_a ([a195aac](https://gitee.com/openharmony/kernel_liteos_a/commits/a195aac9fb60b0163f9eebb29084287d226bd14c)), closes [#I406](https://gitee.com/openharmony/kernel_liteos_a/issues/I406)
|
||||
* add blackbox for liteos_a ([425975e](https://gitee.com/openharmony/kernel_liteos_a/commits/425975e4811023e31a520979c20ea2562224d9d0)), closes [#I3NN7](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NN7)
|
||||
* add clear cache cmd to /proc/fs_cache ([3d1cf68](https://gitee.com/openharmony/kernel_liteos_a/commits/3d1cf683f37a6f75e9db2ce1f11ec93159b77663)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* add blackbox for liteos_a ([a195aac](https://gitee.com/openharmony/kernel_liteos_a/commits/a195aac9fb60b0163f9eebb29084287d226bd14c)), closes [#I406NP](https://gitee.com/openharmony/kernel_liteos_a/issues/I406NP)
|
||||
* add blackbox for liteos_a ([425975e](https://gitee.com/openharmony/kernel_liteos_a/commits/425975e4811023e31a520979c20ea2562224d9d0))
|
||||
* add clear cache cmd to /proc/fs_cache ([3d1cf68](https://gitee.com/openharmony/kernel_liteos_a/commits/3d1cf683f37a6f75e9db2ce1f11ec93159b77663)), closes [#I3XLPH](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XLPH)
|
||||
* add liteos patch ability ([98ca844](https://gitee.com/openharmony/kernel_liteos_a/commits/98ca8441fe75ee1c3318a6a09376fd72f5a51350))
|
||||
* add support for gn build system ([a8805a6](https://gitee.com/openharmony/kernel_liteos_a/commits/a8805a65aab9109b915364fccf36c8328f636e48))
|
||||
* add uid/gid for ProcFs ([6780659](https://gitee.com/openharmony/kernel_liteos_a/commits/67806596a3c0df9a54893d8c74ebe9da98d7fb06)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* A核proc文件系统在echo模式下新增write的功能 ([f10dd7c](https://gitee.com/openharmony/kernel_liteos_a/commits/f10dd7c135d37a5fb0d78610d5ece5807d01eb1f)), closes [#I3T6](https://gitee.com/openharmony/kernel_liteos_a/issues/I3T6)
|
||||
* add uid/gid for ProcFs ([6780659](https://gitee.com/openharmony/kernel_liteos_a/commits/67806596a3c0df9a54893d8c74ebe9da98d7fb06)), closes [#I3WGVP](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WGVP)
|
||||
* A核proc文件系统在echo模式下新增write的功能 ([f10dd7c](https://gitee.com/openharmony/kernel_liteos_a/commits/f10dd7c135d37a5fb0d78610d5ece5807d01eb1f)), closes [#I3T6MZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I3T6MZ)
|
||||
* build OHOS_Image from kernel ([abf4d8f](https://gitee.com/openharmony/kernel_liteos_a/commits/abf4d8fb252631aca9d46211762880a23be2a0b1))
|
||||
* **build:** make liteos_config_file available as gn argument ([f9a9077](https://gitee.com/openharmony/kernel_liteos_a/commits/f9a907772f506ca7e2d84e96d4d17cffc7dae50f))
|
||||
* **build:** 使用xts -notest选项时,内核用例不参与编译构建和用例编译配置方式调整 ([9bdf716](https://gitee.com/openharmony/kernel_liteos_a/commits/9bdf716407c125c9877b6f49c2133112c18cdabc))
|
||||
* don't apply module_swith on configs of config ([f3beb4b](https://gitee.com/openharmony/kernel_liteos_a/commits/f3beb4b273c9a76fbfaffe57302f27d2a74cd2ba))
|
||||
* enable gn build for toybox and mksh ([c54bfa1](https://gitee.com/openharmony/kernel_liteos_a/commits/c54bfa16e3907482c252e9738192df869c63326e))
|
||||
* fatfs支持符号链接功能 ([e50cf0b](https://gitee.com/openharmony/kernel_liteos_a/commits/e50cf0be6f6d118022b6d79c5177aece574ba150)), closes [#I3V8D1](https://gitee.com/openharmony/kernel_liteos_a/issues/I3V8D1)
|
||||
* **file system:** add memory-based romfs ([c4595d2](https://gitee.com/openharmony/kernel_liteos_a/commits/c4595d25042b188570d991a815009764c37f3cb3)), closes [#I3S0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3S0)
|
||||
* **file system:** add memory-based romfs ([c4595d2](https://gitee.com/openharmony/kernel_liteos_a/commits/c4595d25042b188570d991a815009764c37f3cb3)), closes [#I3S0CP](https://gitee.com/openharmony/kernel_liteos_a/issues/I3S0CP)
|
||||
* introduce mksh toybox to rootfs ([41c7689](https://gitee.com/openharmony/kernel_liteos_a/commits/41c7689dfa49c52fb15705ce15ef22a278fbf2ef))
|
||||
* L0-L1 支持Trace ([dc9ec68](https://gitee.com/openharmony/kernel_liteos_a/commits/dc9ec6856fe14aa604f037f55f17a3ba2bafb098)), closes [#I46WA0](https://gitee.com/openharmony/kernel_liteos_a/issues/I46WA0)
|
||||
* L1支持低功耗投票框架 ([21d8ac8](https://gitee.com/openharmony/kernel_liteos_a/commits/21d8ac8752469f6e0dc2d50d28b75421f665385a)), closes [#I3VS5](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VS5)
|
||||
* L1支持低功耗投票框架 ([21d8ac8](https://gitee.com/openharmony/kernel_liteos_a/commits/21d8ac8752469f6e0dc2d50d28b75421f665385a)), closes [#I3VS5N](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VS5N)
|
||||
* **libc:** upgrade optimized-routines to v21.02 ([1ec8d5a](https://gitee.com/openharmony/kernel_liteos_a/commits/1ec8d5a454658e95c4acb821d0878f357f4e82ad))
|
||||
* **make:** optimize makefiles and remove some unused files ([0e26094](https://gitee.com/openharmony/kernel_liteos_a/commits/0e260949c962158a263d4b0ad45fe9f6843d6e30))
|
||||
* Open macro for ADC moudule ([c71ec9d](https://gitee.com/openharmony/kernel_liteos_a/commits/c71ec9d7e8574078a9dc2a8463f3141cca3d625a))
|
||||
* **QEMU_ARM_VIRT_CA7:** 使能FAT文件系统编译选项 ([49856dc](https://gitee.com/openharmony/kernel_liteos_a/commits/49856dc1e0de1c5e92346c83eda641dfb1bb16be))
|
||||
* support .mkshrc ([51a50c9](https://gitee.com/openharmony/kernel_liteos_a/commits/51a50c95b4cd47b6931523926b728d1c0ff8988b)), closes [#I3Y5](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Y5)
|
||||
* support link/symlink/readlink ([6eddc86](https://gitee.com/openharmony/kernel_liteos_a/commits/6eddc869d349be59860bfd84ff10b7579a9b00a9)), closes [#I3Q0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Q0)
|
||||
* support toybox in qemu ([5618319](https://gitee.com/openharmony/kernel_liteos_a/commits/561831928bb1ad1871b2d60d2bba2d67488cea5f)), closes [#I3V17](https://gitee.com/openharmony/kernel_liteos_a/issues/I3V17)
|
||||
* timer_create支持以SIGEV_THREAD方式创建定时器 ([e5f6bf0](https://gitee.com/openharmony/kernel_liteos_a/commits/e5f6bf05567c2d193f3746caca502199e7b81e92)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3)
|
||||
* support .mkshrc ([51a50c9](https://gitee.com/openharmony/kernel_liteos_a/commits/51a50c95b4cd47b6931523926b728d1c0ff8988b)), closes [#I3Y5KE](https://gitee.com/openharmony/third_party_mksh/issues/I3Y5KE)
|
||||
* support link/symlink/readlink ([6eddc86](https://gitee.com/openharmony/kernel_liteos_a/commits/6eddc869d349be59860bfd84ff10b7579a9b00a9)), closes [#I3Q0OD](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Q0OD)
|
||||
* support toybox in qemu ([5618319](https://gitee.com/openharmony/kernel_liteos_a/commits/561831928bb1ad1871b2d60d2bba2d67488cea5f)), closes [#I3V17D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3V17D)
|
||||
* timer_create支持以SIGEV_THREAD方式创建定时器 ([e5f6bf0](https://gitee.com/openharmony/kernel_liteos_a/commits/e5f6bf05567c2d193f3746caca502199e7b81e92)), closes [#I3SRFI](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SRFI)
|
||||
* using kconfiglib instead of kconfig ([8784694](https://gitee.com/openharmony/kernel_liteos_a/commits/878469468647a19f704e7ee2af696b0ba8ab775a))
|
||||
* vfs support sdcard hotplug ([2db80ec](https://gitee.com/openharmony/kernel_liteos_a/commits/2db80ecb389176b53c77807567895470bb180a06)), closes [#I44WH1](https://gitee.com/openharmony/kernel_liteos_a/issues/I44WH1)
|
||||
* **vfs:** vfs支持FD_CLOEXEC标记 ([27dca4d](https://gitee.com/openharmony/kernel_liteos_a/commits/27dca4d857ef8de6b4bb9302e0dd435be7e3284f)), closes [#I3U81](https://gitee.com/openharmony/kernel_liteos_a/issues/I3U81)
|
||||
* **vfs:** vfs支持FD_CLOEXEC标记 ([27dca4d](https://gitee.com/openharmony/kernel_liteos_a/commits/27dca4d857ef8de6b4bb9302e0dd435be7e3284f)), closes [#I3U81W](https://gitee.com/openharmony/kernel_liteos_a/issues/I3U81W)
|
||||
* 删除zpfs冗余代码 ([3393479](https://gitee.com/openharmony/kernel_liteos_a/commits/3393479c52f4a9dfe2394bb32beb4b98fca8e171))
|
||||
* 基于汇编实现内核对用户态内存清零的功能 ([9db3407](https://gitee.com/openharmony/kernel_liteos_a/commits/9db3407589bb0b2d4a5772faac3130032bc0b8a9)), closes [#I3XXT0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XXT0)
|
||||
* 增加mount的MS_RDONLY标志的支持 ([8729f6e](https://gitee.com/openharmony/kernel_liteos_a/commits/8729f6ee57ea57bc664d076ff112c8726fedded9)), closes [#I3Z1W6](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Z1W6)
|
||||
* 支持killpg和waitid ([dc3cc09](https://gitee.com/openharmony/kernel_liteos_a/commits/dc3cc094a75c6da65d87522930afea06106d3933))
|
||||
* 新增toybox reboot命令 ([e567a10](https://gitee.com/openharmony/kernel_liteos_a/commits/e567a10d021c3e0fe02d6911dbe8687255c67ffa)), closes [#I3YQ7](https://gitee.com/openharmony/kernel_liteos_a/issues/I3YQ7)
|
||||
* 给开发者提供系统信息导出Hidumper工具。 ([cb17fa5](https://gitee.com/openharmony/kernel_liteos_a/commits/cb17fa50ed28e6e8f59b7d68ede13c759b983311)), closes [#I3NN7](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NN7)
|
||||
* 自研shell命令回补 ([7bc68f4](https://gitee.com/openharmony/kernel_liteos_a/commits/7bc68f454ff5fbf415712c9b8479b8c832f68417)), closes [#I44U0](https://gitee.com/openharmony/kernel_liteos_a/issues/I44U0)
|
||||
* 新增toybox reboot命令 ([e567a10](https://gitee.com/openharmony/kernel_liteos_a/commits/e567a10d021c3e0fe02d6911dbe8687255c67ffa)), closes [#I3YQ7S](https://gitee.com/openharmony/third_party_toybox/issues/I3YQ7S)
|
||||
* 给开发者提供系统信息导出Hidumper工具。 ([cb17fa5](https://gitee.com/openharmony/kernel_liteos_a/commits/cb17fa50ed28e6e8f59b7d68ede13c759b983311))
|
||||
* 自研shell命令回补 ([7bc68f4](https://gitee.com/openharmony/kernel_liteos_a/commits/7bc68f454ff5fbf415712c9b8479b8c832f68417)), closes [#I44U0H](https://gitee.com/openharmony/third_party_toybox/issues/I44U0H)
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
@@ -316,7 +316,7 @@ LOS_LmsAddrDisableProtect去能指定内存段的访问保护
|
||||
|
||||
### Reverts
|
||||
|
||||
* Revert "fix: 修改默认窗口宽度到400" ([1878849](https://gitee.com/openharmony/kernel_liteos_a/commits/187884937cd087e39a28c033c41033163d6b4766)), closes [#I42X9](https://gitee.com/openharmony/kernel_liteos_a/issues/I42X9)
|
||||
* Revert "fix: 修改默认窗口宽度到400" ([1878849](https://gitee.com/openharmony/kernel_liteos_a/commits/187884937cd087e39a28c033c41033163d6b4766)), closes [#I42X9V](https://gitee.com/openharmony/kernel_liteos_a/issues/I42X9V)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
7
Kconfig
7
Kconfig
@@ -235,7 +235,12 @@ config SCHED_DEBUG
|
||||
depends on DEBUG_VERSION
|
||||
help
|
||||
If you wish to build LiteOS with support for sched debug.
|
||||
|
||||
config SCHED_EDF_DEBUG
|
||||
bool "Enable sched EDF debug Feature"
|
||||
default n
|
||||
depends on SCHED_DEBUG
|
||||
help
|
||||
If you wish to build LiteOS with support for sched debug.
|
||||
config USER_INIT_DEBUG
|
||||
bool "Enable user init Debug"
|
||||
default n
|
||||
|
||||
@@ -87,7 +87,7 @@ For compilation, please refer to the [compilation instructions](https://gitee.co
|
||||
|
||||
## Contribution<a name="section1371123476304"></a>
|
||||
|
||||
[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/en/contribute/contribution.md)
|
||||
[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/en/contribute/contribution-guide.md)
|
||||
|
||||
[Commit message spec](https://gitee.com/openharmony/kernel_liteos_a/wikis/Commit%20message%20%E8%A7%84%E8%8C%83)
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@ OpenHarmony LiteOS-A内核支持[Hi3516DV300](https://gitee.com/openharmony/docs
|
||||
|
||||
编译可以参考:[编译指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-build.md)
|
||||
|
||||
测试参考:[单元测试](testsuites/unittest/tools/README.md)
|
||||
|
||||
## 贡献<a name="section1371123476304"></a>
|
||||
|
||||
[如何贡献](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
|
||||
|
||||
@@ -73,5 +73,5 @@ executable("sample_usr_lms") {
|
||||
"-Wl,--wrap=strcpy",
|
||||
"-Wl,--wrap=strcat",
|
||||
]
|
||||
deps = [ "//kernel/liteos_a/kernel/extended/lms/usr:usrlmslib" ]
|
||||
deps = [ "$LITEOSTOPDIR/kernel/extended/lms/usr:usrlmslib" ]
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/mksh/mksh.gni")
|
||||
import("$THIRDPARTY_MKSH_DIR/mksh.gni")
|
||||
|
||||
group("mksh") {
|
||||
deps = [ ":build_mksh" ]
|
||||
@@ -42,7 +42,7 @@ copy("copy_mksh_src") {
|
||||
|
||||
build_ext_component("build_mksh") {
|
||||
deps = [ ":copy_mksh_src" ]
|
||||
deps += [ "//third_party/musl:sysroot_lite" ]
|
||||
deps += [ "$THIRDPARTY_MUSL_DIR:sysroot_lite" ]
|
||||
exec_path = rebase_path("$target_out_dir/mksh_build")
|
||||
|
||||
cflags = [
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
ShellCB *g_shellCB = NULL;
|
||||
|
||||
ShellCB *OsGetShellCb()
|
||||
ShellCB *OsGetShellCb(void)
|
||||
{
|
||||
return g_shellCB;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/toybox/toybox.gni")
|
||||
import("$THIRDPARTY_TOYBOX_DIR/toybox.gni")
|
||||
|
||||
group("toybox") {
|
||||
deps = [ ":build_toybox" ]
|
||||
@@ -51,7 +51,7 @@ build_ext_component("build_toybox") {
|
||||
":copy_toybox_config",
|
||||
":copy_toybox_src",
|
||||
]
|
||||
deps += [ "//third_party/musl:sysroot_lite" ]
|
||||
deps += [ "$THIRDPARTY_MUSL_DIR:sysroot_lite" ]
|
||||
exec_path = rebase_path("$target_out_dir/toybox_build")
|
||||
|
||||
cflags = [
|
||||
|
||||
@@ -27,11 +27,8 @@
|
||||
"component": {
|
||||
"name": "liteos_a",
|
||||
"subsystem": "kernel",
|
||||
"syscap": [
|
||||
"SystemCapability.Kernel.liteos-a"
|
||||
],
|
||||
"features": [],
|
||||
"adated_system_type": [
|
||||
"adapted_system_type": [
|
||||
"small"
|
||||
],
|
||||
"rom": "1.5MB",
|
||||
|
||||
@@ -113,7 +113,9 @@ STATIC INLINE struct mqarray *GetMqueueCBByName(const CHAR *name)
|
||||
STATIC INT32 DoMqueueDelete(struct mqarray *mqueueCB)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
OsIPCLimitMqFree();
|
||||
#endif
|
||||
if (mqueueCB->mq_name != NULL) {
|
||||
LOS_MemFree(OS_SYS_MEM_ADDR, mqueueCB->mq_name);
|
||||
mqueueCB->mq_name = NULL;
|
||||
@@ -163,11 +165,29 @@ STATIC int SaveMqueueName(const CHAR *mqName, struct mqarray *mqueueCB)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID MqueueCBInit(struct mqarray *mqueueCB, const struct mq_attr *attr, INT32 openFlag, UINT32 mode)
|
||||
{
|
||||
mqueueCB->unlinkflag = FALSE;
|
||||
mqueueCB->unlink_ref = 0;
|
||||
mqueueCB->mq_personal->mq_status = MQ_USE_MAGIC;
|
||||
mqueueCB->mq_personal->mq_next = NULL;
|
||||
mqueueCB->mq_personal->mq_posixdes = mqueueCB;
|
||||
mqueueCB->mq_personal->mq_flags = (INT32)((UINT32)openFlag | ((UINT32)attr->mq_flags & (UINT32)FNONBLOCK));
|
||||
mqueueCB->mq_personal->mq_mode = mode;
|
||||
mqueueCB->mq_personal->mq_refcount = 0;
|
||||
mqueueCB->mq_notify.pid = 0;
|
||||
}
|
||||
|
||||
STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR *mqName, INT32 openFlag, UINT32 mode)
|
||||
{
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
UINT32 mqueueID;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
if (OsIPCLimitMqAlloc() != LOS_OK) {
|
||||
return (struct mqpersonal *)-1;
|
||||
}
|
||||
#endif
|
||||
UINT32 err = LOS_QueueCreate(NULL, attr->mq_maxmsg, &mqueueID, 0, attr->mq_msgsize);
|
||||
if (map_errno(err) != ENOERR) {
|
||||
goto ERROUT;
|
||||
@@ -201,15 +221,7 @@ STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR
|
||||
goto ERROUT;
|
||||
}
|
||||
|
||||
mqueueCB->unlinkflag = FALSE;
|
||||
mqueueCB->unlink_ref = 0;
|
||||
mqueueCB->mq_personal->mq_status = MQ_USE_MAGIC;
|
||||
mqueueCB->mq_personal->mq_next = NULL;
|
||||
mqueueCB->mq_personal->mq_posixdes = mqueueCB;
|
||||
mqueueCB->mq_personal->mq_flags = (INT32)((UINT32)openFlag | ((UINT32)attr->mq_flags & (UINT32)FNONBLOCK));
|
||||
mqueueCB->mq_personal->mq_mode = mode;
|
||||
mqueueCB->mq_personal->mq_refcount = 0;
|
||||
mqueueCB->mq_notify.pid = 0;
|
||||
MqueueCBInit(mqueueCB, attr, openFlag, mode);
|
||||
|
||||
return mqueueCB->mq_personal;
|
||||
ERROUT:
|
||||
@@ -218,6 +230,9 @@ ERROUT:
|
||||
LOS_MemFree(OS_SYS_MEM_ADDR, mqueueCB->mq_name);
|
||||
mqueueCB->mq_name = NULL;
|
||||
}
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
OsIPCLimitMqFree();
|
||||
#endif
|
||||
return (struct mqpersonal *)-1;
|
||||
}
|
||||
|
||||
@@ -589,17 +604,19 @@ int OsMqGetAttr(mqd_t personal, struct mq_attr *mqAttr)
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
struct mqpersonal *privateMqPersonal = NULL;
|
||||
|
||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||
if (privateMqPersonal == NULL) {
|
||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mqAttr == NULL) {
|
||||
errno = EINVAL;
|
||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
||||
return -1;
|
||||
}
|
||||
|
||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
||||
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
||||
errno = EBADF;
|
||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
||||
@@ -619,17 +636,19 @@ int OsMqSetAttr(mqd_t personal, const struct mq_attr *mqSetAttr, struct mq_attr
|
||||
{
|
||||
struct mqpersonal *privateMqPersonal = NULL;
|
||||
|
||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||
if (privateMqPersonal == NULL) {
|
||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mqSetAttr == NULL) {
|
||||
errno = EINVAL;
|
||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
||||
return -1;
|
||||
}
|
||||
|
||||
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
|
||||
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
||||
errno = EBADF;
|
||||
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_VFS_BLOCK_DEVICE)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
|
||||
@@ -97,5 +97,5 @@ static const struct file_operations_vfs g_memDevOps = {
|
||||
|
||||
int DevMemRegister(void)
|
||||
{
|
||||
return register_driver("/dev/mem", &g_memDevOps, 0666, 0); /* 0666: file mode */
|
||||
return register_driver("/dev/mem", &g_memDevOps, 0644, 0); /* 0644: file mode */
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_DRIVERS_VIDEO)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/FatFs/FatFs.gni")
|
||||
import("$THIRDPARTY_FATFS_DIR/FatFs.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_FAT)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
|
||||
@@ -31,7 +31,7 @@ import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_JFFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
linux_path = rebase_path("//kernel/linux/linux-5.10")
|
||||
linux_path = rebase_path("$KERNEL_LINUX_DIR")
|
||||
out_path = rebase_path(target_out_dir)
|
||||
|
||||
kernel_module(module_name) {
|
||||
|
||||
@@ -2311,7 +2311,7 @@ diff -Nupr old/fs/jffs2/erase.c new/fs/jffs2/erase.c
|
||||
diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||
--- old/fs/jffs2/file.c 2022-05-09 17:22:53.000000000 +0800
|
||||
+++ new/fs/jffs2/file.c 2022-05-10 09:43:14.250000000 +0800
|
||||
@@ -9,335 +9,30 @@
|
||||
@@ -9,334 +9,31 @@
|
||||
* For licensing information, see the file 'LICENCE' in this directory.
|
||||
*
|
||||
*/
|
||||
@@ -2348,7 +2348,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
|
||||
+ /* FIXME: This works only with one file system mounted at a time */
|
||||
int ret;
|
||||
-
|
||||
|
||||
- ret = file_write_and_wait_range(filp, start, end);
|
||||
+ ret = jffs2_read_inode_range(c, f, gc_buffer,
|
||||
+ offset & ~(PAGE_SIZE-1), PAGE_SIZE);
|
||||
@@ -2361,8 +2361,10 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||
- inode_unlock(inode);
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
+ return ERR_PTR(ret);
|
||||
+ return gc_buffer;
|
||||
}
|
||||
|
||||
-const struct file_operations jffs2_file_operations =
|
||||
-{
|
||||
- .llseek = generic_file_llseek,
|
||||
@@ -2387,7 +2389,10 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||
-};
|
||||
-
|
||||
-const struct address_space_operations jffs2_file_address_operations =
|
||||
-{
|
||||
+void jffs2_gc_release_page(struct jffs2_sb_info *c,
|
||||
+ unsigned char *ptr,
|
||||
+ unsigned long *priv)
|
||||
{
|
||||
- .readpage = jffs2_readpage,
|
||||
- .write_begin = jffs2_write_begin,
|
||||
- .write_end = jffs2_write_end,
|
||||
@@ -2443,35 +2448,29 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||
- ret = jffs2_do_readpage_unlock(pg->mapping->host, pg);
|
||||
- mutex_unlock(&f->sem);
|
||||
- return ret;
|
||||
+ return ERR_PTR(ret);
|
||||
+ return gc_buffer;
|
||||
}
|
||||
|
||||
-}
|
||||
-
|
||||
-static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
|
||||
- loff_t pos, unsigned len, unsigned flags,
|
||||
- struct page **pagep, void **fsdata)
|
||||
+void jffs2_gc_release_page(struct jffs2_sb_info *c,
|
||||
+ unsigned char *ptr,
|
||||
+ unsigned long *priv)
|
||||
{
|
||||
-{
|
||||
- struct page *pg;
|
||||
- struct inode *inode = mapping->host;
|
||||
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
|
||||
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
|
||||
- pgoff_t index = pos >> PAGE_SHIFT;
|
||||
- uint32_t pageofs = index << PAGE_SHIFT;
|
||||
- int ret = 0;
|
||||
-
|
||||
- jffs2_dbg(1, "%s()\n", __func__);
|
||||
-
|
||||
- if (pageofs > inode->i_size) {
|
||||
- /* Make new hole frag from old EOF to new page */
|
||||
- if (pos > inode->i_size) {
|
||||
- /* Make new hole frag from old EOF to new position */
|
||||
- struct jffs2_raw_inode ri;
|
||||
- struct jffs2_full_dnode *fn;
|
||||
- uint32_t alloc_len;
|
||||
-
|
||||
- jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new page\n",
|
||||
- (unsigned int)inode->i_size, pageofs);
|
||||
- jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new position\n",
|
||||
- (unsigned int)inode->i_size, (uint32_t)pos);
|
||||
-
|
||||
- ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
|
||||
- ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
|
||||
@@ -2491,10 +2490,10 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||
- ri.mode = cpu_to_jemode(inode->i_mode);
|
||||
- ri.uid = cpu_to_je16(i_uid_read(inode));
|
||||
- ri.gid = cpu_to_je16(i_gid_read(inode));
|
||||
- ri.isize = cpu_to_je32(max((uint32_t)inode->i_size, pageofs));
|
||||
- ri.isize = cpu_to_je32((uint32_t)pos);
|
||||
- ri.atime = ri.ctime = ri.mtime = cpu_to_je32(JFFS2_NOW());
|
||||
- ri.offset = cpu_to_je32(inode->i_size);
|
||||
- ri.dsize = cpu_to_je32(pageofs - inode->i_size);
|
||||
- ri.dsize = cpu_to_je32((uint32_t)pos - inode->i_size);
|
||||
- ri.csize = cpu_to_je32(0);
|
||||
- ri.compr = JFFS2_COMPR_ZERO;
|
||||
- ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
|
||||
@@ -2524,7 +2523,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
|
||||
- goto out_err;
|
||||
- }
|
||||
- jffs2_complete_reservation(c);
|
||||
- inode->i_size = pageofs;
|
||||
- inode->i_size = pos;
|
||||
- mutex_unlock(&f->sem);
|
||||
- }
|
||||
-
|
||||
@@ -8668,7 +8667,7 @@ diff -Nupr old/fs/jffs2/writev.c new/fs/jffs2/writev.c
|
||||
diff -Nupr old/fs/jffs2/xattr.c new/fs/jffs2/xattr.c
|
||||
--- old/fs/jffs2/xattr.c 2022-05-09 17:15:24.360000000 +0800
|
||||
+++ new/fs/jffs2/xattr.c 1970-01-01 08:00:00.000000000 +0800
|
||||
@@ -1,1347 +0,0 @@
|
||||
@@ -1,1352 +0,0 @@
|
||||
-/*
|
||||
- * JFFS2 -- Journalling Flash File System, Version 2.
|
||||
- *
|
||||
@@ -9443,10 +9442,10 @@ diff -Nupr old/fs/jffs2/xattr.c new/fs/jffs2/xattr.c
|
||||
-}
|
||||
-
|
||||
-#define XREF_TMPHASH_SIZE (128)
|
||||
-void jffs2_build_xattr_subsystem(struct jffs2_sb_info *c)
|
||||
-int jffs2_build_xattr_subsystem(struct jffs2_sb_info *c)
|
||||
-{
|
||||
- struct jffs2_xattr_ref *ref, *_ref;
|
||||
- struct jffs2_xattr_ref *xref_tmphash[XREF_TMPHASH_SIZE];
|
||||
- struct jffs2_xattr_ref **xref_tmphash;
|
||||
- struct jffs2_xattr_datum *xd, *_xd;
|
||||
- struct jffs2_inode_cache *ic;
|
||||
- struct jffs2_raw_node_ref *raw;
|
||||
@@ -9455,9 +9454,12 @@ diff -Nupr old/fs/jffs2/xattr.c new/fs/jffs2/xattr.c
|
||||
-
|
||||
- BUG_ON(!(c->flags & JFFS2_SB_FLAG_BUILDING));
|
||||
-
|
||||
- xref_tmphash = kcalloc(XREF_TMPHASH_SIZE,
|
||||
- sizeof(struct jffs2_xattr_ref *), GFP_KERNEL);
|
||||
- if (!xref_tmphash)
|
||||
- return -ENOMEM;
|
||||
-
|
||||
- /* Phase.1 : Merge same xref */
|
||||
- for (i=0; i < XREF_TMPHASH_SIZE; i++)
|
||||
- xref_tmphash[i] = NULL;
|
||||
- for (ref=c->xref_temp; ref; ref=_ref) {
|
||||
- struct jffs2_xattr_ref *tmp;
|
||||
-
|
||||
@@ -9555,6 +9557,8 @@ diff -Nupr old/fs/jffs2/xattr.c new/fs/jffs2/xattr.c
|
||||
- "%u of xref (%u dead, %u orphan) found.\n",
|
||||
- xdatum_count, xdatum_unchecked_count, xdatum_orphan_count,
|
||||
- xref_count, xref_dead_count, xref_orphan_count);
|
||||
- kfree(xref_tmphash);
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
|
||||
|
||||
@@ -490,14 +490,14 @@ off_t VfsJffs2Seek(struct file *filep, off_t offset, int whence)
|
||||
filePos = filep->f_pos;
|
||||
|
||||
switch (whence) {
|
||||
case SEEK_SET:
|
||||
filePos = offset;
|
||||
break;
|
||||
|
||||
case SEEK_CUR:
|
||||
filePos += offset;
|
||||
break;
|
||||
|
||||
case SEEK_SET:
|
||||
filePos = offset;
|
||||
break;
|
||||
|
||||
case SEEK_END:
|
||||
filePos = node->i_size + offset;
|
||||
break;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_NFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
|
||||
@@ -38,10 +38,12 @@ kernel_module(module_name) {
|
||||
"os_adapt/fs_cache_proc.c",
|
||||
"os_adapt/mem_info.c",
|
||||
"os_adapt/mounts_proc.c",
|
||||
"os_adapt/plimits_proc.c",
|
||||
"os_adapt/power_proc.c",
|
||||
"os_adapt/proc_init.c",
|
||||
"os_adapt/proc_vfs.c",
|
||||
"os_adapt/process_proc.c",
|
||||
"os_adapt/sys_user.c",
|
||||
"os_adapt/uptime_proc.c",
|
||||
"os_adapt/vmm_proc.c",
|
||||
"src/proc_file.c",
|
||||
|
||||
@@ -55,6 +55,16 @@ void ProcSysMemInfoInit(void);
|
||||
void ProcFileSysInit(void);
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
void ProcLimitsInit(void);
|
||||
#endif
|
||||
|
||||
void ProcEntryClearVnode(struct ProcDirEntry *entry);
|
||||
|
||||
void ProcDetachNode(struct ProcDirEntry *pn);
|
||||
|
||||
void RemoveProcEntryTravalsal(struct ProcDirEntry *pn);
|
||||
|
||||
void ProcPmInit(void);
|
||||
|
||||
void ProcVmmInit(void);
|
||||
@@ -79,6 +89,7 @@ void ProcFdInit(void);
|
||||
|
||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
||||
void *ProcfsContainerGet(int fd, unsigned int *containerType);
|
||||
void ProcSysUserInit(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -93,6 +93,15 @@ struct ProcFileOperations {
|
||||
ssize_t (*readLink)(struct ProcDirEntry *pde, char *buf, size_t bufLen);
|
||||
};
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
struct ProcDirOperations {
|
||||
int (*rmdir)(struct ProcDirEntry *parent, struct ProcDirEntry *pde, const char *name);
|
||||
int (*mkdir)(struct ProcDirEntry *parent, const char *dirName, mode_t mode, struct ProcDirEntry **pde);
|
||||
};
|
||||
#endif
|
||||
|
||||
#define PROC_DATA_STATIC 0
|
||||
#define PROC_DATA_FREE 1
|
||||
struct ProcDirEntry {
|
||||
uint uid;
|
||||
uint gid;
|
||||
@@ -101,6 +110,10 @@ struct ProcDirEntry {
|
||||
const struct ProcFileOperations *procFileOps;
|
||||
struct ProcFile *pf;
|
||||
struct ProcDirEntry *next, *parent, *subdir;
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
const struct ProcDirOperations *procDirOps;
|
||||
#endif
|
||||
int dataType;
|
||||
void *data;
|
||||
atomic_t count; /* open file count */
|
||||
spinlock_t pdeUnloadLock;
|
||||
@@ -111,6 +124,11 @@ struct ProcDirEntry {
|
||||
enum VnodeType type;
|
||||
};
|
||||
|
||||
struct ProcDataParm {
|
||||
void *data;
|
||||
int dataType;
|
||||
};
|
||||
|
||||
struct ProcFile {
|
||||
fmode_t fMode;
|
||||
spinlock_t fLock;
|
||||
@@ -274,7 +292,7 @@ extern struct ProcDirEntry *ProcCreate(const char *name, mode_t mode,
|
||||
*
|
||||
*/
|
||||
extern struct ProcDirEntry *ProcCreateData(const char *name, mode_t mode, struct ProcDirEntry *parent,
|
||||
const struct ProcFileOperations *procFileOps, void *data);
|
||||
const struct ProcFileOperations *procFileOps, struct ProcDataParm *param);
|
||||
/**
|
||||
* @ingroup procfs
|
||||
* @brief init proc fs
|
||||
|
||||
@@ -207,7 +207,7 @@ static const struct ProcFileOperations FS_CACHE_PROC_FOPS = {
|
||||
|
||||
void ProcFsCacheInit(void)
|
||||
{
|
||||
struct ProcDirEntry *pde = CreateProcEntry("fs_cache", 0, NULL);
|
||||
struct ProcDirEntry *pde = CreateProcEntry("fs_cache", 0400, NULL);
|
||||
if (pde == NULL) {
|
||||
PRINT_ERR("create fs_cache error!\n");
|
||||
return;
|
||||
|
||||
905
fs/proc/os_adapt/plimits_proc.c
Normal file
905
fs/proc/os_adapt/plimits_proc.c
Normal file
@@ -0,0 +1,905 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/statfs.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "stdlib.h"
|
||||
#include "los_printf.h"
|
||||
#include "los_base.h"
|
||||
#include "los_seq_buf.h"
|
||||
#include "internal.h"
|
||||
#include "proc_fs.h"
|
||||
#include "los_task_pri.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "los_process.h"
|
||||
#include "show.h"
|
||||
#include "vnode.h"
|
||||
#include "proc_file.h"
|
||||
#include "user_copy.h"
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
#include "los_plimits.h"
|
||||
|
||||
#define PLIMITS_ENTRY_NAME_MAX 64
|
||||
#define PLIMITERSET_DELETE_ALLOC 4
|
||||
#define UNITPTR_NULL ((uintptr_t)(0xFFFFFFFF))
|
||||
#define PLIMIT_FILE_MODE_READ_WRITE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
|
||||
#define PLIMIT_FILE_MODE_READ_ONLY (S_IRUSR | S_IRGRP | S_IROTH)
|
||||
#define PLIMIT_FILE_MODE_WRITE_ONLY (S_IWUSR)
|
||||
#define PLIMIT_FILE_MODE_MASK_WRITE (~((mode_t)(S_IWUSR)))
|
||||
#define PLIMIT_FILE_MODE_MASK_NONE (~((mode_t)(0)))
|
||||
#define LOS_MAX_CACHE (UINT64)(0xFFFFFFFFFFFFFFFF)
|
||||
#define PLIMIT_CAT_BUF_SIZE 512
|
||||
#define MAX_PROTECTED_PROCESS_ID 14
|
||||
#define UNITPTR_NULL ((uintptr_t)(0xFFFFFFFF))
|
||||
|
||||
static int ShowPids(struct SeqBuf *seqBuf, VOID *data);
|
||||
static ssize_t PidMigrateFromProcLimiterSet(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
||||
static ssize_t PidLimitReadPidLimit(struct SeqBuf *seqBuf, VOID *data);
|
||||
static ssize_t PidLimitReadPriorityLimit(struct SeqBuf *seqBuf, VOID *data);
|
||||
static ssize_t PriorityLimitVariableWrite(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
||||
static ssize_t PidsMaxVariableWrite(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
||||
static ssize_t ProcLimitsShowLimiters(struct SeqBuf *seqBuf, VOID *data);
|
||||
static int ProcfsPlimitsMkdir(struct ProcDirEntry *parent, const char *dirName, mode_t mode, struct ProcDirEntry **pde);
|
||||
static int ProcfsPlimitsRmdir(struct ProcDirEntry *parent, struct ProcDirEntry *pde, const char *name);
|
||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
||||
static ssize_t MemLimitReadLimit(struct SeqBuf *seqBuf, VOID *data);
|
||||
static ssize_t MemLimitWriteLimit(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
||||
static ssize_t MemLimitStatShow(struct SeqBuf *seqBuf, VOID *data);
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
static ssize_t IPCLimitReadMqLimit(struct SeqBuf *seqBuf, VOID *data);
|
||||
static ssize_t IPCLimitWriteMqLimit(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
||||
static ssize_t IPCLimitReadShmLimit(struct SeqBuf *seqBuf, VOID *data);
|
||||
static ssize_t IPCLimitWriteShmLimit(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
||||
static ssize_t IPCLimitShowStat(struct SeqBuf *seqBuf, VOID *data);
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
||||
static ssize_t DevLimitWriteAllow(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
||||
static ssize_t DevLimitWriteDeny(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
||||
static ssize_t DevLimitShow(struct SeqBuf *seqBuf, VOID *data);
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
static ssize_t SchedLimitReadPeriod(struct SeqBuf *seqBuf, VOID *data);
|
||||
static ssize_t SchedLimitWritePeriod(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
||||
static ssize_t SchedLimitReadQuota(struct SeqBuf *seqBuf, VOID *data);
|
||||
static ssize_t SchedLimitWriteQuota(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos);
|
||||
static ssize_t SchedLimitShow(struct SeqBuf *seqBuf, VOID *data);
|
||||
#endif
|
||||
|
||||
struct PLimitsEntryOpt {
|
||||
int id;
|
||||
char name[PLIMITS_ENTRY_NAME_MAX];
|
||||
mode_t mode;
|
||||
uintptr_t offset;
|
||||
struct ProcFileOperations ops;
|
||||
};
|
||||
|
||||
static struct ProcDirOperations g_procDirOperations = {
|
||||
.mkdir = ProcfsPlimitsMkdir,
|
||||
.rmdir = ProcfsPlimitsRmdir,
|
||||
};
|
||||
|
||||
static struct PLimitsEntryOpt g_plimitsEntryOpts[] = {
|
||||
{
|
||||
.id = PROCESS_LIMITER_COUNT,
|
||||
.name = "plimits.limiters",
|
||||
.mode = PLIMIT_FILE_MODE_READ_ONLY,
|
||||
.offset = UNITPTR_NULL,
|
||||
.ops = {
|
||||
.read = ProcLimitsShowLimiters,
|
||||
}
|
||||
},
|
||||
{
|
||||
.id = PROCESS_LIMITER_COUNT,
|
||||
.name = "plimits.procs",
|
||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
||||
.offset = UNITPTR_NULL,
|
||||
.ops = {
|
||||
.read = ShowPids,
|
||||
.write = PidMigrateFromProcLimiterSet,
|
||||
},
|
||||
},
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_PIDS,
|
||||
.name = "pids.max",
|
||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
||||
.offset = 0,
|
||||
.ops = {
|
||||
.read = PidLimitReadPidLimit,
|
||||
.write = PidsMaxVariableWrite,
|
||||
},
|
||||
},
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_PIDS,
|
||||
.name = "pids.priority",
|
||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
||||
.offset = 0,
|
||||
.ops = {
|
||||
.read = PidLimitReadPriorityLimit,
|
||||
.write = PriorityLimitVariableWrite,
|
||||
},
|
||||
},
|
||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_MEM,
|
||||
.name = "memory.limit",
|
||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
||||
.offset = 0,
|
||||
.ops = {
|
||||
.read = MemLimitReadLimit,
|
||||
.write = MemLimitWriteLimit,
|
||||
},
|
||||
},
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_MEM,
|
||||
.name = "memory.stat",
|
||||
.mode = PLIMIT_FILE_MODE_READ_ONLY,
|
||||
.offset = UNITPTR_NULL,
|
||||
.ops = {
|
||||
.read = MemLimitStatShow,
|
||||
}
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_IPC,
|
||||
.name = "ipc.mq_limit",
|
||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
||||
.offset = 0,
|
||||
.ops = {
|
||||
.read = IPCLimitReadMqLimit,
|
||||
.write = IPCLimitWriteMqLimit,
|
||||
}
|
||||
},
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_IPC,
|
||||
.name = "ipc.shm_limit",
|
||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
||||
.offset = 0,
|
||||
.ops = {
|
||||
.read = IPCLimitReadShmLimit,
|
||||
.write = IPCLimitWriteShmLimit,
|
||||
}
|
||||
},
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_IPC,
|
||||
.name = "ipc.stat",
|
||||
.mode = PLIMIT_FILE_MODE_READ_ONLY,
|
||||
.offset = UNITPTR_NULL,
|
||||
.ops = {
|
||||
.read = IPCLimitShowStat,
|
||||
}
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_DEV,
|
||||
.name = "devices.allow",
|
||||
.mode = PLIMIT_FILE_MODE_WRITE_ONLY,
|
||||
.offset = UNITPTR_NULL,
|
||||
.ops = {
|
||||
.write = DevLimitWriteAllow,
|
||||
}
|
||||
},
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_DEV,
|
||||
.name = "devices.deny",
|
||||
.mode = PLIMIT_FILE_MODE_WRITE_ONLY,
|
||||
.offset = UNITPTR_NULL,
|
||||
.ops = {
|
||||
.write = DevLimitWriteDeny,
|
||||
}
|
||||
},
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_DEV,
|
||||
.name = "devices.list",
|
||||
.mode = PLIMIT_FILE_MODE_READ_ONLY,
|
||||
.offset = 0,
|
||||
.ops = {
|
||||
.read = DevLimitShow,
|
||||
}
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_SCHED,
|
||||
.name = "sched.period",
|
||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
||||
.offset = 0,
|
||||
.ops = {
|
||||
.read = SchedLimitReadPeriod,
|
||||
.write = SchedLimitWritePeriod,
|
||||
},
|
||||
},
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_SCHED,
|
||||
.name = "sched.quota",
|
||||
.mode = PLIMIT_FILE_MODE_READ_WRITE,
|
||||
.offset = 0,
|
||||
.ops = {
|
||||
.read = SchedLimitReadQuota,
|
||||
.write = SchedLimitWriteQuota,
|
||||
},
|
||||
},
|
||||
{
|
||||
.id = PROCESS_LIMITER_ID_SCHED,
|
||||
.name = "sched.stat",
|
||||
.mode = PLIMIT_FILE_MODE_READ_ONLY,
|
||||
.offset = UNITPTR_NULL,
|
||||
.ops = {
|
||||
.read = SchedLimitShow,
|
||||
}
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
static unsigned int MemUserCopy(const char *src, size_t len, char **kbuf)
|
||||
{
|
||||
if (LOS_IsUserAddressRange((VADDR_T)(UINTPTR)src, len)) {
|
||||
char *kernelBuf = LOS_MemAlloc(m_aucSysMem1, len + 1);
|
||||
if (kernelBuf == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (LOS_ArchCopyFromUser(kernelBuf, src, len) != 0) {
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, kernelBuf);
|
||||
return EFAULT;
|
||||
}
|
||||
kernelBuf[len] = '\0';
|
||||
*kbuf = kernelBuf;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline struct ProcDirEntry *GetCurrDirectory(struct ProcDirEntry *dirEntry)
|
||||
{
|
||||
return ((dirEntry == NULL) || S_ISDIR(dirEntry->mode)) ? dirEntry : dirEntry->parent;
|
||||
}
|
||||
|
||||
static inline ProcLimiterSet *GetProcLimiterSetFromDirEntry(struct ProcDirEntry *dirEntry)
|
||||
{
|
||||
struct ProcDirEntry *currDirectory = GetCurrDirectory(dirEntry);
|
||||
return (currDirectory == NULL) || (currDirectory->data == NULL) ? NULL : (ProcLimiterSet *)currDirectory->data;
|
||||
}
|
||||
|
||||
static struct ProcDirEntry *ProcCreateLimiterFiles(struct ProcDirEntry *parentEntry,
|
||||
struct PLimitsEntryOpt *entryOpt,
|
||||
mode_t mode, void *data)
|
||||
{
|
||||
struct ProcDataParm dataParm = {
|
||||
.data = data,
|
||||
.dataType = PROC_DATA_STATIC,
|
||||
};
|
||||
struct ProcDirEntry *plimitFile = ProcCreateData(entryOpt->name, entryOpt->mode & mode, parentEntry,
|
||||
&entryOpt->ops, &dataParm);
|
||||
if (plimitFile == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return plimitFile;
|
||||
}
|
||||
|
||||
static void ProcLimiterDirEntryInit(struct ProcDirEntry *dirEntry, unsigned mask, mode_t mode)
|
||||
{
|
||||
struct ProcDirEntry *currDir = GetCurrDirectory(dirEntry);
|
||||
if (currDir == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProcLimiterSet *plimiterData = (ProcLimiterSet *)currDir->data;
|
||||
if (plimiterData == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int index = 0; index < (sizeof(g_plimitsEntryOpts) / sizeof(struct PLimitsEntryOpt)); index++) {
|
||||
struct PLimitsEntryOpt *entryOpt = &g_plimitsEntryOpts[index];
|
||||
enum ProcLimiterID plimiterType = entryOpt->id;
|
||||
if (!(BIT(plimiterType) & mask)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
void *head = (entryOpt->offset == UNITPTR_NULL) ?
|
||||
plimiterData : (void *)plimiterData->limitsList[plimiterType];
|
||||
struct ProcDirEntry *entry = ProcCreateLimiterFiles(currDir, entryOpt, mode, head);
|
||||
if (entry == NULL) {
|
||||
RemoveProcEntry(currDir->name, NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static ssize_t PLimitsCopyLimits(struct ProcDirEntry *dirEntry)
|
||||
{
|
||||
struct ProcDirEntry *parentPde = dirEntry->parent;
|
||||
ProcLimiterSet *parentPLimits = (ProcLimiterSet *)parentPde->data;
|
||||
if (parentPLimits == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ProcLimiterSet *newPLimits = OsPLimitsCreate(parentPLimits);
|
||||
if (newPLimits == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
dirEntry->data = (VOID *)newPLimits;
|
||||
dirEntry->dataType = PROC_DATA_STATIC;
|
||||
dirEntry->procDirOps = parentPde->procDirOps;
|
||||
ProcLimiterDirEntryInit(dirEntry, newPLimits->mask, PLIMIT_FILE_MODE_MASK_NONE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ProcfsPlimitsMkdir(struct ProcDirEntry *parent, const char *dirName, mode_t mode, struct ProcDirEntry **pde)
|
||||
{
|
||||
int ret;
|
||||
if (strcmp(parent->name, "plimits") != 0) {
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
struct ProcDirEntry *plimitDir = ProcCreateData(dirName, S_IFDIR | mode, parent, NULL, NULL);
|
||||
if (plimitDir == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = PLimitsCopyLimits(plimitDir);
|
||||
if (ret != LOS_OK) {
|
||||
ProcFreeEntry(plimitDir);
|
||||
return -ENOSYS;
|
||||
}
|
||||
*pde = plimitDir;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ProcfsPlimitsRmdir(struct ProcDirEntry *parent, struct ProcDirEntry *pde, const char *name)
|
||||
{
|
||||
if (pde == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ProcLimiterSet *plimits = GetProcLimiterSetFromDirEntry(pde);
|
||||
pde->data = NULL;
|
||||
|
||||
unsigned ret = OsPLimitsFree(plimits);
|
||||
if (ret != 0) {
|
||||
pde->data = plimits;
|
||||
return -ret;
|
||||
}
|
||||
|
||||
spin_lock(&procfsLock);
|
||||
ProcDetachNode(pde);
|
||||
spin_unlock(&procfsLock);
|
||||
|
||||
RemoveProcEntryTravalsal(pde->subdir);
|
||||
|
||||
ProcFreeEntry(pde);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t ProcLimitsShowLimiters(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
ProcLimiterSet *plimits = (ProcLimiterSet *)data;
|
||||
UINT32 mask;
|
||||
if (plimits == NULL) {
|
||||
return -LOS_NOK;
|
||||
}
|
||||
mask = plimits->mask;
|
||||
|
||||
if (mask & BIT(PROCESS_LIMITER_ID_PIDS)) {
|
||||
LosBufPrintf(seqBuf, "%s ", "pids");
|
||||
}
|
||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
||||
if (mask & BIT(PROCESS_LIMITER_ID_MEM)) {
|
||||
LosBufPrintf(seqBuf, "%s ", "memory");
|
||||
}
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
if (mask & BIT(PROCESS_LIMITER_ID_IPC)) {
|
||||
LosBufPrintf(seqBuf, "%s ", "ipc");
|
||||
}
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
||||
if (mask & BIT(PROCESS_LIMITER_ID_DEV)) {
|
||||
LosBufPrintf(seqBuf, "%s ", "devices");
|
||||
}
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
if (mask & BIT(PROCESS_LIMITER_ID_SCHED)) {
|
||||
LosBufPrintf(seqBuf, "%s ", "sched");
|
||||
}
|
||||
#endif
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#define PLIMITS_PID_STR_LENGTH 4
|
||||
static int ShowPids(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
unsigned int size, pidMax;
|
||||
if (data == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
const ProcLimiterSet *plimits = (const ProcLimiterSet *)data;
|
||||
pidMax = LOS_GetSystemProcessMaximum();
|
||||
size = pidMax * sizeof(unsigned int);
|
||||
unsigned int *pids = (unsigned int *)LOS_MemAlloc(m_aucSysMem1, size);
|
||||
if (pids == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
(void)memset_s(pids, size, 0, size);
|
||||
|
||||
unsigned int ret = OsPLimitsPidsGet(plimits, pids, size);
|
||||
if (ret != LOS_OK) {
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, pids);
|
||||
return -ret;
|
||||
}
|
||||
|
||||
(void)LosBufPrintf(seqBuf, "\n");
|
||||
for (unsigned int index = 0; index < pidMax; index++) {
|
||||
if (pids[index] == 0) {
|
||||
continue;
|
||||
}
|
||||
(void)LosBufPrintf(seqBuf, "%u ", index);
|
||||
}
|
||||
(void)LOS_MemFree(m_aucSysMem1, pids);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long long int GetPidLimitValue(struct ProcFile *pf, const CHAR *buf, size_t count)
|
||||
{
|
||||
long long int value;
|
||||
char *kbuf = NULL;
|
||||
|
||||
if ((pf == NULL) || (pf->pPDE == NULL) || (buf == NULL) || (count <= 0)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
unsigned ret = MemUserCopy(buf, count, &kbuf);
|
||||
if (ret != 0) {
|
||||
return -ret;
|
||||
} else if ((ret == 0) && (kbuf != NULL)) {
|
||||
buf = (const char *)kbuf;
|
||||
}
|
||||
|
||||
if (strspn(buf, "0123456789") != count) {
|
||||
(void)LOS_MemFree(m_aucSysMem1, kbuf);
|
||||
return -EINVAL;
|
||||
}
|
||||
value = strtoll(buf, NULL, 10); /* 10: decimal */
|
||||
(void)LOS_MemFree(m_aucSysMem1, kbuf);
|
||||
return value;
|
||||
}
|
||||
|
||||
static ssize_t PidMigrateFromProcLimiterSet(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
||||
{
|
||||
(VOID)ppos;
|
||||
unsigned ret;
|
||||
|
||||
long long int pid = GetPidLimitValue(pf, buf, count);
|
||||
if (pid < 0) {
|
||||
return pid;
|
||||
}
|
||||
|
||||
ProcLimiterSet *plimits = GetCurrDirectory(pf->pPDE)->data;
|
||||
ret = OsPLimitsAddPid(plimits, (unsigned int)pid);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t PidLimitReadPidLimit(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
PidLimit *pidLimit = (PidLimit *)data;
|
||||
if ((seqBuf == NULL) || (pidLimit == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
(void)LosBufPrintf(seqBuf, "%u\n", pidLimit->pidLimit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t PidLimitReadPriorityLimit(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
PidLimit *pidLimit = (PidLimit *)data;
|
||||
if ((seqBuf == NULL) || (pidLimit == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
(void)LosBufPrintf(seqBuf, "%u\n", pidLimit->priorityLimit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t PriorityLimitVariableWrite(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
||||
{
|
||||
(void)ppos;
|
||||
long long int value = GetPidLimitValue(pf, buf, count);
|
||||
if (value < 0) {
|
||||
return value;
|
||||
}
|
||||
|
||||
PidLimit *pidLimit = (PidLimit *)pf->pPDE->data;
|
||||
unsigned ret = PidLimitSetPriorityLimit(pidLimit, (unsigned)value);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t PidsMaxVariableWrite(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
||||
{
|
||||
(void)ppos;
|
||||
long long int value = GetPidLimitValue(pf, buf, count);
|
||||
if (value < 0) {
|
||||
return value;
|
||||
}
|
||||
|
||||
PidLimit *pidLimit = (PidLimit *)pf->pPDE->data;
|
||||
unsigned ret = PidLimitSetPidLimit(pidLimit, (unsigned)value);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
||||
static ssize_t MemLimitReadLimit(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
ProcMemLimiter *memLimit = (ProcMemLimiter *)data;
|
||||
if ((seqBuf == NULL) || (memLimit == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
(void)LosBufPrintf(seqBuf, "%llu\n", memLimit->limit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t MemLimitWriteLimit(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
||||
{
|
||||
(void)ppos;
|
||||
long long int value = GetPidLimitValue(pf, buf, count);
|
||||
if ((value < 0) || (value > (long long int)OS_NULL_INT)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
ProcMemLimiter *memLimit = (ProcMemLimiter *)pf->pPDE->data;
|
||||
unsigned ret = OsMemLimitSetMemLimit(memLimit, (unsigned long long)value);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t MemLimitStatShow(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
ProcLimiterSet *plimits = (ProcLimiterSet *)data;
|
||||
if ((seqBuf == NULL) || (plimits == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
UINT32 pidMax = LOS_GetSystemProcessMaximum();
|
||||
UINT32 size = sizeof(ProcMemLimiter) + pidMax * sizeof(unsigned long long);
|
||||
unsigned long long *usage = (unsigned long long *)LOS_MemAlloc(m_aucSysMem1, size);
|
||||
if (usage == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
(void)memset_s(usage, size, 0, size);
|
||||
|
||||
unsigned int ret = OsPLimitsMemUsageGet(plimits, usage, size);
|
||||
if (ret != LOS_OK) {
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, usage);
|
||||
return -ret;
|
||||
}
|
||||
|
||||
ProcMemLimiter *memLimit = (ProcMemLimiter *)usage;
|
||||
unsigned long long *memUsage = (unsigned long long *)((uintptr_t)usage + sizeof(ProcMemLimiter));
|
||||
(void)LosBufPrintf(seqBuf, "\nMem used: %llu\n", memLimit->usage);
|
||||
(void)LosBufPrintf(seqBuf, "Mem peak: %llu\n", memLimit->peak);
|
||||
(void)LosBufPrintf(seqBuf, "Mem failed count: %u\n", memLimit->failcnt);
|
||||
|
||||
for (unsigned int index = 0; index < pidMax; index++) {
|
||||
if (memUsage[index] == 0) {
|
||||
continue;
|
||||
}
|
||||
(void)LosBufPrintf(seqBuf, "PID: %u mem used: %llu \n", index, memUsage[index]);
|
||||
}
|
||||
(void)LOS_MemFree(m_aucSysMem1, usage);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
static ssize_t IPCLimitReadMqLimit(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)data;
|
||||
if ((seqBuf == NULL) || (ipcLimit == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
(void)LosBufPrintf(seqBuf, "%u\n", ipcLimit->mqCountLimit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t IPCLimitWriteMqLimit(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
||||
{
|
||||
(void)ppos;
|
||||
long long int value = GetPidLimitValue(pf, buf, count);
|
||||
if (value < 0) {
|
||||
return value;
|
||||
}
|
||||
|
||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)pf->pPDE->data;
|
||||
unsigned ret = OsIPCLimitSetMqLimit(ipcLimit, (unsigned long long)value);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t IPCLimitReadShmLimit(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)data;
|
||||
if ((seqBuf == NULL) || (ipcLimit == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
(void)LosBufPrintf(seqBuf, "%u\n", ipcLimit->shmSizeLimit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t IPCLimitWriteShmLimit(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
||||
{
|
||||
(void)ppos;
|
||||
long long int value = GetPidLimitValue(pf, buf, count);
|
||||
if ((value < 0) || (value > (long long int)OS_NULL_INT)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)pf->pPDE->data;
|
||||
unsigned ret = OsIPCLimitSetShmLimit(ipcLimit, (unsigned long long)value);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t IPCLimitShowStat(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
ProcLimiterSet *plimits = (ProcLimiterSet *)data;
|
||||
if ((seqBuf == NULL) || (plimits == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
unsigned int size = sizeof(ProcIPCLimit);
|
||||
ProcIPCLimit *newIPCLimit = (ProcIPCLimit *)LOS_MemAlloc(m_aucSysMem1, size);
|
||||
if (newIPCLimit == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
(void)memset_s(newIPCLimit, size, 0, size);
|
||||
|
||||
unsigned int ret = OsPLimitsIPCStatGet(plimits, newIPCLimit, size);
|
||||
if (ret != LOS_OK) {
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, newIPCLimit);
|
||||
return -ret;
|
||||
}
|
||||
|
||||
(void)LosBufPrintf(seqBuf, "mq count: %u\n", newIPCLimit->mqCount);
|
||||
(void)LosBufPrintf(seqBuf, "mq failed count: %u\n", newIPCLimit->mqFailedCount);
|
||||
(void)LosBufPrintf(seqBuf, "shm size: %u\n", newIPCLimit->shmSize);
|
||||
(void)LosBufPrintf(seqBuf, "shm failed count: %u\n", newIPCLimit->shmFailedCount);
|
||||
(void)LOS_MemFree(m_aucSysMem1, newIPCLimit);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
||||
static ssize_t DevLimitWriteAllow(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
||||
{
|
||||
(void)ppos;
|
||||
char *kbuf = NULL;
|
||||
|
||||
if ((pf == NULL) || (pf->pPDE == NULL) || (buf == NULL) || (count <= 0)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
unsigned ret = MemUserCopy(buf, count, &kbuf);
|
||||
if (ret != 0) {
|
||||
return -ret;
|
||||
} else if ((ret == 0) && (kbuf != NULL)) {
|
||||
buf = (const char *)kbuf;
|
||||
}
|
||||
|
||||
ProcLimiterSet *plimit = (ProcLimiterSet *)pf->pPDE->data;
|
||||
ret = OsDevLimitWriteAllow(plimit, buf, count);
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, kbuf);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t DevLimitWriteDeny(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
||||
{
|
||||
(void)ppos;
|
||||
char *kbuf = NULL;
|
||||
|
||||
if ((pf == NULL) || (pf->pPDE == NULL) || (buf == NULL) || (count <= 0)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
unsigned ret = MemUserCopy(buf, count, &kbuf);
|
||||
if (ret != 0) {
|
||||
return -ret;
|
||||
} else if ((ret == 0) && (kbuf != NULL)) {
|
||||
buf = (const char *)kbuf;
|
||||
}
|
||||
|
||||
ProcLimiterSet *plimit = (ProcLimiterSet *)pf->pPDE->data;
|
||||
ret = OsDevLimitWriteDeny(plimit, buf, count);
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, kbuf);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t DevLimitShow(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
ProcDevLimit *devLimit = (ProcDevLimit *)data;
|
||||
if ((seqBuf == NULL) || (devLimit == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
unsigned ret = OsDevLimitShow(devLimit, seqBuf);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
static ssize_t SchedLimitReadPeriod(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
ProcSchedLimiter *schedLimit = (ProcSchedLimiter *)data;
|
||||
if ((seqBuf == NULL) || (schedLimit == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
(void)LosBufPrintf(seqBuf, "%lld\n", schedLimit->period);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t SchedLimitWritePeriod(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
||||
{
|
||||
(void)ppos;
|
||||
long long int value = GetPidLimitValue(pf, buf, count);
|
||||
if (value < 0) {
|
||||
return value;
|
||||
}
|
||||
|
||||
ProcSchedLimiter *schedLimit = (ProcSchedLimiter *)pf->pPDE->data;
|
||||
unsigned ret = OsSchedLimitSetPeriod(schedLimit, (unsigned long long)value);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t SchedLimitReadQuota(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
ProcSchedLimiter *schedLimit = (ProcSchedLimiter *)data;
|
||||
if ((seqBuf == NULL) || (schedLimit == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
(void)LosBufPrintf(seqBuf, "%lld\n", schedLimit->quota);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t SchedLimitWriteQuota(struct ProcFile *pf, const CHAR *buf, size_t count, loff_t *ppos)
|
||||
{
|
||||
(void)ppos;
|
||||
long long int value = GetPidLimitValue(pf, buf, count);
|
||||
if (value < 0) {
|
||||
return value;
|
||||
}
|
||||
|
||||
ProcSchedLimiter *schedLimit = (ProcSchedLimiter *)pf->pPDE->data;
|
||||
unsigned ret = OsSchedLimitSetQuota(schedLimit, (unsigned long long)value);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
#define TIME_CYCLE_TO_US(time) ((((UINT64)time) * OS_NS_PER_CYCLE) / OS_SYS_NS_PER_US)
|
||||
#define SCHED_DEFAULT_VALUE (0x101010101010101)
|
||||
|
||||
static ssize_t SchedLimitShow(struct SeqBuf *seqBuf, VOID *data)
|
||||
{
|
||||
ProcLimiterSet *plimits = (ProcLimiterSet *)data;
|
||||
if ((seqBuf == NULL) || (plimits == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
UINT32 pidMax = LOS_GetSystemProcessMaximum();
|
||||
UINT32 size = pidMax * sizeof(unsigned long long);
|
||||
unsigned long long *usage = (unsigned long long *)LOS_MemAlloc(m_aucSysMem1, size);
|
||||
if (usage == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
(void)memset_s(usage, size, 1, size);
|
||||
|
||||
unsigned int ret = OsPLimitsSchedUsageGet(plimits, usage, size);
|
||||
if (ret != LOS_OK) {
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, usage);
|
||||
return -ret;
|
||||
}
|
||||
|
||||
for (unsigned int index = 0; index < pidMax; index++) {
|
||||
if (usage[index] == SCHED_DEFAULT_VALUE) {
|
||||
continue;
|
||||
}
|
||||
(void)LosBufPrintf(seqBuf, "PID: %u runTime: %llu us\n", index, TIME_CYCLE_TO_US(usage[index]));
|
||||
}
|
||||
(void)LOS_MemFree(m_aucSysMem1, usage);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define PROC_PLIMITS_MODE (S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
||||
void ProcLimitsInit(void)
|
||||
{
|
||||
struct ProcDirEntry *parentPDE = CreateProcEntry("plimits", PROC_PLIMITS_MODE, NULL);
|
||||
if (parentPDE == NULL) {
|
||||
return;
|
||||
}
|
||||
ProcLimiterSet *plimits = OsRootPLimitsGet();
|
||||
parentPDE->procDirOps = &g_procDirOperations;
|
||||
parentPDE->data = (VOID *)plimits;
|
||||
parentPDE->dataType = PROC_DATA_STATIC;
|
||||
plimits->mask = BIT(PROCESS_LIMITER_ID_PIDS) | BIT(PROCESS_LIMITER_COUNT);
|
||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
||||
plimits->mask |= BIT(PROCESS_LIMITER_ID_MEM);
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
plimits->mask |= BIT(PROCESS_LIMITER_ID_IPC);
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
||||
plimits->mask |= BIT(PROCESS_LIMITER_ID_DEV);
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
plimits->mask |= BIT(PROCESS_LIMITER_ID_SCHED);
|
||||
#endif
|
||||
ProcLimiterDirEntryInit(parentPDE, plimits->mask, PLIMIT_FILE_MODE_MASK_WRITE);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -72,6 +72,12 @@ void ProcFsInit(void)
|
||||
ProcSysMemInfoInit();
|
||||
ProcFileSysInit();
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
ProcLimitsInit();
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
||||
ProcSysUserInit();
|
||||
#endif
|
||||
}
|
||||
|
||||
LOS_MODULE_INIT(ProcFsInit, LOS_INIT_LEVEL_KMOD_EXTENDED);
|
||||
|
||||
@@ -239,6 +239,53 @@ int VfsProcfsStat(struct Vnode *node, struct stat *buf)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
int VfsProcfsMkdir(struct Vnode *parent, const char *dirName, mode_t mode, struct Vnode **vnode)
|
||||
{
|
||||
struct ProcDirEntry *parentEntry = VnodeToEntry(parent);
|
||||
struct ProcDirEntry *pde = NULL;
|
||||
if ((parentEntry->procDirOps == NULL) || (parentEntry->procDirOps->mkdir == NULL)) {
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
int ret = parentEntry->procDirOps->mkdir(parentEntry, dirName, mode, &pde);
|
||||
if ((ret < 0) || (pde == NULL)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
*vnode = EntryToVnode(pde);
|
||||
(*vnode)->vop = parent->vop;
|
||||
(*vnode)->parent = parent;
|
||||
(*vnode)->originMount = parent->originMount;
|
||||
if ((*vnode)->type == VNODE_TYPE_DIR) {
|
||||
(*vnode)->mode = S_IFDIR | PROCFS_DEFAULT_MODE;
|
||||
} else {
|
||||
(*vnode)->mode = S_IFREG | PROCFS_DEFAULT_MODE;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int VfsProcfsRmdir(struct Vnode *parent, struct Vnode *vnode, const char *dirName)
|
||||
{
|
||||
if (parent == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
struct ProcDirEntry *parentEntry = VnodeToEntry(parent);
|
||||
if ((parentEntry->procDirOps == NULL) || (parentEntry->procDirOps->rmdir == NULL)) {
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
struct ProcDirEntry *dirEntry = VnodeToEntry(vnode);
|
||||
int ret = parentEntry->procDirOps->rmdir(parentEntry, dirEntry, dirName);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
vnode->data = NULL;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int VfsProcfsReaddir(struct Vnode *node, struct fs_dirent_s *dir)
|
||||
{
|
||||
int result;
|
||||
@@ -350,7 +397,7 @@ int VfsProcfsClose(struct file *filep)
|
||||
VnodeHold();
|
||||
struct Vnode *node = filep->f_vnode;
|
||||
struct ProcDirEntry *pde = VnodeToEntry(node);
|
||||
if (pde == NULL) {
|
||||
if ((pde == NULL) || (pde->pf == NULL)) {
|
||||
VnodeDrop();
|
||||
return -EPERM;
|
||||
}
|
||||
@@ -410,6 +457,10 @@ static struct VnodeOps g_procfsVops = {
|
||||
.Closedir = VfsProcfsClosedir,
|
||||
.Truncate = VfsProcfsTruncate,
|
||||
.Readlink = VfsProcfsReadlink,
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
.Mkdir = VfsProcfsMkdir,
|
||||
.Rmdir = VfsProcfsRmdir,
|
||||
#endif
|
||||
};
|
||||
|
||||
static struct file_operations_vfs g_procfsFops = {
|
||||
|
||||
@@ -91,6 +91,8 @@ static ssize_t ProcessContainerLink(unsigned int containerID, ContainerType type
|
||||
count = snprintf_s(buffer, bufLen, bufLen - 1, "'time:[%u]'", containerID);
|
||||
} else if (type == USER_CONTAINER) {
|
||||
count = snprintf_s(buffer, bufLen, bufLen - 1, "'user:[%u]'", containerID);
|
||||
} else if (type == NET_CONTAINER) {
|
||||
count = snprintf_s(buffer, bufLen, bufLen - 1, "'net:[%u]'", containerID);
|
||||
}
|
||||
|
||||
if (count < 0) {
|
||||
@@ -101,6 +103,8 @@ static ssize_t ProcessContainerLink(unsigned int containerID, ContainerType type
|
||||
|
||||
static ssize_t ProcessContainerReadLink(struct ProcDirEntry *entry, char *buffer, size_t bufLen)
|
||||
{
|
||||
char *freeBuf = NULL;
|
||||
char *buf = buffer;
|
||||
ssize_t count;
|
||||
unsigned int intSave;
|
||||
if (entry == NULL) {
|
||||
@@ -110,17 +114,41 @@ static ssize_t ProcessContainerReadLink(struct ProcDirEntry *entry, char *buffer
|
||||
if (data == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (LOS_IsUserAddressRange((VADDR_T)(UINTPTR)buffer, bufLen)) {
|
||||
buf = LOS_MemAlloc(m_aucSysMem1, bufLen);
|
||||
if (buf == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
(void)memset_s(buf, bufLen, 0, bufLen);
|
||||
freeBuf = buf;
|
||||
}
|
||||
|
||||
LosProcessCB *processCB = ProcGetProcessCB(data);
|
||||
SCHEDULER_LOCK(intSave);
|
||||
UINT32 containerID = OsGetContainerID(processCB, (ContainerType)data->type);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
if (containerID != OS_INVALID_VALUE) {
|
||||
return ProcessContainerLink(containerID, (ContainerType)data->type, buffer, bufLen);
|
||||
count = ProcessContainerLink(containerID, (ContainerType)data->type, buf, bufLen);
|
||||
} else {
|
||||
count = strlen("(unknown)");
|
||||
if (memcpy_s(buf, bufLen, "(unknown)", count + 1) != EOK) {
|
||||
(void)LOS_MemFree(m_aucSysMem1, freeBuf);
|
||||
return -EBADF;
|
||||
}
|
||||
}
|
||||
count = strlen("(unknown)");
|
||||
if (memcpy_s(buffer, bufLen, "(unknown)", count + 1) != EOK) {
|
||||
return -EBADF;
|
||||
if (count < 0) {
|
||||
(void)LOS_MemFree(m_aucSysMem1, freeBuf);
|
||||
return count;
|
||||
}
|
||||
|
||||
if (LOS_IsUserAddressRange((VADDR_T)(UINTPTR)buffer, bufLen)) {
|
||||
if (LOS_ArchCopyToUser(buffer, buf, bufLen) != 0) {
|
||||
(void)LOS_MemFree(m_aucSysMem1, freeBuf);
|
||||
return -EFAULT;
|
||||
}
|
||||
}
|
||||
(void)LOS_MemFree(m_aucSysMem1, freeBuf);
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -574,6 +602,14 @@ static struct ProcProcess g_procProcess[] = {
|
||||
.fileOps = &UID_GID_MAP_FOPS
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_IPC_CONTAINER
|
||||
{
|
||||
.name = "container/net",
|
||||
.mode = S_IFLNK,
|
||||
.type = NET_CONTAINER,
|
||||
.fileOps = &PID_CONTAINER_FOPS
|
||||
},
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -588,6 +624,7 @@ void ProcFreeProcessDir(struct ProcDirEntry *processDir)
|
||||
static struct ProcDirEntry *ProcCreatePorcess(UINT32 pid, struct ProcProcess *porcess, uintptr_t processCB)
|
||||
{
|
||||
int ret;
|
||||
struct ProcDataParm dataParm;
|
||||
char pidName[PROC_PID_DIR_LEN] = {0};
|
||||
struct ProcessData *data = (struct ProcessData *)malloc(sizeof(struct ProcessData));
|
||||
if (data == NULL) {
|
||||
@@ -613,7 +650,9 @@ static struct ProcDirEntry *ProcCreatePorcess(UINT32 pid, struct ProcProcess *po
|
||||
|
||||
data->process = processCB;
|
||||
data->type = porcess->type;
|
||||
struct ProcDirEntry *container = ProcCreateData(pidName, porcess->mode, NULL, porcess->fileOps, (void *)data);
|
||||
dataParm.data = data;
|
||||
dataParm.dataType = PROC_DATA_FREE;
|
||||
struct ProcDirEntry *container = ProcCreateData(pidName, porcess->mode, NULL, porcess->fileOps, &dataParm);
|
||||
if (container == NULL) {
|
||||
free(data);
|
||||
PRINT_ERR("create /proc/%s error!\n", pidName);
|
||||
|
||||
228
fs/proc/os_adapt/sys_user.c
Normal file
228
fs/proc/os_adapt/sys_user.c
Normal file
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/statfs.h>
|
||||
#include <sys/mount.h>
|
||||
#include "proc_fs.h"
|
||||
#include "internal.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "user_copy.h"
|
||||
#include "los_memory.h"
|
||||
|
||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
||||
struct ProcSysUser {
|
||||
char *name;
|
||||
mode_t mode;
|
||||
int type;
|
||||
const struct ProcFileOperations *fileOps;
|
||||
};
|
||||
|
||||
static unsigned int MemUserCopy(const char *src, size_t len, char **kbuf)
|
||||
{
|
||||
if (LOS_IsUserAddressRange((VADDR_T)(UINTPTR)src, len)) {
|
||||
char *kernelBuf = LOS_MemAlloc(m_aucSysMem1, len + 1);
|
||||
if (kernelBuf == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (LOS_ArchCopyFromUser(kernelBuf, src, len) != 0) {
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, kernelBuf);
|
||||
return EFAULT;
|
||||
}
|
||||
kernelBuf[len] = '\0';
|
||||
*kbuf = kernelBuf;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int GetContainerLimitValue(struct ProcFile *pf, const CHAR *buf, size_t count)
|
||||
{
|
||||
int value;
|
||||
char *kbuf = NULL;
|
||||
|
||||
if ((pf == NULL) || (pf->pPDE == NULL) || (buf == NULL) || (count <= 0)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
unsigned ret = MemUserCopy(buf, count, &kbuf);
|
||||
if (ret != 0) {
|
||||
return -ret;
|
||||
} else if ((ret == 0) && (kbuf != NULL)) {
|
||||
buf = (const char *)kbuf;
|
||||
}
|
||||
|
||||
if (strspn(buf, "0123456789") != count) {
|
||||
(void)LOS_MemFree(m_aucSysMem1, kbuf);
|
||||
return -EINVAL;
|
||||
}
|
||||
value = atoi(buf);
|
||||
(void)LOS_MemFree(m_aucSysMem1, kbuf);
|
||||
return value;
|
||||
}
|
||||
|
||||
static ssize_t ProcSysUserWrite(struct ProcFile *pf, const char *buf, size_t size, loff_t *ppos)
|
||||
{
|
||||
(void)ppos;
|
||||
unsigned ret;
|
||||
int value = GetContainerLimitValue(pf, buf, size);
|
||||
if (value < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ContainerType type = (ContainerType)(uintptr_t)pf->pPDE->data;
|
||||
ret = OsSetContainerLimit(type, value);
|
||||
if (ret != LOS_OK) {
|
||||
return -EINVAL;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
static int ProcSysUserRead(struct SeqBuf *seqBuf, void *v)
|
||||
{
|
||||
unsigned ret;
|
||||
if ((seqBuf == NULL) || (v == NULL)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
ContainerType type = (ContainerType)(uintptr_t)v;
|
||||
ret = OsGetContainerLimit(type);
|
||||
if (ret == OS_INVALID_VALUE) {
|
||||
return EINVAL;
|
||||
}
|
||||
(void)LosBufPrintf(seqBuf, "\nlimit: %u\n", ret);
|
||||
(void)LosBufPrintf(seqBuf, "count: %u\n", OsGetContainerCount(type));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct ProcFileOperations SYS_USER_OPT = {
|
||||
.read = ProcSysUserRead,
|
||||
.write = ProcSysUserWrite,
|
||||
};
|
||||
|
||||
static struct ProcSysUser g_sysUser[] = {
|
||||
#ifdef LOSCFG_MNT_CONTAINER
|
||||
{
|
||||
.name = "max_mnt_container",
|
||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
||||
.type = MNT_CONTAINER,
|
||||
.fileOps = &SYS_USER_OPT
|
||||
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_PID_CONTAINER
|
||||
{
|
||||
.name = "max_pid_container",
|
||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
||||
.type = PID_CONTAINER,
|
||||
.fileOps = &SYS_USER_OPT
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_USER_CONTAINER
|
||||
{
|
||||
.name = "max_user_container",
|
||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
||||
.type = USER_CONTAINER,
|
||||
.fileOps = &SYS_USER_OPT
|
||||
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_UTS_CONTAINER
|
||||
{
|
||||
.name = "max_uts_container",
|
||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
||||
.type = UTS_CONTAINER,
|
||||
.fileOps = &SYS_USER_OPT
|
||||
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_UTS_CONTAINER
|
||||
{
|
||||
.name = "max_time_container",
|
||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
||||
.type = UTS_CONTAINER,
|
||||
.fileOps = &SYS_USER_OPT
|
||||
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_IPC_CONTAINER
|
||||
{
|
||||
.name = "max_ipc_container",
|
||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
||||
.type = IPC_CONTAINER,
|
||||
.fileOps = &SYS_USER_OPT
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
{
|
||||
.name = "max_net_container",
|
||||
.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
|
||||
.type = NET_CONTAINER,
|
||||
.fileOps = &SYS_USER_OPT
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
static int ProcCreateSysUser(struct ProcDirEntry *parent)
|
||||
{
|
||||
struct ProcDataParm parm;
|
||||
for (int index = 0; index < (sizeof(g_sysUser) / sizeof(struct ProcSysUser)); index++) {
|
||||
struct ProcSysUser *sysUser = &g_sysUser[index];
|
||||
parm.data = (void *)(uintptr_t)sysUser->type;
|
||||
parm.dataType = PROC_DATA_STATIC;
|
||||
struct ProcDirEntry *userFile = ProcCreateData(sysUser->name, sysUser->mode, parent, sysUser->fileOps, &parm);
|
||||
if (userFile == NULL) {
|
||||
PRINT_ERR("create /proc/%s/%s error!\n", parent->name, sysUser->name);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define PROC_SYS_USER_MODE (S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
|
||||
void ProcSysUserInit(void)
|
||||
{
|
||||
struct ProcDirEntry *parentPDE = CreateProcEntry("sys", PROC_SYS_USER_MODE, NULL);
|
||||
if (parentPDE == NULL) {
|
||||
return;
|
||||
}
|
||||
struct ProcDirEntry *pde = CreateProcEntry("user", PROC_SYS_USER_MODE, parentPDE);
|
||||
if (pde == NULL) {
|
||||
PRINT_ERR("create /proc/process error!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int ret = ProcCreateSysUser(pde);
|
||||
if (ret < 0) {
|
||||
PRINT_ERR("Create proc sys user failed!\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -296,7 +296,7 @@ static int ProcAddNode(struct ProcDirEntry *parent, struct ProcDirEntry *pn)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ProcDetachNode(struct ProcDirEntry *pn)
|
||||
void ProcDetachNode(struct ProcDirEntry *pn)
|
||||
{
|
||||
struct ProcDirEntry *parent = pn->parent;
|
||||
struct ProcDirEntry **iter = NULL;
|
||||
@@ -379,7 +379,7 @@ struct ProcDirEntry *CreateProcEntry(const char *name, mode_t mode, struct ProcD
|
||||
return pde;
|
||||
}
|
||||
|
||||
static void ProcEntryClearVnode(struct ProcDirEntry *entry)
|
||||
void ProcEntryClearVnode(struct ProcDirEntry *entry)
|
||||
{
|
||||
struct Vnode *item = NULL;
|
||||
struct Vnode *nextItem = NULL;
|
||||
@@ -404,16 +404,14 @@ static void FreeProcEntry(struct ProcDirEntry *entry)
|
||||
return;
|
||||
}
|
||||
|
||||
ProcEntryClearVnode(entry);
|
||||
|
||||
if (entry->pf != NULL) {
|
||||
free(entry->pf);
|
||||
entry->pf = NULL;
|
||||
}
|
||||
if (entry->data != NULL) {
|
||||
if ((entry->dataType == PROC_DATA_FREE) && (entry->data != NULL)) {
|
||||
free(entry->data);
|
||||
entry->data = NULL;
|
||||
}
|
||||
entry->data = NULL;
|
||||
free(entry);
|
||||
}
|
||||
|
||||
@@ -424,7 +422,7 @@ void ProcFreeEntry(struct ProcDirEntry *pn)
|
||||
}
|
||||
}
|
||||
|
||||
static void RemoveProcEntryTravalsal(struct ProcDirEntry *pn)
|
||||
void RemoveProcEntryTravalsal(struct ProcDirEntry *pn)
|
||||
{
|
||||
if (pn == NULL) {
|
||||
return;
|
||||
@@ -432,6 +430,8 @@ static void RemoveProcEntryTravalsal(struct ProcDirEntry *pn)
|
||||
RemoveProcEntryTravalsal(pn->next);
|
||||
RemoveProcEntryTravalsal(pn->subdir);
|
||||
|
||||
ProcEntryClearVnode(pn);
|
||||
|
||||
ProcFreeEntry(pn);
|
||||
}
|
||||
|
||||
@@ -461,6 +461,9 @@ void RemoveProcEntry(const char *name, struct ProcDirEntry *parent)
|
||||
spin_unlock(&procfsLock);
|
||||
|
||||
RemoveProcEntryTravalsal(pn->subdir);
|
||||
|
||||
ProcEntryClearVnode(pn);
|
||||
|
||||
ProcFreeEntry(pn);
|
||||
}
|
||||
|
||||
@@ -475,14 +478,17 @@ struct ProcDirEntry *ProcMkdir(const char *name, struct ProcDirEntry *parent)
|
||||
}
|
||||
|
||||
struct ProcDirEntry *ProcCreateData(const char *name, mode_t mode, struct ProcDirEntry *parent,
|
||||
const struct ProcFileOperations *procFileOps, void *data)
|
||||
const struct ProcFileOperations *procFileOps, struct ProcDataParm *param)
|
||||
{
|
||||
struct ProcDirEntry *pde = CreateProcEntry(name, mode, parent);
|
||||
if (pde != NULL) {
|
||||
if (procFileOps != NULL) {
|
||||
pde->procFileOps = procFileOps;
|
||||
}
|
||||
pde->data = data;
|
||||
if (param != NULL) {
|
||||
pde->data = param->data;
|
||||
pde->dataType = param->dataType;
|
||||
}
|
||||
}
|
||||
return pde;
|
||||
}
|
||||
@@ -644,7 +650,6 @@ int WriteProcFile(struct ProcDirEntry *pde, const void *buf, size_t len)
|
||||
result = pde->procFileOps->write(pde->pf, (const char *)buf, len, &(pde->pf->fPos));
|
||||
}
|
||||
spin_unlock(&procfsLock);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_RAMFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_ROMFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
|
||||
@@ -28,17 +28,14 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_VFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"$LITEOSTOPDIR/fs/vfs/epoll/fs_epoll.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/mount.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/path_cache.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/vnode.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/vnode_hash.c",
|
||||
"epoll/fs_epoll.c",
|
||||
"mount.c",
|
||||
"operation/fullpath.c",
|
||||
"operation/vfs_chattr.c",
|
||||
"operation/vfs_check.c",
|
||||
@@ -55,7 +52,10 @@ kernel_module(module_name) {
|
||||
"operation/vfs_readv.c",
|
||||
"operation/vfs_utime.c",
|
||||
"operation/vfs_writev.c",
|
||||
"path_cache.c",
|
||||
"vfs_cmd/vfs_shellcmd.c",
|
||||
"vnode.c",
|
||||
"vnode_hash.c",
|
||||
]
|
||||
sources += NUTTX_FS_DIRENT_SRC_FILES
|
||||
sources += NUTTX_FS_DRIVER_SRC_FILES
|
||||
|
||||
@@ -138,7 +138,7 @@ int VnodeAlloc(struct VnodeOps *vop, struct Vnode **newVnode)
|
||||
VnodeHold();
|
||||
vnode = GetFromFreeList();
|
||||
if ((vnode == NULL) && g_totalVnodeSize < LOSCFG_MAX_VNODE_SIZE) {
|
||||
vnode = (struct Vnode*)zalloc(sizeof(struct Vnode));
|
||||
vnode = (struct Vnode *)zalloc(sizeof(struct Vnode));
|
||||
g_totalVnodeSize++;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,46 +67,6 @@ config PAGE_TABLE_FINE_LOCK
|
||||
help
|
||||
This option will enable fine lock for page table.
|
||||
|
||||
######################### config options of container ####################
|
||||
config KERNEL_CONTAINER
|
||||
bool "Enable container Feature"
|
||||
default n
|
||||
depends on KERNEL_VM
|
||||
|
||||
config PID_CONTAINER
|
||||
bool "Enable pid container Feature"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
config UTS_CONTAINER
|
||||
bool "Enable uts container Feature"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
config MNT_CONTAINER
|
||||
bool "Enable mnt container Feature"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
config CHROOT
|
||||
bool "Enable chroot"
|
||||
default n
|
||||
depends on MNT_CONTAINER
|
||||
|
||||
config IPC_CONTAINER
|
||||
bool "Enable ipc container Feature"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
config TIME_CONTAINER
|
||||
bool "Enable time container"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
config USER_CONTAINER
|
||||
bool "Enable user container"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
######################### config options of extended #####################
|
||||
source "kernel/extended/Kconfig"
|
||||
|
||||
@@ -32,14 +32,6 @@ import("//kernel/liteos_a/liteos.gni")
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"container/los_container.c",
|
||||
"container/los_credentials.c",
|
||||
"container/los_ipc_container.c",
|
||||
"container/los_mnt_container.c",
|
||||
"container/los_pid_container.c",
|
||||
"container/los_time_container.c",
|
||||
"container/los_user_container.c",
|
||||
"container/los_uts_container.c",
|
||||
"core/los_bitmap.c",
|
||||
"core/los_info.c",
|
||||
"core/los_process.c",
|
||||
@@ -75,6 +67,7 @@ kernel_module(module_name) {
|
||||
"mp/los_percpu.c",
|
||||
"mp/los_spinlock.c",
|
||||
"om/los_err.c",
|
||||
"sched/los_deadline.c",
|
||||
"sched/los_idle.c",
|
||||
"sched/los_priority.c",
|
||||
"sched/los_sched.c",
|
||||
|
||||
@@ -39,7 +39,6 @@ LOCAL_SRCS := $(wildcard ipc/*.c) $(wildcard core/*.c) $(wildcard mem/membox/*.
|
||||
$(wildcard mp/*.c) \
|
||||
$(wildcard sched/*.c) \
|
||||
$(wildcard vm/*.c) \
|
||||
$(wildcard container/*.c)
|
||||
|
||||
|
||||
LOCAL_FLAGS := $(LITEOS_CFLAGS_INTERWORK) -Wno-frame-address
|
||||
|
||||
@@ -109,6 +109,7 @@ STATIC VOID GetProcessInfo(ProcessInfo *pcbInfo, const LosProcessCB *processCB)
|
||||
(VOID)memcpy_s(pcbInfo->name, OS_PCB_NAME_LEN, processCB->processName, OS_PCB_NAME_LEN);
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC VOID GetProcessMemInfo(ProcessInfo *pcbInfo, const LosProcessCB *processCB, LosVmSpace *vmSpace)
|
||||
{
|
||||
/* Process memory usage statistics, idle task defaults to 0 */
|
||||
@@ -130,6 +131,7 @@ STATIC VOID GetProcessMemInfo(ProcessInfo *pcbInfo, const LosProcessCB *processC
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC VOID GetThreadInfo(ProcessThreadInfo *threadInfo, LosProcessCB *processCB)
|
||||
{
|
||||
@@ -182,7 +184,9 @@ UINT32 OsGetProcessThreadInfo(UINT32 pid, ProcessThreadInfo *threadInfo)
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
GetProcessMemInfo(&threadInfo->processInfo, processCB, processCB->vmSpace);
|
||||
#endif
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
GetProcessInfo(&threadInfo->processInfo, processCB);
|
||||
@@ -210,11 +214,14 @@ STATIC VOID ProcessMemUsageGet(ProcessInfo *pcbArray)
|
||||
pcbInfo->status = OS_PROCESS_FLAG_UNUSED;
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosVmSpace *vmSpace = processCB->vmSpace;
|
||||
#endif
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
GetProcessMemInfo(pcbInfo, processCB, vmSpace);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -442,7 +442,7 @@ LITE_OS_SEC_TEXT VOID OsProcessResourcesToFree(LosProcessCB *processCB)
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
||||
OsContainersDestroy(processCB);
|
||||
OsOsContainersDestroyEarly(processCB);
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
@@ -452,6 +452,13 @@ LITE_OS_SEC_TEXT VOID OsProcessResourcesToFree(LosProcessCB *processCB)
|
||||
processCB->files = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
||||
OsContainersDestroy(processCB);
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
OsPLimitsDeleteProcess(processCB);
|
||||
#endif
|
||||
if (processCB->resourceLimit != NULL) {
|
||||
(VOID)LOS_MemFree((VOID *)m_aucSysMem0, processCB->resourceLimit);
|
||||
processCB->resourceLimit = NULL;
|
||||
@@ -606,7 +613,9 @@ UINT32 OsProcessInit(VOID)
|
||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
||||
OsInitRootContainer();
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
OsProcLimiterSetInit();
|
||||
#endif
|
||||
SystemProcessEarlyInit(OsGetIdleProcess());
|
||||
SystemProcessEarlyInit(OsGetUserInitProcess());
|
||||
SystemProcessEarlyInit(OsGetKernelInitProcess());
|
||||
@@ -883,6 +892,13 @@ STATIC UINT32 OsSystemProcessInit(LosProcessCB *processCB, UINT32 flags, const C
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
ret = OsPLimitsAddProcess(NULL, processCB);
|
||||
if (ret != LOS_OK) {
|
||||
ret = LOS_ENOMEM;
|
||||
goto EXIT;
|
||||
}
|
||||
#endif
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
@@ -923,7 +939,37 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSystemProcessCreate(VOID)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC INLINE INT32 OsProcessSchedlerParamCheck(INT32 which, INT32 pid, UINT16 prio, UINT16 policy)
|
||||
INT32 OsSchedulerParamCheck(UINT16 policy, BOOL isThread, const LosSchedParam *param)
|
||||
{
|
||||
if (param == NULL) {
|
||||
return LOS_EINVAL;
|
||||
}
|
||||
|
||||
if ((policy == LOS_SCHED_RR) || (isThread && (policy == LOS_SCHED_FIFO))) {
|
||||
if ((param->priority < OS_PROCESS_PRIORITY_HIGHEST) ||
|
||||
(param->priority > OS_PROCESS_PRIORITY_LOWEST)) {
|
||||
return LOS_EINVAL;
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (policy == LOS_SCHED_DEADLINE) {
|
||||
if ((param->runTimeUs < OS_SCHED_EDF_MIN_RUNTIME) || (param->runTimeUs >= param->deadlineUs)) {
|
||||
return LOS_EINVAL;
|
||||
}
|
||||
if ((param->deadlineUs < OS_SCHED_EDF_MIN_DEADLINE) || (param->deadlineUs > OS_SCHED_EDF_MAX_DEADLINE)) {
|
||||
return LOS_EINVAL;
|
||||
}
|
||||
if (param->periodUs < param->deadlineUs) {
|
||||
return LOS_EINVAL;
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
return LOS_EINVAL;
|
||||
}
|
||||
|
||||
STATIC INLINE INT32 ProcessSchedulerParamCheck(INT32 which, INT32 pid, UINT16 policy, const LosSchedParam *param)
|
||||
{
|
||||
if (OS_PID_CHECK_INVALID(pid)) {
|
||||
return LOS_EINVAL;
|
||||
@@ -933,19 +979,11 @@ STATIC INLINE INT32 OsProcessSchedlerParamCheck(INT32 which, INT32 pid, UINT16 p
|
||||
return LOS_EINVAL;
|
||||
}
|
||||
|
||||
if (prio > OS_PROCESS_PRIORITY_LOWEST) {
|
||||
return LOS_EINVAL;
|
||||
}
|
||||
|
||||
if (policy != LOS_SCHED_RR) {
|
||||
return LOS_EINVAL;
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
return OsSchedulerParamCheck(policy, FALSE, param);
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_SECURITY_CAPABILITY
|
||||
STATIC BOOL OsProcessCapPermitCheck(const LosProcessCB *processCB, const SchedParam *param, UINT16 prio)
|
||||
STATIC BOOL OsProcessCapPermitCheck(const LosProcessCB *processCB, const SchedParam *param, UINT16 policy, UINT16 prio)
|
||||
{
|
||||
LosProcessCB *runProcess = OsCurrProcessGet();
|
||||
|
||||
@@ -955,7 +993,7 @@ STATIC BOOL OsProcessCapPermitCheck(const LosProcessCB *processCB, const SchedPa
|
||||
}
|
||||
|
||||
/* user mode process can reduce the priority of itself */
|
||||
if ((runProcess->processID == processCB->processID) && (prio > param->basePrio)) {
|
||||
if ((runProcess->processID == processCB->processID) && (policy == LOS_SCHED_RR) && (prio > param->basePrio)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -967,12 +1005,13 @@ STATIC BOOL OsProcessCapPermitCheck(const LosProcessCB *processCB, const SchedPa
|
||||
}
|
||||
#endif
|
||||
|
||||
LITE_OS_SEC_TEXT INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 prio, UINT16 policy)
|
||||
LITE_OS_SEC_TEXT INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 policy, const LosSchedParam *schedParam)
|
||||
{
|
||||
SchedParam param = { 0 };
|
||||
BOOL needSched = FALSE;
|
||||
UINT32 intSave;
|
||||
|
||||
INT32 ret = OsProcessSchedlerParamCheck(which, pid, prio, policy);
|
||||
INT32 ret = ProcessSchedulerParamCheck(which, pid, policy, schedParam);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
@@ -980,22 +1019,45 @@ LITE_OS_SEC_TEXT INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 prio
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(pid);
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (OsProcessIsInactive(processCB)) {
|
||||
ret = LOS_ESRCH;
|
||||
goto EXIT;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return -LOS_ESRCH;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_SECURITY_CAPABILITY
|
||||
if (!OsProcessCapPermitCheck(processCB, ¶m, prio)) {
|
||||
ret = LOS_EPERM;
|
||||
goto EXIT;
|
||||
}
|
||||
#endif
|
||||
|
||||
LosTaskCB *taskCB = processCB->threadGroup;
|
||||
taskCB->ops->schedParamGet(taskCB, ¶m);
|
||||
param.basePrio = prio;
|
||||
|
||||
BOOL needSched = taskCB->ops->schedParamModify(taskCB, ¶m);
|
||||
#ifdef LOSCFG_SECURITY_CAPABILITY
|
||||
if (!OsProcessCapPermitCheck(processCB, ¶m, policy, schedParam->priority)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return -LOS_EPERM;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (param.policy != policy) {
|
||||
if (policy == LOS_SCHED_DEADLINE) { /* HPF -> EDF */
|
||||
if (processCB->threadNumber > 1) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return -LOS_EPERM;
|
||||
}
|
||||
OsSchedParamInit(taskCB, policy, NULL, schedParam);
|
||||
needSched = TRUE;
|
||||
goto TO_SCHED;
|
||||
} else if (param.policy == LOS_SCHED_DEADLINE) { /* EDF -> HPF */
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return -LOS_EPERM;
|
||||
}
|
||||
}
|
||||
|
||||
if (policy == LOS_SCHED_DEADLINE) {
|
||||
param.runTimeUs = schedParam->runTimeUs;
|
||||
param.deadlineUs = schedParam->deadlineUs;
|
||||
param.periodUs = schedParam->periodUs;
|
||||
} else {
|
||||
param.basePrio = schedParam->priority;
|
||||
}
|
||||
needSched = taskCB->ops->schedParamModify(taskCB, ¶m);
|
||||
|
||||
TO_SCHED:
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
LOS_MpSchedule(OS_MP_CPU_ALL);
|
||||
@@ -1003,25 +1065,26 @@ LITE_OS_SEC_TEXT INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 prio
|
||||
LOS_Schedule();
|
||||
}
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return -ret;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT INT32 LOS_SetProcessScheduler(INT32 pid, UINT16 policy, UINT16 prio)
|
||||
LITE_OS_SEC_TEXT INT32 LOS_SetProcessScheduler(INT32 pid, UINT16 policy, const LosSchedParam *schedParam)
|
||||
{
|
||||
return OsSetProcessScheduler(LOS_PRIO_PROCESS, pid, prio, policy);
|
||||
return OsSetProcessScheduler(LOS_PRIO_PROCESS, pid, policy, schedParam);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT INT32 LOS_GetProcessScheduler(INT32 pid)
|
||||
LITE_OS_SEC_TEXT INT32 LOS_GetProcessScheduler(INT32 pid, INT32 *policy, LosSchedParam *schedParam)
|
||||
{
|
||||
UINT32 intSave;
|
||||
SchedParam param = { 0 };
|
||||
|
||||
if (OS_PID_CHECK_INVALID(pid)) {
|
||||
return -LOS_EINVAL;
|
||||
}
|
||||
|
||||
if ((policy == NULL) && (schedParam == NULL)) {
|
||||
return -LOS_EINVAL;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(pid);
|
||||
if (OsProcessIsUnused(processCB)) {
|
||||
@@ -1029,14 +1092,48 @@ LITE_OS_SEC_TEXT INT32 LOS_GetProcessScheduler(INT32 pid)
|
||||
return -LOS_ESRCH;
|
||||
}
|
||||
|
||||
LosTaskCB *taskCB = processCB->threadGroup;
|
||||
taskCB->ops->schedParamGet(taskCB, ¶m);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
return LOS_SCHED_RR;
|
||||
if (policy != NULL) {
|
||||
if (param.policy == LOS_SCHED_FIFO) {
|
||||
*policy = LOS_SCHED_RR;
|
||||
} else {
|
||||
*policy = param.policy;
|
||||
}
|
||||
}
|
||||
|
||||
if (schedParam != NULL) {
|
||||
if (param.policy == LOS_SCHED_DEADLINE) {
|
||||
schedParam->runTimeUs = param.runTimeUs;
|
||||
schedParam->deadlineUs = param.deadlineUs;
|
||||
schedParam->periodUs = param.periodUs;
|
||||
} else {
|
||||
schedParam->priority = param.basePrio;
|
||||
}
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT INT32 LOS_SetProcessPriority(INT32 pid, UINT16 prio)
|
||||
LITE_OS_SEC_TEXT INT32 LOS_SetProcessPriority(INT32 pid, INT32 prio)
|
||||
{
|
||||
return OsSetProcessScheduler(LOS_PRIO_PROCESS, pid, prio, LOS_GetProcessScheduler(pid));
|
||||
INT32 ret;
|
||||
INT32 policy;
|
||||
LosSchedParam param = {
|
||||
.priority = prio,
|
||||
};
|
||||
|
||||
ret = LOS_GetProcessScheduler(pid, &policy, NULL);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (policy == LOS_SCHED_DEADLINE) {
|
||||
return -LOS_EINVAL;
|
||||
}
|
||||
|
||||
return OsSetProcessScheduler(LOS_PRIO_PROCESS, pid, (UINT16)policy, ¶m);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT INT32 OsGetProcessPriority(INT32 which, INT32 pid)
|
||||
@@ -1063,6 +1160,11 @@ LITE_OS_SEC_TEXT INT32 OsGetProcessPriority(INT32 which, INT32 pid)
|
||||
LosTaskCB *taskCB = processCB->threadGroup;
|
||||
taskCB->ops->schedParamGet(taskCB, ¶m);
|
||||
|
||||
if (param.policy == LOS_SCHED_DEADLINE) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return -LOS_EINVAL;
|
||||
}
|
||||
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return param.basePrio;
|
||||
}
|
||||
@@ -1834,6 +1936,38 @@ STATIC UINT32 OsCopyUser(LosProcessCB *childCB, LosProcessCB *parentCB)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID GetCopyTaskParam(LosProcessCB *childProcessCB, UINTPTR entry, UINT32 size,
|
||||
TSK_INIT_PARAM_S *taskParam, SchedParam *param)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosTaskCB *runTask = OsCurrTaskGet();
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (OsProcessIsUserMode(childProcessCB)) {
|
||||
taskParam->pfnTaskEntry = runTask->taskEntry;
|
||||
taskParam->uwStackSize = runTask->stackSize;
|
||||
taskParam->userParam.userArea = runTask->userArea;
|
||||
taskParam->userParam.userMapBase = runTask->userMapBase;
|
||||
taskParam->userParam.userMapSize = runTask->userMapSize;
|
||||
} else {
|
||||
taskParam->pfnTaskEntry = (TSK_ENTRY_FUNC)entry;
|
||||
taskParam->uwStackSize = size;
|
||||
}
|
||||
if (runTask->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN) {
|
||||
taskParam->uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
}
|
||||
|
||||
runTask->ops->schedParamGet(runTask, param);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
taskParam->policy = param->policy;
|
||||
taskParam->runTimeUs = param->runTimeUs;
|
||||
taskParam->deadlineUs = param->deadlineUs;
|
||||
taskParam->periodUs = param->periodUs;
|
||||
taskParam->usTaskPrio = param->priority;
|
||||
taskParam->processID = (UINTPTR)childProcessCB;
|
||||
}
|
||||
|
||||
STATIC UINT32 OsCopyTask(UINT32 flags, LosProcessCB *childProcessCB, const CHAR *name, UINTPTR entry, UINT32 size)
|
||||
{
|
||||
LosTaskCB *runTask = OsCurrTaskGet();
|
||||
@@ -1841,28 +1975,8 @@ STATIC UINT32 OsCopyTask(UINT32 flags, LosProcessCB *childProcessCB, const CHAR
|
||||
UINT32 ret, taskID, intSave;
|
||||
SchedParam param = { 0 };
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (OsProcessIsUserMode(childProcessCB)) {
|
||||
taskParam.pfnTaskEntry = runTask->taskEntry;
|
||||
taskParam.uwStackSize = runTask->stackSize;
|
||||
taskParam.userParam.userArea = runTask->userArea;
|
||||
taskParam.userParam.userMapBase = runTask->userMapBase;
|
||||
taskParam.userParam.userMapSize = runTask->userMapSize;
|
||||
} else {
|
||||
taskParam.pfnTaskEntry = (TSK_ENTRY_FUNC)entry;
|
||||
taskParam.uwStackSize = size;
|
||||
}
|
||||
if (runTask->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN) {
|
||||
taskParam.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
}
|
||||
|
||||
runTask->ops->schedParamGet(runTask, ¶m);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
taskParam.pcName = (CHAR *)name;
|
||||
taskParam.policy = param.policy;
|
||||
taskParam.usTaskPrio = param.priority;
|
||||
taskParam.processID = (UINTPTR)childProcessCB;
|
||||
GetCopyTaskParam(childProcessCB, entry, size, &taskParam, ¶m);
|
||||
|
||||
ret = LOS_TaskCreateOnly(&taskID, &taskParam);
|
||||
if (ret != LOS_OK) {
|
||||
@@ -2066,6 +2180,13 @@ STATIC INT32 OsCopyProcess(UINT32 flags, const CHAR *name, UINTPTR sp, UINT32 si
|
||||
if (ret != LOS_OK) {
|
||||
goto ERROR_INIT;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
ret = OsPLimitsAddProcess(run->plimits, child);
|
||||
if (ret != LOS_OK) {
|
||||
goto ERROR_INIT;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ret = OsForkInitPCB(flags, child, name, sp, size);
|
||||
@@ -2134,6 +2255,9 @@ LITE_OS_SEC_TEXT INT32 OsClone(UINT32 flags, UINTPTR sp, UINT32 size)
|
||||
#ifdef LOSCFG_USER_CONTAINER
|
||||
cloneFlag |= CLONE_NEWUSER;
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
cloneFlag |= CLONE_NEWNET;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (flags & (~cloneFlag)) {
|
||||
|
||||
@@ -583,7 +583,7 @@ STATIC INLINE BOOL SwtmrRunqueueFind(SortLinkAttribute *swtmrSortLink, SCHED_TL_
|
||||
STATIC BOOL SwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
|
||||
{
|
||||
for (UINT16 cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) {
|
||||
SortLinkAttribute *swtmrSortLink = &g_swtmrRunqueue[ArchCurrCpuid()].swtmrSortLink;
|
||||
SortLinkAttribute *swtmrSortLink = &g_swtmrRunqueue[cpuid].swtmrSortLink;
|
||||
if (SwtmrRunqueueFind(swtmrSortLink, checkFunc, arg)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ STATIC VOID OsTaskResourcesToFree(LosTaskCB *taskCB)
|
||||
return;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsTaskCBRecycleToFree()
|
||||
LITE_OS_SEC_TEXT VOID OsTaskCBRecycleToFree(void)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
@@ -543,6 +543,7 @@ STATIC UINT32 TaskCBInit(LosTaskCB *taskCB, const TSK_INIT_PARAM_S *initParam)
|
||||
UINT32 ret;
|
||||
UINT32 numCount;
|
||||
SchedParam schedParam = { 0 };
|
||||
LosSchedParam initSchedParam = {0};
|
||||
UINT16 policy = (initParam->policy == LOS_SCHED_NORMAL) ? LOS_SCHED_RR : initParam->policy;
|
||||
|
||||
TaskCBBaseInit(taskCB, initParam);
|
||||
@@ -553,7 +554,14 @@ STATIC UINT32 TaskCBInit(LosTaskCB *taskCB, const TSK_INIT_PARAM_S *initParam)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = OsSchedParamInit(taskCB, policy, &schedParam, initParam);
|
||||
if (policy == LOS_SCHED_DEADLINE) {
|
||||
initSchedParam.runTimeUs = initParam->runTimeUs;
|
||||
initSchedParam.deadlineUs = initParam->deadlineUs;
|
||||
initSchedParam.periodUs = initParam->periodUs;
|
||||
} else {
|
||||
initSchedParam.priority = initParam->usTaskPrio;
|
||||
}
|
||||
ret = OsSchedParamInit(taskCB, policy, &schedParam, &initSchedParam);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
@@ -1365,6 +1373,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCreateUserTask(UINTPTR processID, TSK_INIT_PARAM_
|
||||
UINT32 taskID;
|
||||
UINT32 ret;
|
||||
UINT32 intSave;
|
||||
INT32 policy;
|
||||
SchedParam param;
|
||||
|
||||
ret = OsCreateUserTaskParamCheck(processID, initParam);
|
||||
if (ret != LOS_OK) {
|
||||
@@ -1373,14 +1383,25 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCreateUserTask(UINTPTR processID, TSK_INIT_PARAM_
|
||||
|
||||
initParam->uwStackSize = OS_USER_TASK_SYSCALL_STACK_SIZE;
|
||||
initParam->usTaskPrio = OS_TASK_PRIORITY_LOWEST;
|
||||
initParam->policy = LOS_SCHED_RR;
|
||||
if (processID == OS_INVALID_VALUE) {
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LosProcessCB *processCB = OsCurrProcessGet();
|
||||
initParam->processID = (UINTPTR)processCB;
|
||||
initParam->consoleID = processCB->consoleID;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
ret = LOS_GetProcessScheduler(processCB->processID, &policy, NULL);
|
||||
if (ret != LOS_OK) {
|
||||
return OS_INVALID_VALUE;
|
||||
}
|
||||
initParam->policy = policy;
|
||||
if (policy == LOS_SCHED_DEADLINE) {
|
||||
OsSchedProcessDefaultSchedParamGet((UINT16)policy, ¶m);
|
||||
initParam->runTimeUs = param.runTimeUs;
|
||||
initParam->deadlineUs = param.deadlineUs;
|
||||
initParam->periodUs = param.periodUs;
|
||||
}
|
||||
} else {
|
||||
initParam->policy = LOS_SCHED_RR;
|
||||
initParam->processID = processID;
|
||||
initParam->consoleID = 0;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,9 @@
|
||||
#ifdef LOSCFG_TIME_CONTAINER
|
||||
#include "los_time_container_pri.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
#include "los_net_container_pri.h"
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
CONTAINER = 0,
|
||||
@@ -62,6 +65,7 @@ typedef enum {
|
||||
USER_CONTAINER,
|
||||
TIME_CONTAINER,
|
||||
TIME_CHILD_CONTAINER,
|
||||
NET_CONTAINER,
|
||||
CONTAINER_MAX,
|
||||
} ContainerType;
|
||||
|
||||
@@ -84,14 +88,43 @@ typedef struct Container {
|
||||
struct TimeContainer *timeContainer;
|
||||
struct TimeContainer *timeForChildContainer;
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
struct NetContainer *netContainer;
|
||||
#endif
|
||||
} Container;
|
||||
|
||||
typedef struct TagContainerLimit {
|
||||
#ifdef LOSCFG_PID_CONTAINER
|
||||
UINT32 pidLimit;
|
||||
#endif
|
||||
#ifdef LOSCFG_UTS_CONTAINER
|
||||
UINT32 utsLimit;
|
||||
#endif
|
||||
#ifdef LOSCFG_MNT_CONTAINER
|
||||
UINT32 mntLimit;
|
||||
#endif
|
||||
#ifdef LOSCFG_IPC_CONTAINER
|
||||
UINT32 ipcLimit;
|
||||
#endif
|
||||
#ifdef LOSCFG_TIME_CONTAINER
|
||||
UINT32 timeLimit;
|
||||
#endif
|
||||
#ifdef LOSCFG_USER_CONTAINER
|
||||
UINT32 userLimit;
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
UINT32 netLimit;
|
||||
#endif
|
||||
} ContainerLimit;
|
||||
|
||||
VOID OsContainerInitSystemProcess(LosProcessCB *processCB);
|
||||
|
||||
VOID OsInitRootContainer(VOID);
|
||||
|
||||
UINT32 OsCopyContainers(UINTPTR flags, LosProcessCB *child, LosProcessCB *parent, UINT32 *processID);
|
||||
|
||||
VOID OsOsContainersDestroyEarly(LosProcessCB *processCB);
|
||||
|
||||
VOID OsContainersDestroy(LosProcessCB *processCB);
|
||||
|
||||
VOID OsContainerFree(LosProcessCB *processCB);
|
||||
@@ -104,5 +137,12 @@ INT32 OsUnshare(UINT32 flags);
|
||||
|
||||
INT32 OsSetNs(INT32 fd, INT32 type);
|
||||
|
||||
UINT32 OsGetContainerLimit(ContainerType type);
|
||||
|
||||
UINT32 OsContainerLimitCheck(ContainerType type, UINT32 *containerCount);
|
||||
|
||||
UINT32 OsSetContainerLimit(ContainerType type, UINT32 value);
|
||||
|
||||
UINT32 OsGetContainerCount(ContainerType type);
|
||||
#endif
|
||||
#endif /* _LOS_CONTAINER_PRI_H */
|
||||
|
||||
@@ -72,6 +72,8 @@ UINT32 OsGetIpcContainerID(IpcContainer *ipcContainer);
|
||||
|
||||
IpcContainer *OsGetCurrIpcContainer(VOID);
|
||||
|
||||
UINT32 OsGetIpcContainerCount(VOID);
|
||||
|
||||
#define IPC_ALL_QUEUE (OsGetCurrIpcContainer()->allQueue)
|
||||
|
||||
#define FREE_QUEUE_LIST (OsGetCurrIpcContainer()->freeQueueList)
|
||||
|
||||
@@ -61,5 +61,6 @@ VOID OsMntContainerDestroy(struct Container *container);
|
||||
|
||||
UINT32 OsGetMntContainerID(MntContainer *mntContainer);
|
||||
|
||||
UINT32 OsGetMntContainerCount(VOID);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
62
kernel/base/include/los_net_container_pri.h
Normal file
62
kernel/base/include/los_net_container_pri.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_NET_CONTAINER_PRI_H
|
||||
#define _LOS_NET_CONTAINER_PRI_H
|
||||
#include <lwip/net_group.h>
|
||||
#include <lwip/netif.h>
|
||||
#include <lwip/ip.h>
|
||||
#include "los_atomic.h"
|
||||
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
typedef struct ProcessCB LosProcessCB;
|
||||
struct Container;
|
||||
|
||||
typedef struct NetContainer {
|
||||
Atomic rc;
|
||||
struct net_group *group;
|
||||
UINT32 containerID;
|
||||
} NetContainer;
|
||||
|
||||
UINT32 OsInitRootNetContainer(NetContainer **ipcContainer);
|
||||
|
||||
UINT32 OsCopyNetContainer(UINTPTR flags, LosProcessCB *child, LosProcessCB *parent);
|
||||
|
||||
UINT32 OsUnshareNetContainer(UINTPTR flags, LosProcessCB *curr, struct Container *newContainer);
|
||||
|
||||
UINT32 OsSetNsNetContainer(UINT32 flags, struct Container *container, struct Container *newContainer);
|
||||
|
||||
VOID OsNetContainerDestroy(struct Container *container);
|
||||
|
||||
UINT32 OsGetNetContainerID(NetContainer *ipcContainer);
|
||||
|
||||
UINT32 OsGetNetContainerCount(VOID);
|
||||
#endif
|
||||
#endif /* _LOS_NET_CONTAINER_PRI_H */
|
||||
@@ -106,4 +106,6 @@ UINT32 OsAllocVtid(LosTaskCB *taskCB, const LosProcessCB *processCB);
|
||||
UINT32 OsGetPidContainerID(PidContainer *pidContainer);
|
||||
|
||||
BOOL OsPidContainerProcessParentIsRealParent(const LosProcessCB *processCB, const LosProcessCB *curr);
|
||||
|
||||
UINT32 OsGetPidContainerCount(VOID);
|
||||
#endif /* _LOS_PID_CONTAINER_PRI_H */
|
||||
|
||||
@@ -50,6 +50,9 @@
|
||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
||||
#include "los_container_pri.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
#include "los_plimits.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -139,6 +142,11 @@ typedef struct ProcessCB {
|
||||
#ifdef LOSCFG_PROC_PROCESS_DIR
|
||||
struct ProcDirEntry *procDir;
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
ProcLimiterSet *plimits;
|
||||
LOS_DL_LIST plimitsList; /* plimit process list */
|
||||
PLimitsData limitStat;
|
||||
#endif
|
||||
} LosProcessCB;
|
||||
|
||||
extern LosProcessCB *g_processCBArray;
|
||||
@@ -527,7 +535,7 @@ extern LosVmSpace *OsExecProcessVmSpaceReplace(LosVmSpace *newSpace, UINTPTR sta
|
||||
extern UINT32 OsExecRecycleAndInit(LosProcessCB *processCB, const CHAR *name, LosVmSpace *oldAspace, UINTPTR oldFiles);
|
||||
extern UINT32 OsExecStart(const TSK_ENTRY_FUNC entry, UINTPTR sp, UINTPTR mapBase, UINT32 mapSize);
|
||||
extern UINT32 OsSetProcessName(LosProcessCB *processCB, const CHAR *name);
|
||||
extern INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 prio, UINT16 policy);
|
||||
extern INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 policy, const LosSchedParam *param);
|
||||
extern INT32 OsGetProcessPriority(INT32 which, INT32 pid);
|
||||
extern LosProcessCB *OsGetUserInitProcess(VOID);
|
||||
extern LosProcessCB *OsGetIdleProcess(VOID);
|
||||
@@ -545,6 +553,7 @@ extern VOID OsProcessThreadGroupDestroy(VOID);
|
||||
extern UINT32 OsGetProcessGroupCB(UINT32 pid, UINTPTR *ppgroupLeader);
|
||||
extern LosProcessCB *OsGetDefaultProcessCB(VOID);
|
||||
extern ProcessGroup *OsCreateProcessGroup(LosProcessCB *processCB);
|
||||
INT32 OsSchedulerParamCheck(UINT16 policy, BOOL isThread, const LosSchedParam *param);
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -68,6 +68,10 @@ extern "C" {
|
||||
#define OS_SCHED_TICK_TO_CYCLE(ticks) ((UINT64)ticks * OS_CYCLE_PER_TICK)
|
||||
#define AFFI_MASK_TO_CPUID(mask) ((UINT16)((mask) - 1))
|
||||
|
||||
#define OS_SCHED_EDF_MIN_RUNTIME 100 /* 100 us */
|
||||
#define OS_SCHED_EDF_MIN_DEADLINE 400 /* 400 us */
|
||||
#define OS_SCHED_EDF_MAX_DEADLINE 5000000 /* 5 s */
|
||||
|
||||
extern UINT32 g_taskScheduled;
|
||||
#define OS_SCHEDULER_ACTIVE (g_taskScheduled & (1U << ArchCurrCpuid()))
|
||||
#define OS_SCHEDULER_ALL_ACTIVE (g_taskScheduled == LOSCFG_KERNEL_CPU_MASK)
|
||||
@@ -98,9 +102,16 @@ typedef struct {
|
||||
UINT32 queueBitmap;
|
||||
} HPFRunqueue;
|
||||
|
||||
typedef struct {
|
||||
LOS_DL_LIST root;
|
||||
LOS_DL_LIST waitList;
|
||||
UINT64 period;
|
||||
} EDFRunqueue;
|
||||
|
||||
typedef struct {
|
||||
SortLinkAttribute timeoutQueue; /* task timeout queue */
|
||||
HPFRunqueue *hpfRunqueue;
|
||||
EDFRunqueue *edfRunqueue;
|
||||
UINT64 responseTime; /* Response time for current CPU tick interrupts */
|
||||
UINT32 responseID; /* The response ID of the current CPU tick interrupt */
|
||||
LosTaskCB *idleTask; /* idle task id */
|
||||
@@ -212,30 +223,52 @@ STATIC INLINE VOID OsSchedRunqueuePendingSet(VOID)
|
||||
OsSchedRunqueue()->schedFlag |= INT_PEND_RESCH;
|
||||
}
|
||||
|
||||
#define LOS_SCHED_NORMAL 0U
|
||||
#define LOS_SCHED_FIFO 1U
|
||||
#define LOS_SCHED_RR 2U
|
||||
#define LOS_SCHED_IDLE 3U
|
||||
#define LOS_SCHED_NORMAL 0U
|
||||
#define LOS_SCHED_FIFO 1U
|
||||
#define LOS_SCHED_RR 2U
|
||||
#define LOS_SCHED_IDLE 3U
|
||||
#define LOS_SCHED_DEADLINE 6U
|
||||
|
||||
typedef struct {
|
||||
UINT16 policy;
|
||||
/* HPF scheduling parameters */
|
||||
UINT16 basePrio;
|
||||
UINT16 priority;
|
||||
UINT32 timeSlice;
|
||||
|
||||
/* EDF scheduling parameters */
|
||||
INT32 runTimeUs;
|
||||
UINT32 deadlineUs;
|
||||
UINT32 periodUs;
|
||||
} SchedParam;
|
||||
|
||||
typedef struct {
|
||||
UINT16 policy; /* This field must be present for all scheduling policies and must be the first in the structure */
|
||||
UINT16 basePrio;
|
||||
UINT16 priority;
|
||||
UINT32 initTimeSlice;
|
||||
UINT32 priBitmap; /**< Bitmap for recording the change of task priority, the priority can not be greater than 31 */
|
||||
UINT32 initTimeSlice; /* cycle */
|
||||
UINT32 priBitmap; /* Bitmap for recording the change of task priority, the priority can not be greater than 31 */
|
||||
} SchedHPF;
|
||||
|
||||
#define EDF_UNUSED 0
|
||||
#define EDF_NEXT_PERIOD 1
|
||||
#define EDF_WAIT_FOREVER 2
|
||||
#define EDF_INIT 3
|
||||
typedef struct {
|
||||
UINT16 policy;
|
||||
UINT16 cpuid;
|
||||
UINT32 flags;
|
||||
INT32 runTime; /* cycle */
|
||||
UINT64 deadline; /* deadline >> runTime */
|
||||
UINT64 period; /* period >= deadline */
|
||||
UINT64 finishTime; /* startTime + deadline */
|
||||
} SchedEDF;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
SchedEDF edf;
|
||||
SchedHPF hpf;
|
||||
} Policy;
|
||||
};
|
||||
} SchedPolicy;
|
||||
|
||||
typedef struct {
|
||||
@@ -243,6 +276,7 @@ typedef struct {
|
||||
VOID (*enqueue)(SchedRunqueue *rq, LosTaskCB *taskCB);
|
||||
VOID (*start)(SchedRunqueue *rq, LosTaskCB *taskCB);
|
||||
VOID (*exit)(LosTaskCB *taskCB);
|
||||
UINT64 (*waitTimeGet)(LosTaskCB *taskCB);
|
||||
UINT32 (*wait)(LosTaskCB *runTask, LOS_DL_LIST *list, UINT32 timeout);
|
||||
VOID (*wake)(LosTaskCB *taskCB);
|
||||
BOOL (*schedParamModify)(LosTaskCB *taskCB, const SchedParam *param);
|
||||
@@ -429,7 +463,7 @@ typedef struct TagTaskCB {
|
||||
PidContainer *pidContainer;
|
||||
#endif
|
||||
#ifdef LOSCFG_IPC_CONTAINER
|
||||
BOOL cloneIpc;
|
||||
BOOL cloneIpc;
|
||||
#endif
|
||||
} LosTaskCB;
|
||||
|
||||
@@ -463,6 +497,12 @@ STATIC INLINE BOOL OsTaskIsBlocked(const LosTaskCB *taskCB)
|
||||
return ((taskCB->taskStatus & (OS_TASK_STATUS_SUSPENDED | OS_TASK_STATUS_PENDING | OS_TASK_STATUS_DELAY)) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsSchedPolicyIsEDF(const LosTaskCB *taskCB)
|
||||
{
|
||||
const SchedEDF *sched = (const SchedEDF *)&taskCB->sp;
|
||||
return (sched->policy == LOS_SCHED_DEADLINE);
|
||||
}
|
||||
|
||||
STATIC INLINE LosTaskCB *OsCurrTaskGet(VOID)
|
||||
{
|
||||
return (LosTaskCB *)ArchCurrTaskGet();
|
||||
@@ -619,6 +659,20 @@ STATIC INLINE VOID SchedTaskUnfreeze(LosTaskCB *taskCB)
|
||||
g_taskScheduled &= ~(1U << (cpuid)); \
|
||||
} while (0);
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
BOOL OsSchedLimitCheckTime(LosTaskCB *task);
|
||||
#endif
|
||||
|
||||
STATIC INLINE LosTaskCB *EDFRunqueueTopTaskGet(EDFRunqueue *rq)
|
||||
{
|
||||
LOS_DL_LIST *root = &rq->root;
|
||||
if (LOS_ListEmpty(root)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return LOS_DL_LIST_ENTRY(LOS_DL_LIST_FIRST(root), LosTaskCB, pendList);
|
||||
}
|
||||
|
||||
STATIC INLINE LosTaskCB *HPFRunqueueTopTaskGet(HPFRunqueue *rq)
|
||||
{
|
||||
LosTaskCB *newTask = NULL;
|
||||
@@ -634,6 +688,12 @@ STATIC INLINE LosTaskCB *HPFRunqueueTopTaskGet(HPFRunqueue *rq)
|
||||
while (bitmap) {
|
||||
UINT32 priority = CLZ(bitmap);
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(newTask, &queueList->priQueList[priority], LosTaskCB, pendList) {
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
if (!OsSchedLimitCheckTime(newTask)) {
|
||||
bitmap &= ~(1U << (OS_PRIORITY_QUEUE_NUM - priority - 1));
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
if (newTask->cpuAffiMask & (1U << cpuid)) {
|
||||
#endif
|
||||
@@ -650,9 +710,16 @@ STATIC INLINE LosTaskCB *HPFRunqueueTopTaskGet(HPFRunqueue *rq)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VOID EDFProcessDefaultSchedParamGet(SchedParam *param);
|
||||
VOID EDFSchedPolicyInit(SchedRunqueue *rq);
|
||||
UINT32 EDFTaskSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
|
||||
const SchedParam *parentParam,
|
||||
const LosSchedParam *param);
|
||||
|
||||
VOID HPFSchedPolicyInit(SchedRunqueue *rq);
|
||||
VOID HPFTaskSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
|
||||
const SchedParam *parentParam, const TSK_INIT_PARAM_S *param);
|
||||
const SchedParam *parentParam,
|
||||
const LosSchedParam *param);
|
||||
VOID HPFProcessDefaultSchedParamGet(SchedParam *param);
|
||||
|
||||
VOID IdleTaskSchedParamInit(LosTaskCB *taskCB);
|
||||
@@ -660,7 +727,8 @@ VOID IdleTaskSchedParamInit(LosTaskCB *taskCB);
|
||||
INT32 OsSchedParamCompare(const LosTaskCB *task1, const LosTaskCB *task2);
|
||||
VOID OsSchedPriorityInheritance(LosTaskCB *owner, const SchedParam *param);
|
||||
UINT32 OsSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
|
||||
const SchedParam *parentParam, const TSK_INIT_PARAM_S *param);
|
||||
const SchedParam *parentParam,
|
||||
const LosSchedParam *param);
|
||||
VOID OsSchedProcessDefaultSchedParamGet(UINT16 policy, SchedParam *param);
|
||||
|
||||
VOID OsSchedResponseTimeReset(UINT64 responseTime);
|
||||
|
||||
@@ -57,9 +57,11 @@ typedef struct {
|
||||
#ifdef LOSCFG_SCHED_TICK_DEBUG
|
||||
VOID OsSchedDebugRecordData(VOID);
|
||||
UINT32 OsShellShowTickResponse(VOID);
|
||||
UINT32 OsShellShowSchedStatistics(VOID);
|
||||
UINT32 OsSchedDebugInit(VOID);
|
||||
#endif
|
||||
UINT32 OsShellShowSchedStatistics(VOID);
|
||||
UINT32 OsShellShowEdfSchedStatistics(VOID);
|
||||
VOID EDFDebugRecord(UINTPTR *taskCB, UINT64 oldFinish);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -101,6 +101,16 @@ extern "C" {
|
||||
*/
|
||||
#define OS_NS_PER_TICK (OS_SYS_NS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND)
|
||||
|
||||
#define OS_US_TO_CYCLE(time, freq) ((((time) / OS_SYS_US_PER_SECOND) * (freq)) + \
|
||||
(((time) % OS_SYS_US_PER_SECOND) * (freq) / OS_SYS_US_PER_SECOND))
|
||||
|
||||
#define OS_SYS_US_TO_CYCLE(time) OS_US_TO_CYCLE((time), OS_SYS_CLOCK)
|
||||
|
||||
#define OS_CYCLE_TO_US(cycle, freq) ((((cycle) / (freq)) * OS_SYS_US_PER_SECOND) + \
|
||||
((cycle) % (freq) * OS_SYS_US_PER_SECOND / (freq)))
|
||||
|
||||
#define OS_SYS_CYCLE_TO_US(cycle) OS_CYCLE_TO_US((cycle), OS_SYS_CLOCK)
|
||||
|
||||
/**
|
||||
* @ingroup los_sys
|
||||
* The maximum length of name.
|
||||
|
||||
@@ -54,6 +54,7 @@ extern "C" {
|
||||
|
||||
/* scheduler lock */
|
||||
extern SPIN_LOCK_S g_taskSpin;
|
||||
#define SCHEDULER_HELD() LOS_SpinHeld(&g_taskSpin)
|
||||
#define SCHEDULER_LOCK(state) LOS_SpinLockSave(&g_taskSpin, &(state))
|
||||
#define SCHEDULER_UNLOCK(state) LOS_SpinUnlockRestore(&g_taskSpin, state)
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ UINT32 OsGetTimeContainerMonotonic(LosProcessCB *processCB, struct timespec64 *o
|
||||
|
||||
UINT32 OsSetTimeContainerMonotonic(LosProcessCB *processCB, struct timespec64 *offsets);
|
||||
|
||||
UINT32 OsGetTimeContainerCount(VOID);
|
||||
|
||||
#define CLOCK_MONOTONIC_TIME_BASE (OsGetCurrTimeContainer()->monotonic)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -76,5 +76,7 @@ UINT32 OsMakeKgid(UserContainer *userContainer, UINT32 gid);
|
||||
|
||||
INT32 OsUserContainerMapWrite(struct ProcFile *fp, CHAR *buf, size_t count,
|
||||
INT32 capSetid, UidGidMap *map, UidGidMap *parentMap);
|
||||
|
||||
UINT32 OsGetUserContainerCount(VOID);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -60,5 +60,6 @@ struct utsname *OsGetCurrUtsName(VOID);
|
||||
|
||||
UINT32 OsGetUtsContainerID(UtsContainer *utsContainer);
|
||||
|
||||
UINT32 OsGetUtsContainerCount(VOID);
|
||||
#endif
|
||||
#endif /* _LOS_UTS_CONTAINER_PRI_H */
|
||||
|
||||
@@ -103,7 +103,7 @@ STATIC VOID SortQueueIndexArray(UINT32 *indexArray, UINT32 count)
|
||||
IpcSortParam queueSortParam;
|
||||
queueSortParam.buf = (CHAR *)g_queueDebugArray;
|
||||
queueSortParam.ipcDebugCBSize = sizeof(QueueDebugCB);
|
||||
queueSortParam.ipcDebugCBCnt = LOSCFG_BASE_IPC_SEM_LIMIT;
|
||||
queueSortParam.ipcDebugCBCnt = LOSCFG_BASE_IPC_QUEUE_LIMIT;
|
||||
queueSortParam.sortElemOff = LOS_OFF_SET_OF(QueueDebugCB, lastAccessTime);
|
||||
|
||||
if (count > 0) {
|
||||
|
||||
@@ -53,6 +53,9 @@
|
||||
#include "los_sched_pri.h"
|
||||
#include "los_swtmr_pri.h"
|
||||
#include "los_info_pri.h"
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#include "los_statistics_pri.h"
|
||||
#endif
|
||||
|
||||
#define OS_PROCESS_MEM_INFO 0x2U
|
||||
#undef SHOW
|
||||
@@ -93,6 +96,8 @@ STATIC UINT8 *ConvertSchedPolicyToString(UINT16 policy)
|
||||
return (UINT8 *)"RR";
|
||||
} else if (policy == LOS_SCHED_FIFO) {
|
||||
return (UINT8 *)"FIFO";
|
||||
} else if (policy == LOS_SCHED_DEADLINE) {
|
||||
return (UINT8 *)"EDF";
|
||||
} else if (policy == LOS_SCHED_IDLE) {
|
||||
return (UINT8 *)"IDLE";
|
||||
}
|
||||
@@ -200,12 +205,10 @@ STATIC UINT8 *ConvertTaskStatusToString(UINT16 taskStatus)
|
||||
return (UINT8 *)"Suspended";
|
||||
} else if (taskStatus & OS_TASK_STATUS_DELAY) {
|
||||
return (UINT8 *)"Delay";
|
||||
} else if (taskStatus & OS_TASK_STATUS_PEND_TIME) {
|
||||
return (UINT8 *)"PendTime";
|
||||
} else if (taskStatus & OS_TASK_STATUS_PENDING) {
|
||||
if (taskStatus & OS_TASK_STATUS_PEND_TIME) {
|
||||
return (UINT8 *)"PendTime";
|
||||
} else {
|
||||
return (UINT8 *)"Pending";
|
||||
}
|
||||
return (UINT8 *)"Pending";
|
||||
} else if (taskStatus & OS_TASK_STATUS_EXIT) {
|
||||
return (UINT8 *)"Exit";
|
||||
}
|
||||
@@ -413,11 +416,20 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdDumpTask(INT32 argc, const CHAR **argv)
|
||||
}
|
||||
goto TASK_HELP;
|
||||
#endif
|
||||
#ifdef LOSCFG_SCHED_HPF_DEBUG
|
||||
} else if (strcmp("-t", argv[0]) == 0) {
|
||||
if (!OsShellShowSchedStatistics()) {
|
||||
return LOS_OK;
|
||||
}
|
||||
goto TASK_HELP;
|
||||
#endif
|
||||
#ifdef LOSCFG_SCHED_EDF_DEBUG
|
||||
} else if (strcmp("-e", argv[0]) == 0) {
|
||||
if (!OsShellShowEdfSchedStatistics()) {
|
||||
return LOS_OK;
|
||||
}
|
||||
goto TASK_HELP;
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
goto TASK_HELP;
|
||||
|
||||
403
kernel/base/sched/los_deadline.c
Normal file
403
kernel/base/sched/los_deadline.c
Normal file
@@ -0,0 +1,403 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "los_sched_pri.h"
|
||||
#include "los_task_pri.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "los_hook.h"
|
||||
#include "los_tick_pri.h"
|
||||
#include "los_sys_pri.h"
|
||||
|
||||
STATIC EDFRunqueue g_schedEDF;
|
||||
|
||||
STATIC VOID EDFDequeue(SchedRunqueue *rq, LosTaskCB *taskCB);
|
||||
STATIC VOID EDFEnqueue(SchedRunqueue *rq, LosTaskCB *taskCB);
|
||||
STATIC UINT64 EDFWaitTimeGet(LosTaskCB *taskCB);
|
||||
STATIC UINT32 EDFWait(LosTaskCB *runTask, LOS_DL_LIST *list, UINT32 ticks);
|
||||
STATIC VOID EDFWake(LosTaskCB *resumedTask);
|
||||
STATIC BOOL EDFSchedParamModify(LosTaskCB *taskCB, const SchedParam *param);
|
||||
STATIC UINT32 EDFSchedParamGet(const LosTaskCB *taskCB, SchedParam *param);
|
||||
STATIC UINT32 EDFDelay(LosTaskCB *runTask, UINT64 waitTime);
|
||||
STATIC VOID EDFYield(LosTaskCB *runTask);
|
||||
STATIC VOID EDFExit(LosTaskCB *taskCB);
|
||||
STATIC UINT32 EDFSuspend(LosTaskCB *taskCB);
|
||||
STATIC UINT32 EDFResume(LosTaskCB *taskCB, BOOL *needSched);
|
||||
STATIC UINT64 EDFTimeSliceGet(const LosTaskCB *taskCB);
|
||||
STATIC VOID EDFTimeSliceUpdate(SchedRunqueue *rq, LosTaskCB *taskCB, UINT64 currTime);
|
||||
STATIC INT32 EDFParamCompare(const SchedPolicy *sp1, const SchedPolicy *sp2);
|
||||
STATIC VOID EDFPriorityInheritance(LosTaskCB *owner, const SchedParam *param);
|
||||
STATIC VOID EDFPriorityRestore(LosTaskCB *owner, const LOS_DL_LIST *list, const SchedParam *param);
|
||||
|
||||
const STATIC SchedOps g_deadlineOps = {
|
||||
.dequeue = EDFDequeue,
|
||||
.enqueue = EDFEnqueue,
|
||||
.waitTimeGet = EDFWaitTimeGet,
|
||||
.wait = EDFWait,
|
||||
.wake = EDFWake,
|
||||
.schedParamModify = EDFSchedParamModify,
|
||||
.schedParamGet = EDFSchedParamGet,
|
||||
.delay = EDFDelay,
|
||||
.yield = EDFYield,
|
||||
.start = EDFDequeue,
|
||||
.exit = EDFExit,
|
||||
.suspend = EDFSuspend,
|
||||
.resume = EDFResume,
|
||||
.deadlineGet = EDFTimeSliceGet,
|
||||
.timeSliceUpdate = EDFTimeSliceUpdate,
|
||||
.schedParamCompare = EDFParamCompare,
|
||||
.priorityInheritance = EDFPriorityInheritance,
|
||||
.priorityRestore = EDFPriorityRestore,
|
||||
};
|
||||
|
||||
STATIC VOID EDFTimeSliceUpdate(SchedRunqueue *rq, LosTaskCB *taskCB, UINT64 currTime)
|
||||
{
|
||||
SchedEDF *sched = (SchedEDF *)&taskCB->sp;
|
||||
|
||||
LOS_ASSERT(currTime >= taskCB->startTime);
|
||||
|
||||
if (taskCB->timeSlice <= 0) {
|
||||
taskCB->irqUsedTime = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
INT32 incTime = (currTime - taskCB->startTime - taskCB->irqUsedTime);
|
||||
LOS_ASSERT(incTime >= 0);
|
||||
|
||||
#ifdef LOSCFG_SCHED_EDF_DEBUG
|
||||
taskCB->schedStat.timeSliceRealTime += incTime;
|
||||
taskCB->schedStat.allRuntime += (currTime - taskCB->startTime);
|
||||
#endif
|
||||
|
||||
taskCB->timeSlice -= incTime;
|
||||
taskCB->irqUsedTime = 0;
|
||||
taskCB->startTime = currTime;
|
||||
|
||||
if ((sched->finishTime > currTime) && (taskCB->timeSlice > 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
rq->schedFlag |= INT_PEND_RESCH;
|
||||
if (sched->finishTime <= currTime) {
|
||||
#ifdef LOSCFG_SCHED_EDF_DEBUG
|
||||
EDFDebugRecord((UINTPTR *)taskCB, sched->finishTime);
|
||||
#endif
|
||||
|
||||
taskCB->timeSlice = 0;
|
||||
PrintExcInfo("EDF task %u is timeout, runTime: %d us period: %llu us\n", taskCB->taskID,
|
||||
(INT32)OS_SYS_CYCLE_TO_US((UINT64)sched->runTime), OS_SYS_CYCLE_TO_US(sched->period));
|
||||
}
|
||||
}
|
||||
|
||||
STATIC UINT64 EDFTimeSliceGet(const LosTaskCB *taskCB)
|
||||
{
|
||||
SchedEDF *sched = (SchedEDF *)&taskCB->sp;
|
||||
UINT64 endTime = taskCB->startTime + taskCB->timeSlice;
|
||||
return (endTime > sched->finishTime) ? sched->finishTime : endTime;
|
||||
}
|
||||
|
||||
STATIC VOID DeadlineQueueInsert(EDFRunqueue *rq, LosTaskCB *taskCB)
|
||||
{
|
||||
LOS_DL_LIST *root = &rq->root;
|
||||
if (LOS_ListEmpty(root)) {
|
||||
LOS_ListTailInsert(root, &taskCB->pendList);
|
||||
return;
|
||||
}
|
||||
|
||||
LOS_DL_LIST *list = root->pstNext;
|
||||
do {
|
||||
LosTaskCB *readyTask = LOS_DL_LIST_ENTRY(list, LosTaskCB, pendList);
|
||||
if (EDFParamCompare(&readyTask->sp, &taskCB->sp) > 0) {
|
||||
LOS_ListHeadInsert(list, &taskCB->pendList);
|
||||
return;
|
||||
}
|
||||
list = list->pstNext;
|
||||
} while (list != root);
|
||||
|
||||
LOS_ListHeadInsert(list, &taskCB->pendList);
|
||||
}
|
||||
|
||||
STATIC VOID EDFEnqueue(SchedRunqueue *rq, LosTaskCB *taskCB)
|
||||
{
|
||||
LOS_ASSERT(!(taskCB->taskStatus & OS_TASK_STATUS_READY));
|
||||
|
||||
EDFRunqueue *erq = rq->edfRunqueue;
|
||||
SchedEDF *sched = (SchedEDF *)&taskCB->sp;
|
||||
if (taskCB->timeSlice <= 0) {
|
||||
#ifdef LOSCFG_SCHED_EDF_DEBUG
|
||||
UINT64 oldFinish = sched->finishTime;
|
||||
#endif
|
||||
UINT64 currTime = OsGetCurrSchedTimeCycle();
|
||||
if (sched->flags == EDF_INIT) {
|
||||
sched->finishTime = currTime;
|
||||
} else if (sched->flags != EDF_NEXT_PERIOD) {
|
||||
/* The start time of the next period */
|
||||
sched->finishTime = (sched->finishTime - sched->deadline) + sched->period;
|
||||
}
|
||||
|
||||
/* Calculate the start time of the next period */
|
||||
while (1) {
|
||||
/* The deadline of the next period */
|
||||
UINT64 finishTime = sched->finishTime + sched->deadline;
|
||||
if ((finishTime <= currTime) || ((sched->finishTime + sched->runTime) > finishTime)) {
|
||||
/* This period cannot meet the minimum running time, so it is migrated to the next period */
|
||||
sched->finishTime += sched->period;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (sched->finishTime > currTime) {
|
||||
/* Wait for the next period to start */
|
||||
LOS_ListTailInsert(&erq->waitList, &taskCB->pendList);
|
||||
taskCB->waitTime = OS_SCHED_MAX_RESPONSE_TIME;
|
||||
if (!OsTaskIsRunning(taskCB)) {
|
||||
OsSchedTimeoutQueueAdd(taskCB, sched->finishTime);
|
||||
}
|
||||
#ifdef LOSCFG_SCHED_EDF_DEBUG
|
||||
if (oldFinish != sched->finishTime) {
|
||||
EDFDebugRecord((UINTPTR *)taskCB, oldFinish);
|
||||
taskCB->schedStat.allRuntime = 0;
|
||||
taskCB->schedStat.timeSliceRealTime = 0;
|
||||
taskCB->schedStat.pendTime = 0;
|
||||
}
|
||||
#endif
|
||||
taskCB->taskStatus |= OS_TASK_STATUS_PEND_TIME;
|
||||
sched->flags = EDF_NEXT_PERIOD;
|
||||
return;
|
||||
}
|
||||
|
||||
sched->finishTime += sched->deadline;
|
||||
taskCB->timeSlice = sched->runTime;
|
||||
sched->flags = EDF_UNUSED;
|
||||
}
|
||||
|
||||
DeadlineQueueInsert(erq, taskCB);
|
||||
taskCB->taskStatus &= ~(OS_TASK_STATUS_BLOCKED | OS_TASK_STATUS_TIMEOUT);
|
||||
taskCB->taskStatus |= OS_TASK_STATUS_READY;
|
||||
}
|
||||
|
||||
STATIC VOID EDFDequeue(SchedRunqueue *rq, LosTaskCB *taskCB)
|
||||
{
|
||||
(VOID)rq;
|
||||
LOS_ListDelete(&taskCB->pendList);
|
||||
taskCB->taskStatus &= ~OS_TASK_STATUS_READY;
|
||||
}
|
||||
|
||||
STATIC VOID EDFExit(LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_READY) {
|
||||
EDFDequeue(OsSchedRunqueue(), taskCB);
|
||||
} else if (taskCB->taskStatus & OS_TASK_STATUS_PENDING) {
|
||||
LOS_ListDelete(&taskCB->pendList);
|
||||
taskCB->taskStatus &= ~OS_TASK_STATUS_PENDING;
|
||||
}
|
||||
if (taskCB->taskStatus & (OS_TASK_STATUS_DELAY | OS_TASK_STATUS_PEND_TIME)) {
|
||||
OsSchedTimeoutQueueDelete(taskCB);
|
||||
taskCB->taskStatus &= ~(OS_TASK_STATUS_DELAY | OS_TASK_STATUS_PEND_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
STATIC VOID EDFYield(LosTaskCB *runTask)
|
||||
{
|
||||
SchedRunqueue *rq = OsSchedRunqueue();
|
||||
runTask->timeSlice = 0;
|
||||
|
||||
runTask->startTime = OsGetCurrSchedTimeCycle();
|
||||
EDFEnqueue(rq, runTask);
|
||||
OsSchedResched();
|
||||
}
|
||||
|
||||
STATIC UINT32 EDFDelay(LosTaskCB *runTask, UINT64 waitTime)
|
||||
{
|
||||
runTask->taskStatus |= OS_TASK_STATUS_DELAY;
|
||||
runTask->waitTime = waitTime;
|
||||
OsSchedResched();
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT64 EDFWaitTimeGet(LosTaskCB *taskCB)
|
||||
{
|
||||
const SchedEDF *sched = (const SchedEDF *)&taskCB->sp;
|
||||
if (sched->flags != EDF_WAIT_FOREVER) {
|
||||
taskCB->waitTime += taskCB->startTime;
|
||||
}
|
||||
return (taskCB->waitTime >= sched->finishTime) ? sched->finishTime : taskCB->waitTime;
|
||||
}
|
||||
|
||||
STATIC UINT32 EDFWait(LosTaskCB *runTask, LOS_DL_LIST *list, UINT32 ticks)
|
||||
{
|
||||
SchedEDF *sched = (SchedEDF *)&runTask->sp;
|
||||
runTask->taskStatus |= (OS_TASK_STATUS_PENDING | OS_TASK_STATUS_PEND_TIME);
|
||||
LOS_ListTailInsert(list, &runTask->pendList);
|
||||
|
||||
if (ticks != LOS_WAIT_FOREVER) {
|
||||
runTask->waitTime = OS_SCHED_TICK_TO_CYCLE(ticks);
|
||||
} else {
|
||||
sched->flags = EDF_WAIT_FOREVER;
|
||||
runTask->waitTime = OS_SCHED_MAX_RESPONSE_TIME;
|
||||
}
|
||||
|
||||
if (OsPreemptableInSched()) {
|
||||
OsSchedResched();
|
||||
if (runTask->taskStatus & OS_TASK_STATUS_TIMEOUT) {
|
||||
runTask->taskStatus &= ~OS_TASK_STATUS_TIMEOUT;
|
||||
return LOS_ERRNO_TSK_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID EDFWake(LosTaskCB *resumedTask)
|
||||
{
|
||||
LOS_ListDelete(&resumedTask->pendList);
|
||||
resumedTask->taskStatus &= ~OS_TASK_STATUS_PENDING;
|
||||
|
||||
if (resumedTask->taskStatus & OS_TASK_STATUS_PEND_TIME) {
|
||||
OsSchedTimeoutQueueDelete(resumedTask);
|
||||
resumedTask->taskStatus &= ~OS_TASK_STATUS_PEND_TIME;
|
||||
}
|
||||
|
||||
if (!(resumedTask->taskStatus & OS_TASK_STATUS_SUSPENDED)) {
|
||||
#ifdef LOSCFG_SCHED_EDF_DEBUG
|
||||
resumedTask->schedStat.pendTime += OsGetCurrSchedTimeCycle() - resumedTask->startTime;
|
||||
resumedTask->schedStat.pendCount++;
|
||||
#endif
|
||||
EDFEnqueue(OsSchedRunqueue(), resumedTask);
|
||||
}
|
||||
}
|
||||
|
||||
STATIC BOOL EDFSchedParamModify(LosTaskCB *taskCB, const SchedParam *param)
|
||||
{
|
||||
SchedRunqueue *rq = OsSchedRunqueue();
|
||||
SchedEDF *sched = (SchedEDF *)&taskCB->sp;
|
||||
|
||||
taskCB->timeSlice = 0;
|
||||
sched->runTime = (INT32)OS_SYS_US_TO_CYCLE(param->runTimeUs);
|
||||
sched->period = OS_SYS_US_TO_CYCLE(param->periodUs);
|
||||
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_READY) {
|
||||
EDFDequeue(rq, taskCB);
|
||||
sched->deadline = OS_SYS_US_TO_CYCLE(param->deadlineUs);
|
||||
EDFEnqueue(rq, taskCB);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
sched->deadline = OS_SYS_US_TO_CYCLE(param->deadlineUs);
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_INIT) {
|
||||
EDFEnqueue(rq, taskCB);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC UINT32 EDFSchedParamGet(const LosTaskCB *taskCB, SchedParam *param)
|
||||
{
|
||||
SchedEDF *sched = (SchedEDF *)&taskCB->sp;
|
||||
param->policy = sched->policy;
|
||||
param->runTimeUs = (INT32)OS_SYS_CYCLE_TO_US((UINT64)sched->runTime);
|
||||
param->deadlineUs = OS_SYS_CYCLE_TO_US(sched->deadline);
|
||||
param->periodUs = OS_SYS_CYCLE_TO_US(sched->period);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 EDFSuspend(LosTaskCB *taskCB)
|
||||
{
|
||||
return LOS_EOPNOTSUPP;
|
||||
}
|
||||
|
||||
STATIC UINT32 EDFResume(LosTaskCB *taskCB, BOOL *needSched)
|
||||
{
|
||||
return LOS_EOPNOTSUPP;
|
||||
}
|
||||
|
||||
STATIC INT32 EDFParamCompare(const SchedPolicy *sp1, const SchedPolicy *sp2)
|
||||
{
|
||||
const SchedEDF *param1 = (const SchedEDF *)sp1;
|
||||
const SchedEDF *param2 = (const SchedEDF *)sp2;
|
||||
|
||||
return (INT32)(param1->finishTime - param2->finishTime);
|
||||
}
|
||||
|
||||
STATIC VOID EDFPriorityInheritance(LosTaskCB *owner, const SchedParam *param)
|
||||
{
|
||||
(VOID)owner;
|
||||
(VOID)param;
|
||||
}
|
||||
|
||||
STATIC VOID EDFPriorityRestore(LosTaskCB *owner, const LOS_DL_LIST *list, const SchedParam *param)
|
||||
{
|
||||
(VOID)owner;
|
||||
(VOID)list;
|
||||
(VOID)param;
|
||||
}
|
||||
|
||||
UINT32 EDFTaskSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
|
||||
const SchedParam *parentParam,
|
||||
const LosSchedParam *param)
|
||||
{
|
||||
(VOID)parentParam;
|
||||
SchedEDF *sched = (SchedEDF *)&taskCB->sp;
|
||||
sched->flags = EDF_INIT;
|
||||
sched->policy = policy;
|
||||
sched->runTime = (INT32)OS_SYS_US_TO_CYCLE((UINT64)param->runTimeUs);
|
||||
sched->deadline = OS_SYS_US_TO_CYCLE(param->deadlineUs);
|
||||
sched->period = OS_SYS_US_TO_CYCLE(param->periodUs);
|
||||
sched->finishTime = 0;
|
||||
taskCB->timeSlice = 0;
|
||||
taskCB->ops = &g_deadlineOps;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID EDFProcessDefaultSchedParamGet(SchedParam *param)
|
||||
{
|
||||
param->runTimeUs = OS_SCHED_EDF_MIN_RUNTIME;
|
||||
param->deadlineUs = OS_SCHED_EDF_MAX_DEADLINE;
|
||||
param->periodUs = param->deadlineUs;
|
||||
}
|
||||
|
||||
VOID EDFSchedPolicyInit(SchedRunqueue *rq)
|
||||
{
|
||||
if (ArchCurrCpuid() > 0) {
|
||||
rq->edfRunqueue = &g_schedEDF;
|
||||
return;
|
||||
}
|
||||
|
||||
EDFRunqueue *erq = &g_schedEDF;
|
||||
erq->period = OS_SCHED_MAX_RESPONSE_TIME;
|
||||
LOS_ListInit(&erq->root);
|
||||
LOS_ListInit(&erq->waitList);
|
||||
rq->edfRunqueue = erq;
|
||||
}
|
||||
@@ -48,6 +48,7 @@ STATIC VOID IdlePriorityRestore(LosTaskCB *owner, const LOS_DL_LIST *list, const
|
||||
const STATIC SchedOps g_idleOps = {
|
||||
.dequeue = IdleDequeue,
|
||||
.enqueue = IdleEnqueue,
|
||||
.waitTimeGet = NULL,
|
||||
.wait = IdleWait,
|
||||
.wake = IdleWake,
|
||||
.schedParamModify = NULL,
|
||||
|
||||
@@ -47,6 +47,7 @@ STATIC HPFRunqueue g_schedHPF;
|
||||
|
||||
STATIC VOID HPFDequeue(SchedRunqueue *rq, LosTaskCB *taskCB);
|
||||
STATIC VOID HPFEnqueue(SchedRunqueue *rq, LosTaskCB *taskCB);
|
||||
STATIC UINT64 HPFWaitTimeGet(LosTaskCB *taskCB);
|
||||
STATIC UINT32 HPFWait(LosTaskCB *runTask, LOS_DL_LIST *list, UINT32 ticks);
|
||||
STATIC VOID HPFWake(LosTaskCB *resumedTask);
|
||||
STATIC BOOL HPFSchedParamModify(LosTaskCB *taskCB, const SchedParam *param);
|
||||
@@ -66,6 +67,7 @@ STATIC VOID HPFPriorityRestore(LosTaskCB *owner, const LOS_DL_LIST *list, const
|
||||
const STATIC SchedOps g_priorityOps = {
|
||||
.dequeue = HPFDequeue,
|
||||
.enqueue = HPFEnqueue,
|
||||
.waitTimeGet = HPFWaitTimeGet,
|
||||
.wait = HPFWait,
|
||||
.wake = HPFWake,
|
||||
.schedParamModify = HPFSchedParamModify,
|
||||
@@ -94,17 +96,20 @@ STATIC VOID HPFTimeSliceUpdate(SchedRunqueue *rq, LosTaskCB *taskCB, UINT64 curr
|
||||
|
||||
if (sched->policy == LOS_SCHED_RR) {
|
||||
taskCB->timeSlice -= incTime;
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#ifdef LOSCFG_SCHED_HPF_DEBUG
|
||||
taskCB->schedStat.timeSliceRealTime += incTime;
|
||||
#endif
|
||||
}
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
OsSchedLimitUpdateRuntime(taskCB, currTime, incTime);
|
||||
#endif
|
||||
taskCB->irqUsedTime = 0;
|
||||
taskCB->startTime = currTime;
|
||||
if (taskCB->timeSlice <= OS_TIME_SLICE_MIN) {
|
||||
rq->schedFlag |= INT_PEND_RESCH;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#ifdef LOSCFG_SCHED_HPF_DEBUG
|
||||
taskCB->schedStat.allRuntime += incTime;
|
||||
#endif
|
||||
}
|
||||
@@ -212,7 +217,7 @@ STATIC INLINE VOID PriQueInsert(HPFRunqueue *rq, LosTaskCB *taskCB)
|
||||
sched->initTimeSlice = TimeSliceCalculate(rq, sched->basePrio, sched->priority);
|
||||
taskCB->timeSlice = sched->initTimeSlice;
|
||||
PriQueTailInsert(rq, sched->basePrio, &taskCB->pendList, sched->priority);
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#ifdef LOSCFG_SCHED_HPF_DEBUG
|
||||
taskCB->schedStat.timeSliceTime = taskCB->schedStat.timeSliceRealTime;
|
||||
taskCB->schedStat.timeSliceCount++;
|
||||
#endif
|
||||
@@ -241,7 +246,7 @@ STATIC INLINE VOID PriQueInsert(HPFRunqueue *rq, LosTaskCB *taskCB)
|
||||
|
||||
STATIC VOID HPFEnqueue(SchedRunqueue *rq, LosTaskCB *taskCB)
|
||||
{
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#ifdef LOSCFG_SCHED_HPF_DEBUG
|
||||
if (!(taskCB->taskStatus & OS_TASK_STATUS_RUNNING)) {
|
||||
taskCB->startTime = OsGetCurrSchedTimeCycle();
|
||||
}
|
||||
@@ -298,6 +303,12 @@ STATIC UINT32 HPFDelay(LosTaskCB *runTask, UINT64 waitTime)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT64 HPFWaitTimeGet(LosTaskCB *taskCB)
|
||||
{
|
||||
taskCB->waitTime += taskCB->startTime;
|
||||
return taskCB->waitTime;
|
||||
}
|
||||
|
||||
STATIC UINT32 HPFWait(LosTaskCB *runTask, LOS_DL_LIST *list, UINT32 ticks)
|
||||
{
|
||||
runTask->taskStatus |= OS_TASK_STATUS_PENDING;
|
||||
@@ -330,7 +341,7 @@ STATIC VOID HPFWake(LosTaskCB *resumedTask)
|
||||
}
|
||||
|
||||
if (!(resumedTask->taskStatus & OS_TASK_STATUS_SUSPENDED)) {
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#ifdef LOSCFG_SCHED_HPF_DEBUG
|
||||
resumedTask->schedStat.pendTime += OsGetCurrSchedTimeCycle() - resumedTask->startTime;
|
||||
resumedTask->schedStat.pendCount++;
|
||||
#endif
|
||||
@@ -505,13 +516,13 @@ STATIC VOID HPFPriorityRestore(LosTaskCB *owner, const LOS_DL_LIST *list, const
|
||||
|
||||
VOID HPFTaskSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
|
||||
const SchedParam *parentParam,
|
||||
const TSK_INIT_PARAM_S *param)
|
||||
const LosSchedParam *param)
|
||||
{
|
||||
SchedHPF *sched = (SchedHPF *)&taskCB->sp;
|
||||
|
||||
sched->policy = policy;
|
||||
if (param != NULL) {
|
||||
sched->priority = param->usTaskPrio;
|
||||
sched->priority = param->priority;
|
||||
} else {
|
||||
sched->priority = parentParam->priority;
|
||||
}
|
||||
|
||||
@@ -102,15 +102,26 @@ VOID OsSchedExpireTimeUpdate(VOID)
|
||||
|
||||
STATIC INLINE VOID SchedTimeoutTaskWake(SchedRunqueue *rq, UINT64 currTime, LosTaskCB *taskCB, BOOL *needSched)
|
||||
{
|
||||
#ifndef LOSCFG_SCHED_DEBUG
|
||||
(VOID)currTime;
|
||||
#endif
|
||||
|
||||
LOS_SpinLock(&g_taskSpin);
|
||||
if (OsSchedPolicyIsEDF(taskCB)) {
|
||||
SchedEDF *sched = (SchedEDF *)&taskCB->sp;
|
||||
if (sched->finishTime <= currTime) {
|
||||
if (taskCB->timeSlice >= 0) {
|
||||
PrintExcInfo("EDF task: %u name: %s is timeout, timeout for %llu us.\n",
|
||||
taskCB->taskID, taskCB->taskName, OS_SYS_CYCLE_TO_US(currTime - sched->finishTime));
|
||||
}
|
||||
taskCB->timeSlice = 0;
|
||||
}
|
||||
if (sched->flags == EDF_WAIT_FOREVER) {
|
||||
taskCB->taskStatus &= ~OS_TASK_STATUS_PEND_TIME;
|
||||
sched->flags = EDF_UNUSED;
|
||||
}
|
||||
}
|
||||
|
||||
UINT16 tempStatus = taskCB->taskStatus;
|
||||
if (tempStatus & (OS_TASK_STATUS_PENDING | OS_TASK_STATUS_DELAY)) {
|
||||
if (tempStatus & (OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_DELAY)) {
|
||||
taskCB->taskStatus &= ~(OS_TASK_STATUS_PENDING | OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_DELAY);
|
||||
if (tempStatus & OS_TASK_STATUS_PENDING) {
|
||||
if (tempStatus & OS_TASK_STATUS_PEND_TIME) {
|
||||
taskCB->taskStatus |= OS_TASK_STATUS_TIMEOUT;
|
||||
LOS_ListDelete(&taskCB->pendList);
|
||||
taskCB->taskMux = NULL;
|
||||
@@ -118,7 +129,7 @@ STATIC INLINE VOID SchedTimeoutTaskWake(SchedRunqueue *rq, UINT64 currTime, LosT
|
||||
}
|
||||
|
||||
if (!(tempStatus & OS_TASK_STATUS_SUSPENDED)) {
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#ifdef LOSCFG_SCHED_HPF_DEBUG
|
||||
taskCB->schedStat.pendTime += currTime - taskCB->startTime;
|
||||
taskCB->schedStat.pendCount++;
|
||||
#endif
|
||||
@@ -212,8 +223,10 @@ VOID OsSchedRunqueueIdleInit(LosTaskCB *idleTask)
|
||||
|
||||
UINT32 OsSchedInit(VOID)
|
||||
{
|
||||
for (UINT16 cpuId = 0; cpuId < LOSCFG_KERNEL_CORE_NUM; cpuId++) {
|
||||
HPFSchedPolicyInit(OsSchedRunqueueByID(cpuId));
|
||||
for (UINT16 cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) {
|
||||
SchedRunqueue *rq = OsSchedRunqueueByID(cpuid);
|
||||
EDFSchedPolicyInit(rq);
|
||||
HPFSchedPolicyInit(rq);
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_SCHED_TICK_DEBUG
|
||||
@@ -247,13 +260,15 @@ INT32 OsSchedParamCompare(const LosTaskCB *task1, const LosTaskCB *task2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT32 OsSchedParamInit(LosTaskCB *taskCB, UINT16 policy, const SchedParam *parentParam, const TSK_INIT_PARAM_S *param)
|
||||
UINT32 OsSchedParamInit(LosTaskCB *taskCB, UINT16 policy, const SchedParam *parentParam, const LosSchedParam *param)
|
||||
{
|
||||
switch (policy) {
|
||||
case LOS_SCHED_FIFO:
|
||||
case LOS_SCHED_RR:
|
||||
HPFTaskSchedParamInit(taskCB, policy, parentParam, param);
|
||||
break;
|
||||
case LOS_SCHED_DEADLINE:
|
||||
return EDFTaskSchedParamInit(taskCB, policy, parentParam, param);
|
||||
case LOS_SCHED_IDLE:
|
||||
IdleTaskSchedParamInit(taskCB);
|
||||
break;
|
||||
@@ -271,6 +286,9 @@ VOID OsSchedProcessDefaultSchedParamGet(UINT16 policy, SchedParam *param)
|
||||
case LOS_SCHED_RR:
|
||||
HPFProcessDefaultSchedParamGet(param);
|
||||
break;
|
||||
case LOS_SCHED_DEADLINE:
|
||||
EDFProcessDefaultSchedParamGet(param);
|
||||
break;
|
||||
case LOS_SCHED_IDLE:
|
||||
default:
|
||||
PRINT_ERR("Invalid process-level scheduling policy, %u\n", policy);
|
||||
@@ -281,12 +299,19 @@ VOID OsSchedProcessDefaultSchedParamGet(UINT16 policy, SchedParam *param)
|
||||
|
||||
STATIC LosTaskCB *TopTaskGet(SchedRunqueue *rq)
|
||||
{
|
||||
LosTaskCB *newTask = HPFRunqueueTopTaskGet(rq->hpfRunqueue);
|
||||
|
||||
if (newTask == NULL) {
|
||||
newTask = rq->idleTask;
|
||||
LosTaskCB *newTask = EDFRunqueueTopTaskGet(rq->edfRunqueue);
|
||||
if (newTask != NULL) {
|
||||
goto FIND;
|
||||
}
|
||||
|
||||
newTask = HPFRunqueueTopTaskGet(rq->hpfRunqueue);
|
||||
if (newTask != NULL) {
|
||||
goto FIND;
|
||||
}
|
||||
|
||||
newTask = rq->idleTask;
|
||||
|
||||
FIND:
|
||||
newTask->ops->start(rq, newTask);
|
||||
return newTask;
|
||||
}
|
||||
@@ -387,7 +412,7 @@ STATIC VOID SchedTaskSwitch(SchedRunqueue *rq, LosTaskCB *runTask, LosTaskCB *ne
|
||||
OsCpupCycleEndStart(runTask, newTask);
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#ifdef LOSCFG_SCHED_HPF_DEBUG
|
||||
UINT64 waitStartTime = newTask->startTime;
|
||||
#endif
|
||||
if (runTask->taskStatus & OS_TASK_STATUS_READY) {
|
||||
@@ -400,14 +425,14 @@ STATIC VOID SchedTaskSwitch(SchedRunqueue *rq, LosTaskCB *runTask, LosTaskCB *ne
|
||||
runTask->ops->timeSliceUpdate(rq, runTask, newTask->startTime);
|
||||
|
||||
if (runTask->taskStatus & (OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_DELAY)) {
|
||||
OsSchedTimeoutQueueAdd(runTask, runTask->startTime + runTask->waitTime);
|
||||
OsSchedTimeoutQueueAdd(runTask, runTask->ops->waitTimeGet(runTask));
|
||||
}
|
||||
}
|
||||
|
||||
UINT64 deadline = newTask->ops->deadlineGet(newTask);
|
||||
SchedNextExpireTimeSet(newTask->taskID, deadline, runTask->taskID);
|
||||
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#ifdef LOSCFG_SCHED_HPF_DEBUG
|
||||
newTask->schedStat.waitSchedTime += newTask->startTime - waitStartTime;
|
||||
newTask->schedStat.waitSchedCount++;
|
||||
runTask->schedStat.runTime = runTask->schedStat.allRuntime;
|
||||
|
||||
@@ -99,6 +99,7 @@ UINT32 OsShellShowTickResponse(VOID)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_SCHED_HPF_DEBUG
|
||||
STATIC VOID SchedDataGet(const LosTaskCB *taskCB, UINT64 *runTime, UINT64 *timeSlice,
|
||||
UINT64 *pendTime, UINT64 *schedWait)
|
||||
{
|
||||
@@ -128,6 +129,7 @@ UINT32 OsShellShowSchedStatistics(VOID)
|
||||
UINT32 taskLinkNum[LOSCFG_KERNEL_CORE_NUM];
|
||||
UINT32 intSave;
|
||||
LosTaskCB task;
|
||||
SchedEDF *sched = NULL;
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
for (UINT16 cpu = 0; cpu < LOSCFG_KERNEL_CORE_NUM; cpu++) {
|
||||
@@ -150,6 +152,12 @@ UINT32 OsShellShowSchedStatistics(VOID)
|
||||
continue;
|
||||
}
|
||||
|
||||
sched = (SchedEDF *)&taskCB->sp;
|
||||
if (sched->policy == LOS_SCHED_DEADLINE) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
continue;
|
||||
}
|
||||
|
||||
(VOID)memcpy_s(&task, sizeof(LosTaskCB), taskCB, sizeof(LosTaskCB));
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
@@ -170,3 +178,168 @@ UINT32 OsShellShowSchedStatistics(VOID)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_SCHED_EDF_DEBUG
|
||||
#define EDF_DEBUG_NODE 20
|
||||
typedef struct {
|
||||
UINT32 tid;
|
||||
INT32 runTimeUs;
|
||||
UINT64 deadlineUs;
|
||||
UINT64 periodUs;
|
||||
UINT64 startTime;
|
||||
UINT64 finishTime;
|
||||
UINT64 nextfinishTime;
|
||||
UINT64 timeSliceUnused;
|
||||
UINT64 timeSliceRealTime;
|
||||
UINT64 allRuntime;
|
||||
UINT64 pendTime;
|
||||
} EDFDebug;
|
||||
|
||||
STATIC EDFDebug g_edfNode[EDF_DEBUG_NODE];
|
||||
STATIC INT32 g_edfNodePointer = 0;
|
||||
|
||||
VOID EDFDebugRecord(UINTPTR *task, UINT64 oldFinish)
|
||||
{
|
||||
LosTaskCB *taskCB = (LosTaskCB *)task;
|
||||
SchedEDF *sched = (SchedEDF *)&taskCB->sp;
|
||||
SchedParam param;
|
||||
|
||||
// when print edf info, will stop record
|
||||
if (g_edfNodePointer == (EDF_DEBUG_NODE + 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
taskCB->ops->schedParamGet(taskCB, ¶m);
|
||||
g_edfNode[g_edfNodePointer].tid = taskCB->taskID;
|
||||
g_edfNode[g_edfNodePointer].runTimeUs =param.runTimeUs;
|
||||
g_edfNode[g_edfNodePointer].deadlineUs =param.deadlineUs;
|
||||
g_edfNode[g_edfNodePointer].periodUs =param.periodUs;
|
||||
g_edfNode[g_edfNodePointer].startTime = taskCB->startTime;
|
||||
if (taskCB->timeSlice <= 0) {
|
||||
taskCB->irqUsedTime = 0;
|
||||
g_edfNode[g_edfNodePointer].timeSliceUnused = 0;
|
||||
} else {
|
||||
g_edfNode[g_edfNodePointer].timeSliceUnused = taskCB->timeSlice;
|
||||
}
|
||||
g_edfNode[g_edfNodePointer].finishTime = oldFinish;
|
||||
g_edfNode[g_edfNodePointer].nextfinishTime = sched->finishTime;
|
||||
g_edfNode[g_edfNodePointer].timeSliceRealTime = taskCB->schedStat.timeSliceRealTime;
|
||||
g_edfNode[g_edfNodePointer].allRuntime = taskCB->schedStat.allRuntime;
|
||||
g_edfNode[g_edfNodePointer].pendTime = taskCB->schedStat.pendTime;
|
||||
|
||||
g_edfNodePointer++;
|
||||
if (g_edfNodePointer == EDF_DEBUG_NODE) {
|
||||
g_edfNodePointer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
STATIC VOID EDFInfoPrint(int idx)
|
||||
{
|
||||
INT32 runTimeUs;
|
||||
UINT64 deadlineUs;
|
||||
UINT64 periodUs;
|
||||
UINT64 startTime;
|
||||
UINT64 timeSlice;
|
||||
UINT64 finishTime;
|
||||
UINT64 nextfinishTime;
|
||||
UINT64 pendTime;
|
||||
UINT64 allRuntime;
|
||||
UINT64 timeSliceRealTime;
|
||||
CHAR *status = NULL;
|
||||
|
||||
startTime = OS_SYS_CYCLE_TO_US(g_edfNode[idx].startTime);
|
||||
timeSlice = OS_SYS_CYCLE_TO_US(g_edfNode[idx].timeSliceUnused);
|
||||
finishTime = OS_SYS_CYCLE_TO_US(g_edfNode[idx].finishTime);
|
||||
nextfinishTime = OS_SYS_CYCLE_TO_US(g_edfNode[idx].nextfinishTime);
|
||||
pendTime = OS_SYS_CYCLE_TO_US(g_edfNode[idx].pendTime);
|
||||
allRuntime = OS_SYS_CYCLE_TO_US(g_edfNode[idx].allRuntime);
|
||||
timeSliceRealTime = OS_SYS_CYCLE_TO_US(g_edfNode[idx].timeSliceRealTime);
|
||||
runTimeUs = g_edfNode[idx].runTimeUs;
|
||||
deadlineUs = g_edfNode[idx].deadlineUs;
|
||||
periodUs = g_edfNode[idx].periodUs;
|
||||
|
||||
if (timeSlice > 0) {
|
||||
status = "TIMEOUT";
|
||||
} else if (nextfinishTime == finishTime) {
|
||||
status = "NEXT PERIOD";
|
||||
} else {
|
||||
status = "WAIT RUN";
|
||||
}
|
||||
|
||||
PRINTK("%4u%9d%9llu%9llu%12llu%12llu%12llu%9llu%9llu%9llu%9llu %-12s\n",
|
||||
g_edfNode[idx].tid, runTimeUs, deadlineUs, periodUs,
|
||||
startTime, finishTime, nextfinishTime, allRuntime, timeSliceRealTime,
|
||||
timeSlice, pendTime, status);
|
||||
}
|
||||
|
||||
VOID OsEDFDebugPrint(VOID)
|
||||
{
|
||||
INT32 max;
|
||||
UINT32 intSave;
|
||||
INT32 i;
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
max = g_edfNodePointer;
|
||||
g_edfNodePointer = EDF_DEBUG_NODE + 1;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
PRINTK("\r\nlast %d sched is: (in microsecond)\r\n", EDF_DEBUG_NODE);
|
||||
|
||||
PRINTK(" TID RunTime Deadline Period StartTime "
|
||||
"CurPeriod NextPeriod AllRun RealRun TimeOut WaitTime Status\n");
|
||||
|
||||
for (i = max; i < EDF_DEBUG_NODE; i++) {
|
||||
EDFInfoPrint(i);
|
||||
}
|
||||
|
||||
for (i = 0; i < max; i++) {
|
||||
EDFInfoPrint(i);
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
g_edfNodePointer = max;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
}
|
||||
|
||||
UINT32 OsShellShowEdfSchedStatistics(VOID)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosTaskCB task;
|
||||
UINT64 curTime;
|
||||
UINT64 deadline;
|
||||
UINT64 finishTime;
|
||||
SchedEDF *sched = NULL;
|
||||
|
||||
PRINTK("Now Alive EDF Thread:\n");
|
||||
PRINTK("TID CurTime DeadTime FinishTime taskName\n");
|
||||
|
||||
for (UINT32 tid = 0; tid < g_taskMaxNum; tid++) {
|
||||
LosTaskCB *taskCB = g_taskCBArray + tid;
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (OsTaskIsUnused(taskCB)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
continue;
|
||||
}
|
||||
|
||||
sched = (SchedEDF *)&taskCB->sp;
|
||||
if (sched->policy != LOS_SCHED_DEADLINE) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
continue;
|
||||
}
|
||||
|
||||
(VOID)memcpy_s(&task, sizeof(LosTaskCB), taskCB, sizeof(LosTaskCB));
|
||||
|
||||
curTime = OS_SYS_CYCLE_TO_US(HalClockGetCycles());
|
||||
finishTime = OS_SYS_CYCLE_TO_US(sched->finishTime);
|
||||
deadline = OS_SYS_CYCLE_TO_US(taskCB->ops->deadlineGet(taskCB));
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
PRINTK("%3u%15llu%15llu%15llu %-32s\n",
|
||||
task.taskID, curTime, deadline, finishTime, task.taskName);
|
||||
}
|
||||
|
||||
OsEDFDebugPrint();
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -359,6 +359,12 @@ STATUS_T OsVmPageFaultHandler(VADDR_T vaddr, UINT32 flags, ExcContext *frame)
|
||||
return LOS_ERRNO_VM_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
if (OsMemLimitCheckAndMemAdd(PAGE_SIZE) != LOS_OK) {
|
||||
return LOS_ERRNO_VM_NO_MEMORY;
|
||||
}
|
||||
#endif
|
||||
|
||||
(VOID)LOS_MuxAcquire(&space->regionMux);
|
||||
region = LOS_RegionFind(space, vaddr);
|
||||
if (region == NULL) {
|
||||
@@ -450,6 +456,9 @@ VMM_MAP_FAILED:
|
||||
}
|
||||
CHECK_FAILED:
|
||||
OsFaultTryFixup(frame, excVaddr, &status);
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
OsMemLimitMemFree(PAGE_SIZE);
|
||||
#endif
|
||||
DONE:
|
||||
(VOID)LOS_MuxRelease(&space->regionMux);
|
||||
return status;
|
||||
|
||||
@@ -34,7 +34,9 @@
|
||||
#include "los_vm_phys.h"
|
||||
#include "los_vm_boot.h"
|
||||
#include "los_vm_filemap.h"
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
||||
#include "los_plimits.h"
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
@@ -81,7 +83,8 @@ VOID OsVmPageStartup(VOID)
|
||||
* struct LosVmPage occupied, which satisfies the equation:
|
||||
* nPage * sizeof(LosVmPage) + nPage * PAGE_SIZE = OsVmPhysPageNumGet() * PAGE_SIZE.
|
||||
*/
|
||||
nPage = OsVmPhysPageNumGet() * PAGE_SIZE / (sizeof(LosVmPage) + PAGE_SIZE);
|
||||
UINT32 pageNum = OsVmPhysPageNumGet();
|
||||
nPage = pageNum * PAGE_SIZE / (sizeof(LosVmPage) + PAGE_SIZE);
|
||||
g_vmPageArraySize = nPage * sizeof(LosVmPage);
|
||||
g_vmPageArray = (LosVmPage *)OsVmBootMemAlloc(g_vmPageArraySize);
|
||||
|
||||
@@ -89,6 +92,9 @@ VOID OsVmPageStartup(VOID)
|
||||
|
||||
OsVmPhysSegAdd();
|
||||
OsVmPhysInit();
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
OsMemLimitSetLimit(pageNum * PAGE_SIZE);
|
||||
#endif
|
||||
|
||||
for (segID = 0; segID < g_vmPhysSegNum; segID++) {
|
||||
seg = &g_vmPhysSeg[segID];
|
||||
|
||||
@@ -52,7 +52,7 @@ STATIC struct VmPhysArea g_physArea[] = {
|
||||
struct VmPhysSeg g_vmPhysSeg[VM_PHYS_SEG_MAX];
|
||||
INT32 g_vmPhysSegNum = 0;
|
||||
|
||||
LosVmPhysSeg *OsGVmPhysSegGet()
|
||||
LosVmPhysSeg *OsGVmPhysSegGet(void)
|
||||
{
|
||||
return g_vmPhysSeg;
|
||||
}
|
||||
@@ -456,6 +456,9 @@ VOID LOS_PhysPagesFreeContiguous(VOID *ptr, size_t nPages)
|
||||
OsVmPhysPagesFreeContiguous(page, nPages);
|
||||
|
||||
LOS_SpinUnlockRestore(&seg->freeListLock, intSave);
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
OsMemLimitMemFree(nPages * PAGE_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
PADDR_T OsKVaddrToPaddr(VADDR_T kvaddr)
|
||||
@@ -503,6 +506,9 @@ VOID LOS_PhysPageFree(LosVmPage *page)
|
||||
|
||||
LOS_SpinUnlockRestore(&seg->freeListLock, intSave);
|
||||
}
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
OsMemLimitMemFree(PAGE_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
LosVmPage *LOS_PhysPageAlloc(VOID)
|
||||
|
||||
@@ -193,40 +193,58 @@ STATIC VOID ShmPagesRefDec(struct shmIDSource *seg)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC INT32 ShmAllocSeg(key_t key, size_t size, INT32 shmflg)
|
||||
STATIC INT32 ShmAllocSegCheck(key_t key, size_t *size, INT32 *segNum)
|
||||
{
|
||||
INT32 i;
|
||||
INT32 segNum = -1;
|
||||
struct shmIDSource *seg = NULL;
|
||||
size_t count;
|
||||
|
||||
if ((size == 0) || (size < IPC_SHM_INFO.shmmin) ||
|
||||
(size > IPC_SHM_INFO.shmmax)) {
|
||||
if ((*size == 0) || (*size < IPC_SHM_INFO.shmmin) ||
|
||||
(*size > IPC_SHM_INFO.shmmax)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
size = LOS_Align(size, PAGE_SIZE);
|
||||
if ((IPC_SHM_USED_PAGE_COUNT + (size >> PAGE_SHIFT)) > IPC_SHM_INFO.shmall) {
|
||||
*size = LOS_Align(*size, PAGE_SIZE);
|
||||
if ((IPC_SHM_USED_PAGE_COUNT + (*size >> PAGE_SHIFT)) > IPC_SHM_INFO.shmall) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
if (OsIPCLimitShmAlloc(*size) != LOS_OK) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < IPC_SHM_INFO.shmmni; i++) {
|
||||
if (IPC_SHM_SEGS[i].status & SHM_SEG_FREE) {
|
||||
IPC_SHM_SEGS[i].status &= ~SHM_SEG_FREE;
|
||||
segNum = i;
|
||||
*segNum = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (segNum < 0) {
|
||||
if (*segNum < 0) {
|
||||
return -ENOSPC;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC INT32 ShmAllocSeg(key_t key, size_t size, INT32 shmflg)
|
||||
{
|
||||
INT32 segNum = -1;
|
||||
struct shmIDSource *seg = NULL;
|
||||
size_t count;
|
||||
|
||||
INT32 ret = ShmAllocSegCheck(key, &size, &segNum);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
seg = &IPC_SHM_SEGS[segNum];
|
||||
count = LOS_PhysPagesAlloc(size >> PAGE_SHIFT, &seg->node);
|
||||
if (count != (size >> PAGE_SHIFT)) {
|
||||
(VOID)LOS_PhysPagesFree(&seg->node);
|
||||
seg->status = SHM_SEG_FREE;
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
OsIPCLimitShmFree(size);
|
||||
#endif
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@@ -264,6 +282,9 @@ STATIC INLINE VOID ShmFreeSeg(struct shmIDSource *seg, UINT32 *shmUsedPageCount)
|
||||
VM_ERR("free physical pages failed, count = %d, size = %d", count, seg->ds.shm_segsz >> PAGE_SHIFT);
|
||||
return;
|
||||
}
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
OsIPCLimitShmFree(seg->ds.shm_segsz);
|
||||
#endif
|
||||
if (shmUsedPageCount != NULL) {
|
||||
(*shmUsedPageCount) -= seg->ds.shm_segsz >> PAGE_SHIFT;
|
||||
}
|
||||
|
||||
@@ -389,6 +389,14 @@ extern UINT32 __heap_end;
|
||||
#define VERSION_NUM(a, b, c, d) (((a) << 24) | ((b) << 16) | (c) << 8 | (d))
|
||||
#define KERNEL_OPEN_VERSION_NUM VERSION_NUM(KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE)
|
||||
|
||||
/**
|
||||
* @ingroup los_config
|
||||
* The container limit
|
||||
*/
|
||||
#ifndef LOSCFG_KERNEL_CONTAINER_DEFAULT_LIMIT
|
||||
#define LOSCFG_KERNEL_CONTAINER_DEFAULT_LIMIT 10
|
||||
#endif
|
||||
|
||||
/****************************** Exception information configuration ******************************/
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
/**
|
||||
|
||||
@@ -32,6 +32,7 @@ import("//kernel/liteos_a/liteos.gni")
|
||||
group("extended") {
|
||||
deps = [
|
||||
"blackbox",
|
||||
"container",
|
||||
"cppsupport",
|
||||
"cpup",
|
||||
"dynload",
|
||||
@@ -42,6 +43,7 @@ group("extended") {
|
||||
"lms",
|
||||
"perf",
|
||||
"pipes",
|
||||
"plimit",
|
||||
"power",
|
||||
"trace",
|
||||
"vdso",
|
||||
@@ -51,6 +53,7 @@ group("extended") {
|
||||
config("public") {
|
||||
configs = [
|
||||
"blackbox:public",
|
||||
"container:public",
|
||||
"cpup:public",
|
||||
"dynload:public",
|
||||
"hidumper:public",
|
||||
@@ -62,5 +65,6 @@ config("public") {
|
||||
"perf:public",
|
||||
"lms:public",
|
||||
"power:public",
|
||||
"plimit:public",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -76,6 +76,31 @@ config KERNEL_PIPE
|
||||
help
|
||||
Answer Y to enable LiteOS support pipes.
|
||||
|
||||
config KERNEL_PLIMITS
|
||||
bool "Enable plimits Feature"
|
||||
default n
|
||||
depends on KERNEL_EXTKERNEL
|
||||
|
||||
config KERNEL_MEM_PLIMIT
|
||||
bool "Enable mem limits Feature"
|
||||
default n
|
||||
depends on KERNEL_PLIMITS
|
||||
|
||||
config KERNEL_IPC_PLIMIT
|
||||
bool "Enable ipc limits Feature"
|
||||
default n
|
||||
depends on KERNEL_PLIMITS
|
||||
|
||||
config KERNEL_DEV_PLIMIT
|
||||
bool "Enable dev limits Feature"
|
||||
default n
|
||||
depends on KERNEL_PLIMITS
|
||||
|
||||
config KERNEL_SCHED_PLIMIT
|
||||
bool "Enable sched limits Feature"
|
||||
default n
|
||||
depends on KERNEL_PLIMITS
|
||||
|
||||
config BASE_CORE_HILOG
|
||||
bool "Enable Hilog"
|
||||
default y
|
||||
@@ -88,6 +113,54 @@ config KERNEL_HOOK
|
||||
default n
|
||||
depends on KERNEL_EXTKERNEL && DEBUG_VERSION
|
||||
|
||||
|
||||
######################### config options of container ####################
|
||||
config KERNEL_CONTAINER
|
||||
bool "Enable container Feature"
|
||||
default n
|
||||
depends on KERNEL_VM
|
||||
|
||||
config PID_CONTAINER
|
||||
bool "Enable pid container Feature"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
config UTS_CONTAINER
|
||||
bool "Enable uts container Feature"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
config MNT_CONTAINER
|
||||
bool "Enable mnt container Feature"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
config CHROOT
|
||||
bool "Enable chroot"
|
||||
default n
|
||||
depends on MNT_CONTAINER
|
||||
|
||||
config IPC_CONTAINER
|
||||
bool "Enable ipc container Feature"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
config TIME_CONTAINER
|
||||
bool "Enable time container"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
config USER_CONTAINER
|
||||
bool "Enable user container"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
config NET_CONTAINER
|
||||
bool "Enable net container"
|
||||
default n
|
||||
depends on KERNEL_CONTAINER
|
||||
|
||||
|
||||
######################### config options of trace #########################
|
||||
source "kernel/extended/trace/Kconfig"
|
||||
|
||||
@@ -104,4 +177,4 @@ source "kernel/extended/perf/Kconfig"
|
||||
source "kernel/extended/lms/Kconfig"
|
||||
|
||||
######################### config options of hilog #########################
|
||||
source "kernel/extended/hilog/Kconfig"
|
||||
source "kernel/extended/hilog/Kconfig"
|
||||
|
||||
65
kernel/extended/container/BUILD.gn
Normal file
65
kernel/extended/container/BUILD.gn
Normal file
@@ -0,0 +1,65 @@
|
||||
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_KERNEL_CONTAINER)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [ "los_container.c" ]
|
||||
if (defined(LOSCFG_IPC_CONTAINER)) {
|
||||
sources += [ "los_ipc_container.c" ]
|
||||
}
|
||||
if (defined(LOSCFG_MNT_CONTAINER)) {
|
||||
sources += [ "los_mnt_container.c" ]
|
||||
}
|
||||
if (defined(LOSCFG_NET_CONTAINER)) {
|
||||
sources += [ "los_net_container.c" ]
|
||||
}
|
||||
if (defined(LOSCFG_PID_CONTAINER)) {
|
||||
sources += [ "los_pid_container.c" ]
|
||||
}
|
||||
if (defined(LOSCFG_TIME_CONTAINER)) {
|
||||
sources += [ "los_time_container.c" ]
|
||||
}
|
||||
if (defined(LOSCFG_USER_CONTAINER)) {
|
||||
sources += [
|
||||
"los_credentials.c",
|
||||
"los_user_container.c",
|
||||
]
|
||||
}
|
||||
if (defined(LOSCFG_UTS_CONTAINER)) {
|
||||
sources += [ "los_uts_container.c" ]
|
||||
}
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "." ]
|
||||
}
|
||||
63
kernel/extended/container/Makefile
Normal file
63
kernel/extended/container/Makefile
Normal file
@@ -0,0 +1,63 @@
|
||||
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(LITEOSTOPDIR)/config.mk
|
||||
|
||||
MODULE_NAME := $(notdir $(shell pwd))
|
||||
|
||||
LOCAL_SRCS := $(wildcard *.c)
|
||||
|
||||
ifneq ($(LOSCFG_IPC_CONTAINER), y)
|
||||
LOCAL_SRCS += $(filter-out los_ipc_container.c, $(LOCAL_SRCS))
|
||||
endif
|
||||
|
||||
ifneq ($(LOSCFG_MNT_CONTAINER), y)
|
||||
LOCAL_SRCS += $(filter-out los_mnt_container.c, $(LOCAL_SRCS))
|
||||
endif
|
||||
|
||||
ifneq ($(LOSCFG_NET_CONTAINER), y)
|
||||
LOCAL_SRCS += $(filter-out los_net_container.c, $(LOCAL_SRCS))
|
||||
endif
|
||||
|
||||
ifneq ($(LOSCFG_PID_CONTAINER), y)
|
||||
LOCAL_SRCS += $(filter-out los_pid_container.c, $(LOCAL_SRCS))
|
||||
endif
|
||||
|
||||
ifneq ($(LOSCFG_TIME_CONTAINER), y)
|
||||
LOCAL_SRCS += $(filter-out los_time_container.c, $(LOCAL_SRCS))
|
||||
endif
|
||||
|
||||
ifneq ($(LOSCFG_USER_CONTAINER), y)
|
||||
LOCAL_SRCS += $(filter-out los_credentials.c los_user_container.c, $(LOCAL_SRCS))
|
||||
endif
|
||||
|
||||
ifneq ($(LOSCFG_UTS_CONTAINER), y)
|
||||
LOCAL_SRCS += $(filter-out los_uts_container.c, $(LOCAL_SRCS))
|
||||
endif
|
||||
|
||||
include $(MODULE)
|
||||
@@ -27,12 +27,14 @@
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
||||
#include "los_container_pri.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "internal.h"
|
||||
#ifdef LOSCFG_KERNEL_CONTAINER
|
||||
|
||||
STATIC Container g_rootContainer;
|
||||
STATIC ContainerLimit g_containerLimit;
|
||||
STATIC Atomic g_containerCount = 0xF0000000U;
|
||||
#ifdef LOSCFG_USER_CONTAINER
|
||||
STATIC Credentials *g_rootCredentials = NULL;
|
||||
@@ -56,27 +58,182 @@ VOID OsContainerInitSystemProcess(LosProcessCB *processCB)
|
||||
return;
|
||||
}
|
||||
|
||||
UINT32 OsGetContainerLimit(ContainerType type)
|
||||
{
|
||||
switch (type) {
|
||||
#ifdef LOSCFG_PID_CONTAINER
|
||||
case PID_CONTAINER:
|
||||
case PID_CHILD_CONTAINER:
|
||||
return g_containerLimit.pidLimit;
|
||||
#endif
|
||||
#ifdef LOSCFG_USER_CONTAINER
|
||||
case USER_CONTAINER:
|
||||
return g_containerLimit.userLimit;
|
||||
#endif
|
||||
#ifdef LOSCFG_UTS_CONTAINER
|
||||
case UTS_CONTAINER:
|
||||
return g_containerLimit.utsLimit;
|
||||
#endif
|
||||
#ifdef LOSCFG_MNT_CONTAINER
|
||||
case MNT_CONTAINER:
|
||||
return g_containerLimit.mntLimit;
|
||||
#endif
|
||||
#ifdef LOSCFG_IPC_CONTAINER
|
||||
case IPC_CONTAINER:
|
||||
return g_containerLimit.ipcLimit;
|
||||
#endif
|
||||
#ifdef LOSCFG_TIME_CONTAINER
|
||||
case TIME_CONTAINER:
|
||||
case TIME_CHILD_CONTAINER:
|
||||
return g_containerLimit.timeLimit;
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
case NET_CONTAINER:
|
||||
return g_containerLimit.netLimit;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return OS_INVALID_VALUE;
|
||||
}
|
||||
|
||||
UINT32 OsContainerLimitCheck(ContainerType type, UINT32 *containerCount)
|
||||
{
|
||||
UINT32 intSave;
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if ((*containerCount) >= OsGetContainerLimit(type)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 OsSetContainerLimit(ContainerType type, UINT32 value)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
if (value > LOSCFG_KERNEL_CONTAINER_DEFAULT_LIMIT) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
switch (type) {
|
||||
#ifdef LOSCFG_PID_CONTAINER
|
||||
case PID_CONTAINER:
|
||||
case PID_CHILD_CONTAINER:
|
||||
g_containerLimit.pidLimit = value;
|
||||
break;
|
||||
#endif
|
||||
#ifdef LOSCFG_USER_CONTAINER
|
||||
case USER_CONTAINER:
|
||||
g_containerLimit.userLimit = value;
|
||||
break;
|
||||
#endif
|
||||
#ifdef LOSCFG_UTS_CONTAINER
|
||||
case UTS_CONTAINER:
|
||||
g_containerLimit.utsLimit = value;
|
||||
break;
|
||||
#endif
|
||||
#ifdef LOSCFG_MNT_CONTAINER
|
||||
case MNT_CONTAINER:
|
||||
g_containerLimit.mntLimit = value;
|
||||
break;
|
||||
#endif
|
||||
#ifdef LOSCFG_IPC_CONTAINER
|
||||
case IPC_CONTAINER:
|
||||
g_containerLimit.ipcLimit = value;
|
||||
break;
|
||||
#endif
|
||||
#ifdef LOSCFG_TIME_CONTAINER
|
||||
case TIME_CONTAINER:
|
||||
case TIME_CHILD_CONTAINER:
|
||||
g_containerLimit.timeLimit = value;
|
||||
break;
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
case NET_CONTAINER:
|
||||
g_containerLimit.netLimit = value;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 OsGetContainerCount(ContainerType type)
|
||||
{
|
||||
switch (type) {
|
||||
#ifdef LOSCFG_PID_CONTAINER
|
||||
case PID_CONTAINER:
|
||||
case PID_CHILD_CONTAINER:
|
||||
return OsGetPidContainerCount();
|
||||
#endif
|
||||
#ifdef LOSCFG_USER_CONTAINER
|
||||
case USER_CONTAINER:
|
||||
return OsGetUserContainerCount();
|
||||
#endif
|
||||
#ifdef LOSCFG_UTS_CONTAINER
|
||||
case UTS_CONTAINER:
|
||||
return OsGetUtsContainerCount();
|
||||
#endif
|
||||
#ifdef LOSCFG_MNT_CONTAINER
|
||||
case MNT_CONTAINER:
|
||||
return OsGetMntContainerCount();
|
||||
#endif
|
||||
#ifdef LOSCFG_IPC_CONTAINER
|
||||
case IPC_CONTAINER:
|
||||
return OsGetIpcContainerCount();
|
||||
#endif
|
||||
#ifdef LOSCFG_TIME_CONTAINER
|
||||
case TIME_CONTAINER:
|
||||
case TIME_CHILD_CONTAINER:
|
||||
return OsGetTimeContainerCount();
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
case NET_CONTAINER:
|
||||
return OsGetNetContainerCount();
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return OS_INVALID_VALUE;
|
||||
}
|
||||
|
||||
VOID OsInitRootContainer(VOID)
|
||||
{
|
||||
#ifdef LOSCFG_USER_CONTAINER
|
||||
g_containerLimit.userLimit = LOSCFG_KERNEL_CONTAINER_DEFAULT_LIMIT;
|
||||
OsInitRootUserCredentials(&g_rootCredentials);
|
||||
#endif
|
||||
#ifdef LOSCFG_PID_CONTAINER
|
||||
g_containerLimit.pidLimit = LOSCFG_KERNEL_CONTAINER_DEFAULT_LIMIT;
|
||||
(VOID)OsInitRootPidContainer(&g_rootContainer.pidContainer);
|
||||
g_rootContainer.pidForChildContainer = g_rootContainer.pidContainer;
|
||||
#endif
|
||||
#ifdef LOSCFG_UTS_CONTAINER
|
||||
g_containerLimit.utsLimit = LOSCFG_KERNEL_CONTAINER_DEFAULT_LIMIT;
|
||||
(VOID)OsInitRootUtsContainer(&g_rootContainer.utsContainer);
|
||||
#endif
|
||||
#ifdef LOSCFG_MNT_CONTAINER
|
||||
g_containerLimit.mntLimit = LOSCFG_KERNEL_CONTAINER_DEFAULT_LIMIT;
|
||||
(VOID)OsInitRootMntContainer(&g_rootContainer.mntContainer);
|
||||
#endif
|
||||
#ifdef LOSCFG_IPC_CONTAINER
|
||||
g_containerLimit.ipcLimit = LOSCFG_KERNEL_CONTAINER_DEFAULT_LIMIT;
|
||||
(VOID)OsInitRootIpcContainer(&g_rootContainer.ipcContainer);
|
||||
#endif
|
||||
#ifdef LOSCFG_TIME_CONTAINER
|
||||
g_containerLimit.timeLimit = LOSCFG_KERNEL_CONTAINER_DEFAULT_LIMIT;
|
||||
(VOID)OsInitRootTimeContainer(&g_rootContainer.timeContainer);
|
||||
g_rootContainer.timeForChildContainer = g_rootContainer.timeContainer;
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
g_containerLimit.netLimit = LOSCFG_KERNEL_CONTAINER_DEFAULT_LIMIT;
|
||||
(VOID)OsInitRootNetContainer(&g_rootContainer.netContainer);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -133,10 +290,43 @@ STATIC UINT32 CopyContainers(UINTPTR flags, LosProcessCB *child, LosProcessCB *p
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
ret = OsCopyNetContainer(flags, child, parent);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 GetContainerFlagsMask(VOID)
|
||||
{
|
||||
UINT32 mask = 0;
|
||||
#ifdef LOSCFG_PID_CONTAINER
|
||||
mask |= CLONE_NEWPID;
|
||||
#endif
|
||||
#ifdef LOSCFG_MNT_CONTAINER
|
||||
mask |= CLONE_NEWNS;
|
||||
#endif
|
||||
#ifdef LOSCFG_IPC_CONTAINER
|
||||
mask |= CLONE_NEWIPC;
|
||||
#endif
|
||||
#ifdef LOSCFG_USER_CONTAINER
|
||||
mask |= CLONE_NEWUSER;
|
||||
#endif
|
||||
#ifdef LOSCFG_TIME_CONTAINER
|
||||
mask |= CLONE_NEWTIME;
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
mask |= CLONE_NEWNET;
|
||||
#endif
|
||||
#ifdef LOSCFG_UTS_CONTAINER
|
||||
mask |= CLONE_NEWUTS;
|
||||
#endif
|
||||
return mask;
|
||||
}
|
||||
|
||||
/*
|
||||
* called from clone. This now handles copy for Container and all
|
||||
* namespaces therein.
|
||||
@@ -149,7 +339,7 @@ UINT32 OsCopyContainers(UINTPTR flags, LosProcessCB *child, LosProcessCB *parent
|
||||
flags &= ~CLONE_NEWTIME;
|
||||
#endif
|
||||
|
||||
if (!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWTIME))) {
|
||||
if (!(flags & GetContainerFlagsMask())) {
|
||||
#ifdef LOSCFG_PID_CONTAINER
|
||||
if (parent->container->pidContainer != parent->container->pidForChildContainer) {
|
||||
goto CREATE_CONTAINER;
|
||||
@@ -188,7 +378,7 @@ VOID OsContainerFree(LosProcessCB *processCB)
|
||||
}
|
||||
}
|
||||
|
||||
VOID OsContainersDestroy(LosProcessCB *processCB)
|
||||
VOID OsOsContainersDestroyEarly(LosProcessCB *processCB)
|
||||
{
|
||||
/* All processes in the container must be destroyed before the container is destroyed. */
|
||||
#ifdef LOSCFG_PID_CONTAINER
|
||||
@@ -197,6 +387,13 @@ VOID OsContainersDestroy(LosProcessCB *processCB)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_MNT_CONTAINER
|
||||
OsMntContainerDestroy(processCB->container);
|
||||
#endif
|
||||
}
|
||||
|
||||
VOID OsContainersDestroy(LosProcessCB *processCB)
|
||||
{
|
||||
#ifdef LOSCFG_USER_CONTAINER
|
||||
OsUserContainerDestroy(processCB);
|
||||
#endif
|
||||
@@ -205,10 +402,6 @@ VOID OsContainersDestroy(LosProcessCB *processCB)
|
||||
OsUtsContainerDestroy(processCB->container);
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_MNT_CONTAINER
|
||||
OsMntContainerDestroy(processCB->container);
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_IPC_CONTAINER
|
||||
OsIpcContainerDestroy(processCB->container);
|
||||
#endif
|
||||
@@ -217,6 +410,10 @@ VOID OsContainersDestroy(LosProcessCB *processCB)
|
||||
OsTimeContainerDestroy(processCB->container);
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
OsNetContainerDestroy(processCB->container);
|
||||
#endif
|
||||
|
||||
#ifndef LOSCFG_PID_CONTAINER
|
||||
UINT32 intSave;
|
||||
SCHEDULER_LOCK(intSave);
|
||||
@@ -256,6 +453,10 @@ STATIC VOID DeInitContainers(UINT32 flags, Container *container, LosProcessCB *p
|
||||
OsTimeContainerDestroy(container);
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
OsNetContainerDestroy(container);
|
||||
#endif
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LOS_AtomicDec(&container->rc);
|
||||
if (LOS_AtomicRead(&container->rc) == 0) {
|
||||
@@ -299,6 +500,10 @@ UINT32 OsGetContainerID(LosProcessCB *processCB, ContainerType type)
|
||||
return OsGetTimeContainerID(container->timeContainer);
|
||||
case TIME_CHILD_CONTAINER:
|
||||
return OsGetTimeContainerID(container->timeForChildContainer);
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
case NET_CONTAINER:
|
||||
return OsGetNetContainerID(container->netContainer);
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
@@ -338,6 +543,12 @@ STATIC UINT32 UnshareCreateNewContainers(UINT32 flags, LosProcessCB *curr, Conta
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
ret = OsUnshareNetContainer(flags, curr, newContainer);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
@@ -348,8 +559,7 @@ INT32 OsUnshare(UINT32 flags)
|
||||
UINT32 intSave;
|
||||
LosProcessCB *curr = OsCurrProcessGet();
|
||||
Container *oldContainer = curr->container;
|
||||
UINT32 unshareFlags = CLONE_NEWPID | CLONE_NEWTIME | CLONE_NEWUTS | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUSER;
|
||||
|
||||
UINT32 unshareFlags = GetContainerFlagsMask();
|
||||
if (!(flags & unshareFlags) || ((flags & (~unshareFlags)) != 0)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -408,6 +618,8 @@ STATIC UINT32 SetNsGetFlagByContainerType(UINT32 containerType)
|
||||
case TIME_CONTAINER:
|
||||
case TIME_CHILD_CONTAINER:
|
||||
return CLONE_NEWTIME;
|
||||
case NET_CONTAINER:
|
||||
return CLONE_NEWNET;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -446,13 +658,19 @@ STATIC UINT32 SetNsCreateNewContainers(UINT32 flags, Container *newContainer, Co
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
ret = OsSetNsNetContainer(flags, container, newContainer);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 SetNsParamCheck(INT32 fd, INT32 type, UINT32 *flag, LosProcessCB **target)
|
||||
{
|
||||
UINT32 typeMask = CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWPID | CLONE_NEWIPC | CLONE_NEWTIME | CLONE_NEWUSER;
|
||||
UINT32 typeMask = GetContainerFlagsMask();
|
||||
*flag = (UINT32)(type & typeMask);
|
||||
UINT32 containerType = 0;
|
||||
|
||||
@@ -121,6 +121,10 @@ UINT32 OsCopyIpcContainer(UINTPTR flags, LosProcessCB *child, LosProcessCB *pare
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (OsContainerLimitCheck(IPC_CONTAINER, &g_currentIpcContainerNum) != LOS_OK) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
return CreateIpcContainer(child, parent);
|
||||
}
|
||||
|
||||
@@ -137,6 +141,10 @@ UINT32 OsUnshareIpcContainer(UINTPTR flags, LosProcessCB *curr, Container *newCo
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (OsContainerLimitCheck(IPC_CONTAINER, &g_currentIpcContainerNum) != LOS_OK) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
IpcContainer *ipcContainer = CreateNewIpcContainer(parentContainer);
|
||||
if (ipcContainer == NULL) {
|
||||
return ENOMEM;
|
||||
@@ -206,4 +214,9 @@ IpcContainer *OsGetCurrIpcContainer(VOID)
|
||||
{
|
||||
return OsCurrProcessGet()->container->ipcContainer;
|
||||
}
|
||||
|
||||
UINT32 OsGetIpcContainerCount(VOID)
|
||||
{
|
||||
return g_currentIpcContainerNum;
|
||||
}
|
||||
#endif
|
||||
@@ -28,6 +28,7 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LOSCFG_MNT_CONTAINER
|
||||
#include <unistd.h>
|
||||
#include "los_mnt_container_pri.h"
|
||||
#include "los_container_pri.h"
|
||||
@@ -36,7 +37,6 @@
|
||||
#include "vnode.h"
|
||||
#include "internal.h"
|
||||
|
||||
#ifdef LOSCFG_MNT_CONTAINER
|
||||
STATIC UINT32 g_currentMntContainerNum;
|
||||
|
||||
LIST_HEAD *GetContainerMntList(VOID)
|
||||
@@ -124,6 +124,10 @@ UINT32 OsCopyMntContainer(UINTPTR flags, LosProcessCB *child, LosProcessCB *pare
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (OsContainerLimitCheck(MNT_CONTAINER, &g_currentMntContainerNum) != LOS_OK) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
ret = CreateMntContainer(child, parent);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
@@ -146,6 +150,10 @@ UINT32 OsUnshareMntContainer(UINTPTR flags, LosProcessCB *curr, Container *newCo
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (OsContainerLimitCheck(MNT_CONTAINER, &g_currentMntContainerNum) != LOS_OK) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
MntContainer *mntContainer = CreateNewMntContainer(parentContainer);
|
||||
if (mntContainer == NULL) {
|
||||
return ENOMEM;
|
||||
@@ -237,4 +245,9 @@ UINT32 OsGetMntContainerID(MntContainer *mntContainer)
|
||||
|
||||
return mntContainer->containerID;
|
||||
}
|
||||
|
||||
UINT32 OsGetMntContainerCount(VOID)
|
||||
{
|
||||
return g_currentMntContainerNum;
|
||||
}
|
||||
#endif
|
||||
344
kernel/extended/container/los_net_container.c
Normal file
344
kernel/extended/container/los_net_container.c
Normal file
@@ -0,0 +1,344 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LOSCFG_NET_CONTAINER
|
||||
#include <sched.h>
|
||||
#include "los_net_container_pri.h"
|
||||
#include "los_config.h"
|
||||
#include "los_memory.h"
|
||||
#include "los_process_pri.h"
|
||||
|
||||
STATIC UINT32 g_currentNetContainerNum = 0;
|
||||
STATIC NetContainer *g_rootNetContainer = NULL;
|
||||
|
||||
STATIC struct netif *NetifAlloc(VOID)
|
||||
{
|
||||
UINT32 size = sizeof(struct netif);
|
||||
struct netif *netif = LOS_MemAlloc(m_aucSysMem1, size);
|
||||
if (netif == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
(VOID)memset_s(netif, size, 0, size);
|
||||
|
||||
return netif;
|
||||
}
|
||||
|
||||
STATIC VOID FreeNetif(struct netif *netif)
|
||||
{
|
||||
if (netif != NULL) {
|
||||
if (netif->peer != NULL) {
|
||||
netif_remove(netif->peer);
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, netif->peer);
|
||||
}
|
||||
netif_remove(netif);
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, netif);
|
||||
}
|
||||
}
|
||||
|
||||
STATIC UINT32 CreateVethNetif(NetContainer *netContainer, struct netif **veth)
|
||||
{
|
||||
struct netif *netif = NetifAlloc();
|
||||
if (netif == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
veth_init(netif, netContainer->group);
|
||||
|
||||
*veth = netif;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 InitVethPair(NetContainer *netContainer)
|
||||
{
|
||||
struct netif *vethOfNetContainer = NULL;
|
||||
struct netif *vethOfRootNetContainer = NULL;
|
||||
|
||||
UINT32 ret = CreateVethNetif(netContainer, &vethOfNetContainer);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = CreateVethNetif(g_rootNetContainer, &vethOfRootNetContainer);
|
||||
if (ret != LOS_OK) {
|
||||
FreeNetif(vethOfNetContainer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
vethOfNetContainer->peer = vethOfRootNetContainer;
|
||||
vethOfRootNetContainer->peer = vethOfNetContainer;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 InitLoopNetif(NetContainer *netContainer)
|
||||
{
|
||||
struct netif *loop_netif = NetifAlloc();
|
||||
if (loop_netif == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
netContainer->group->loop_netif = loop_netif;
|
||||
netif_init(netContainer->group);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 InitContainerNetifs(NetContainer *netContainer)
|
||||
{
|
||||
UINT32 ret = InitLoopNetif(netContainer);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
return InitVethPair(netContainer);
|
||||
}
|
||||
|
||||
STATIC UINT32 InitNetGroup(NetContainer *netContainer)
|
||||
{
|
||||
UINT32 size = sizeof(struct net_group);
|
||||
struct net_group *group = LOS_MemAlloc(m_aucSysMem1, size);
|
||||
if (group == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
(VOID)memset_s(group, size, 0, size);
|
||||
|
||||
netContainer->group = group;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID FreeNetContainerGroup(struct net_group *group)
|
||||
{
|
||||
if (group == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct netif *freeNetif = group->netif_list;
|
||||
struct netif *nextNetif = NULL;
|
||||
|
||||
while (freeNetif != NULL) {
|
||||
nextNetif = freeNetif->next;
|
||||
FreeNetif(freeNetif);
|
||||
freeNetif = nextNetif;
|
||||
}
|
||||
}
|
||||
|
||||
VOID OsNetContainerDestroy(Container *container)
|
||||
{
|
||||
UINT32 intSave;
|
||||
if (container == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
NetContainer *netContainer = container->netContainer;
|
||||
if (netContainer == NULL) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
LOS_AtomicDec(&netContainer->rc);
|
||||
if (LOS_AtomicRead(&netContainer->rc) > 0) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
g_currentNetContainerNum--;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
FreeNetContainerGroup(netContainer->group);
|
||||
container->netContainer = NULL;
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, netContainer->group);
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, netContainer);
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC NetContainer *CreateNewNetContainer(NetContainer *parent)
|
||||
{
|
||||
NetContainer *netContainer = LOS_MemAlloc(m_aucSysMem1, sizeof(NetContainer));
|
||||
if (netContainer == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
(VOID)memset_s(netContainer, sizeof(NetContainer), 0, sizeof(NetContainer));
|
||||
|
||||
netContainer->containerID = OsAllocContainerID();
|
||||
|
||||
if (parent != NULL) {
|
||||
LOS_AtomicSet(&netContainer->rc, 1);
|
||||
} else {
|
||||
LOS_AtomicSet(&netContainer->rc, 3); /* 3: Three system processes */
|
||||
}
|
||||
return netContainer;
|
||||
}
|
||||
|
||||
STATIC UINT32 CreateNetContainer(Container *container, NetContainer *parentContainer)
|
||||
{
|
||||
UINT32 intSave, ret;
|
||||
NetContainer *newNetContainer = CreateNewNetContainer(parentContainer);
|
||||
if (newNetContainer == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
ret = InitNetGroup(newNetContainer);
|
||||
if (ret != LOS_OK) {
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, newNetContainer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = InitContainerNetifs(newNetContainer);
|
||||
if (ret != LOS_OK) {
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, newNetContainer->group);
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, newNetContainer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
g_currentNetContainerNum++;
|
||||
container->netContainer = newNetContainer;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 OsCopyNetContainer(UINTPTR flags, LosProcessCB *child, LosProcessCB *parent)
|
||||
{
|
||||
UINT32 intSave;
|
||||
NetContainer *currNetContainer = parent->container->netContainer;
|
||||
|
||||
if (!(flags & CLONE_NEWNET)) {
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LOS_AtomicInc(&currNetContainer->rc);
|
||||
child->container->netContainer = currNetContainer;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (OsContainerLimitCheck(NET_CONTAINER, &g_currentNetContainerNum) != LOS_OK) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
return CreateNetContainer(child->container, currNetContainer);
|
||||
}
|
||||
|
||||
UINT32 OsUnshareNetContainer(UINTPTR flags, LosProcessCB *curr, Container *newContainer)
|
||||
{
|
||||
UINT32 intSave;
|
||||
NetContainer *parentContainer = curr->container->netContainer;
|
||||
|
||||
if (!(flags & CLONE_NEWNET)) {
|
||||
SCHEDULER_LOCK(intSave);
|
||||
newContainer->netContainer = parentContainer;
|
||||
LOS_AtomicInc(&parentContainer->rc);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (OsContainerLimitCheck(NET_CONTAINER, &g_currentNetContainerNum) != LOS_OK) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
return CreateNetContainer(newContainer, parentContainer);
|
||||
}
|
||||
|
||||
UINT32 OsSetNsNetContainer(UINT32 flags, Container *container, Container *newContainer)
|
||||
{
|
||||
if (flags & CLONE_NEWNET) {
|
||||
newContainer->netContainer = container->netContainer;
|
||||
LOS_AtomicInc(&container->netContainer->rc);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
newContainer->netContainer = OsCurrProcessGet()->container->netContainer;
|
||||
LOS_AtomicInc(&newContainer->netContainer->rc);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 OsGetNetContainerID(NetContainer *netContainer)
|
||||
{
|
||||
if (netContainer == NULL) {
|
||||
return OS_INVALID_VALUE;
|
||||
}
|
||||
|
||||
return netContainer->containerID;
|
||||
}
|
||||
|
||||
STATIC struct net_group *DoGetNetGroupFromCurrProcess(VOID)
|
||||
{
|
||||
LosProcessCB *processCB = OsCurrProcessGet();
|
||||
NetContainer *netContainer = processCB->container->netContainer;
|
||||
return netContainer->group;
|
||||
}
|
||||
|
||||
STATIC VOID DoSetNetifNetGroup(struct netif *netif, struct net_group *group)
|
||||
{
|
||||
netif->group = group;
|
||||
}
|
||||
|
||||
STATIC struct net_group *DoGetNetGroupFromNetif(struct netif *netif)
|
||||
{
|
||||
return netif != NULL ? netif->group : NULL;
|
||||
}
|
||||
|
||||
STATIC VOID DoSetIppcbNetGroup(struct ip_pcb *pcb, struct net_group *group)
|
||||
{
|
||||
pcb->group = group;
|
||||
}
|
||||
|
||||
STATIC struct net_group *DoGetNetGroupFromIppcb(struct ip_pcb *pcb)
|
||||
{
|
||||
return pcb != NULL ? pcb->group : NULL;
|
||||
}
|
||||
|
||||
struct net_group_ops netGroupOps = {
|
||||
.get_curr_process_net_group = DoGetNetGroupFromCurrProcess,
|
||||
.set_netif_net_group = DoSetNetifNetGroup,
|
||||
.get_net_group_from_netif = DoGetNetGroupFromNetif,
|
||||
.set_ippcb_net_group = DoSetIppcbNetGroup,
|
||||
.get_net_group_from_ippcb = DoGetNetGroupFromIppcb,
|
||||
};
|
||||
|
||||
UINT32 OsInitRootNetContainer(NetContainer **netContainer)
|
||||
{
|
||||
UINT32 intSave;
|
||||
NetContainer *newNetContainer = CreateNewNetContainer(NULL);
|
||||
if (newNetContainer == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
newNetContainer->group = get_root_net_group();
|
||||
set_default_net_group_ops(&netGroupOps);
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
g_currentNetContainerNum++;
|
||||
*netContainer = newNetContainer;
|
||||
g_rootNetContainer = newNetContainer;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 OsGetNetContainerCount(VOID)
|
||||
{
|
||||
return g_currentNetContainerNum;
|
||||
}
|
||||
#endif
|
||||
@@ -52,7 +52,18 @@ STATIC VOID FreeVpid(LosProcessCB *processCB)
|
||||
processVid->vpid = OS_INVALID_VALUE;
|
||||
LOS_ListTailInsert(&pidContainer->pidFreeList, &processVid->node);
|
||||
LOS_AtomicDec(&pidContainer->rc);
|
||||
pidContainer = pidContainer->parent;
|
||||
PidContainer *parentPidContainer = pidContainer->parent;
|
||||
if (LOS_AtomicRead(&pidContainer->rc) > 0) {
|
||||
pidContainer = parentPidContainer;
|
||||
continue;
|
||||
}
|
||||
g_currentPidContainerNum--;
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, pidContainer->rootPGroup);
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, pidContainer);
|
||||
if (pidContainer == processCB->container->pidContainer) {
|
||||
processCB->container->pidContainer = NULL;
|
||||
}
|
||||
pidContainer = parentPidContainer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +225,7 @@ VOID OsPidContainerDestroyAllProcess(LosProcessCB *curr)
|
||||
for (UINT32 index = 2; index < LOSCFG_BASE_CORE_PROCESS_LIMIT; index++) { /* 2: ordinary process */
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(index);
|
||||
if (OsProcessIsUnused(processCB)) {
|
||||
if (OsProcessIsUnused(processCB) || (processCB->parentProcess == NULL)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
continue;
|
||||
}
|
||||
@@ -305,7 +316,7 @@ VOID OsPidContainerDestroy(Container *container, LosProcessCB *processCB)
|
||||
}
|
||||
}
|
||||
|
||||
if (LOS_AtomicRead(&pidContainer->rc) <= 0) {
|
||||
if ((container->pidContainer != NULL) && (LOS_AtomicRead(&pidContainer->rc) <= 0)) {
|
||||
g_currentPidContainerNum--;
|
||||
container->pidContainer = NULL;
|
||||
container->pidForChildContainer = NULL;
|
||||
@@ -409,6 +420,10 @@ UINT32 OsCopyPidContainer(UINTPTR flags, LosProcessCB *child, LosProcessCB *pare
|
||||
}
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
if (OsContainerLimitCheck(PID_CONTAINER, &g_currentPidContainerNum) != LOS_OK) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
ret = CreatePidContainer(child, parent);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
@@ -445,6 +460,10 @@ UINT32 OsUnsharePidContainer(UINTPTR flags, LosProcessCB *curr, Container *newCo
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (OsContainerLimitCheck(PID_CONTAINER, &g_currentPidContainerNum) != LOS_OK) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
PidContainer *pidForChild = CreateNewPidContainer(curr->container->pidContainer);
|
||||
if (pidForChild == NULL) {
|
||||
return ENOMEM;
|
||||
@@ -596,4 +615,9 @@ UINT32 OsGetPidContainerID(PidContainer *pidContainer)
|
||||
|
||||
return pidContainer->containerID;
|
||||
}
|
||||
|
||||
UINT32 OsGetPidContainerCount(VOID)
|
||||
{
|
||||
return g_currentPidContainerNum;
|
||||
}
|
||||
#endif
|
||||
@@ -96,6 +96,10 @@ UINT32 OsCopyTimeContainer(UINTPTR flags, LosProcessCB *child, LosProcessCB *par
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (OsContainerLimitCheck(TIME_CONTAINER, &g_currentTimeContainerNum) != LOS_OK) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
return CreateTimeContainer(child, parent);
|
||||
}
|
||||
|
||||
@@ -114,6 +118,10 @@ UINT32 OsUnshareTimeContainer(UINTPTR flags, LosProcessCB *curr, Container *newC
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (OsContainerLimitCheck(TIME_CONTAINER, &g_currentTimeContainerNum) != LOS_OK) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
TimeContainer *timeForChild = CreateNewTimeContainer(curr->container->timeContainer);
|
||||
if (timeForChild == NULL) {
|
||||
return ENOMEM;
|
||||
@@ -242,4 +250,9 @@ UINT32 OsSetTimeContainerMonotonic(LosProcessCB *processCB, struct timespec64 *o
|
||||
timeContainer->monotonic.tv_nsec = offsets->tv_nsec;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 OsGetTimeContainerCount(VOID)
|
||||
{
|
||||
return g_currentTimeContainerNum;
|
||||
}
|
||||
#endif
|
||||
@@ -28,6 +28,7 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LOSCFG_USER_CONTAINER
|
||||
#include "los_user_container_pri.h"
|
||||
#include "errno.h"
|
||||
#include "ctype.h"
|
||||
@@ -47,11 +48,14 @@
|
||||
#define OCT 8
|
||||
#define DEC 10
|
||||
|
||||
#ifdef LOSCFG_USER_CONTAINER
|
||||
UINT32 g_currentUserContainerNum = 1;
|
||||
UINT32 g_currentUserContainerNum = 0;
|
||||
|
||||
UINT32 OsCreateUserContainer(Credentials *newCredentials, UserContainer *parentUserContainer)
|
||||
{
|
||||
if (g_currentUserContainerNum >= OsGetContainerLimit(USER_CONTAINER)) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
if ((parentUserContainer != NULL) && (parentUserContainer->level >= LEVEL_MAX)) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -95,7 +99,11 @@ VOID FreeUserContainer(UserContainer *userContainer)
|
||||
userContainer->parent = NULL;
|
||||
userContainer = parent;
|
||||
g_currentUserContainerNum--;
|
||||
} while ((userContainer != NULL) && (LOS_AtomicRead(&userContainer->rc) <= 0));
|
||||
if (userContainer == NULL) {
|
||||
break;
|
||||
}
|
||||
LOS_AtomicDec(&userContainer->rc);
|
||||
} while (LOS_AtomicRead(&userContainer->rc) <= 0);
|
||||
}
|
||||
|
||||
STATIC UidGidExtent *MapIdUpBase(UINT32 extents, UidGidMap *map, UINT32 id)
|
||||
@@ -423,4 +431,9 @@ INT32 OsUserContainerMapWrite(struct ProcFile *fp, CHAR *kbuf, size_t count,
|
||||
map->extentCount = newMap.extentCount;
|
||||
return count;
|
||||
}
|
||||
|
||||
UINT32 OsGetUserContainerCount(VOID)
|
||||
{
|
||||
return g_currentUserContainerNum;
|
||||
}
|
||||
#endif
|
||||
@@ -28,12 +28,11 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LOSCFG_UTS_CONTAINER
|
||||
#include "internal.h"
|
||||
#include "los_uts_container_pri.h"
|
||||
#include "los_process_pri.h"
|
||||
|
||||
#ifdef LOSCFG_UTS_CONTAINER
|
||||
|
||||
STATIC UINT32 g_currentUtsContainerNum;
|
||||
|
||||
STATIC UINT32 InitUtsContainer(struct utsname *name)
|
||||
@@ -135,6 +134,10 @@ UINT32 OsCopyUtsContainer(UINTPTR flags, LosProcessCB *child, LosProcessCB *pare
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (OsContainerLimitCheck(UTS_CONTAINER, &g_currentUtsContainerNum) != LOS_OK) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
return CreateUtsContainer(child, parent);
|
||||
}
|
||||
|
||||
@@ -151,6 +154,10 @@ UINT32 OsUnshareUtsContainer(UINTPTR flags, LosProcessCB *curr, Container *newCo
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (OsContainerLimitCheck(UTS_CONTAINER, &g_currentUtsContainerNum) != LOS_OK) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
UtsContainer *utsContainer = CreateNewUtsContainer(parentContainer);
|
||||
if (utsContainer == NULL) {
|
||||
return ENOMEM;
|
||||
@@ -226,4 +233,8 @@ UINT32 OsGetUtsContainerID(UtsContainer *utsContainer)
|
||||
return utsContainer->containerID;
|
||||
}
|
||||
|
||||
UINT32 OsGetUtsContainerCount(VOID)
|
||||
{
|
||||
return g_currentUtsContainerNum;
|
||||
}
|
||||
#endif
|
||||
@@ -33,7 +33,7 @@ module_switch = defined(LOSCFG_BASE_CORE_HILOG)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"//base/hiviewdfx/hilog_lite/frameworks/featured/hiview_log.c",
|
||||
"$HIVIEWDFX_HILOG_LITE_DIR/frameworks/featured/hiview_log.c",
|
||||
"los_hilog.c",
|
||||
]
|
||||
|
||||
@@ -42,8 +42,8 @@ kernel_module(module_name) {
|
||||
|
||||
config("public") {
|
||||
include_dirs = [
|
||||
"//base/hiviewdfx/hilog_lite/interfaces/native/kits",
|
||||
"//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog",
|
||||
"$HIVIEWDFX_HILOG_LITE_DIR/interfaces/native/kits",
|
||||
"$HIVIEWDFX_HILOG_LITE_DIR/interfaces/native/kits/hilog",
|
||||
".",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1094,7 +1094,7 @@ ERROR_COPY:
|
||||
return ret;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT STATIC UINT32 CheckRecievedMsg(IpcListNode *node, IpcContent *content, LosTaskCB *tcb)
|
||||
LITE_OS_SEC_TEXT STATIC UINT32 CheckReceivedMsg(IpcListNode *node, IpcContent *content, LosTaskCB *tcb)
|
||||
{
|
||||
UINT32 ret = LOS_OK;
|
||||
if (node == NULL) {
|
||||
@@ -1184,7 +1184,7 @@ LITE_OS_SEC_TEXT STATIC UINT32 LiteIpcRead(IpcContent *content)
|
||||
LOS_ListDelete(listNode);
|
||||
node = LOS_DL_LIST_ENTRY(listNode, IpcListNode, listNode);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
ret = CheckRecievedMsg(node, content, tcb);
|
||||
ret = CheckReceivedMsg(node, content, tcb);
|
||||
if (ret == LOS_OK) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_KERNEL_PIPE)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
|
||||
46
kernel/extended/plimit/BUILD.gn
Normal file
46
kernel/extended/plimit/BUILD.gn
Normal file
@@ -0,0 +1,46 @@
|
||||
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = true
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"los_devicelimit.c",
|
||||
"los_ipclimit.c",
|
||||
"los_memlimit.c",
|
||||
"los_plimits.c",
|
||||
"los_processlimit.c",
|
||||
"los_schedlimit.c",
|
||||
]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "." ]
|
||||
}
|
||||
35
kernel/extended/plimit/Makefile
Normal file
35
kernel/extended/plimit/Makefile
Normal file
@@ -0,0 +1,35 @@
|
||||
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(LITEOSTOPDIR)/config.mk
|
||||
|
||||
MODULE_NAME := $(notdir $(shell pwd))
|
||||
|
||||
LOCAL_SRCS := $(wildcard *.c)
|
||||
|
||||
include $(MODULE)
|
||||
605
kernel/extended/plimit/los_devicelimit.c
Normal file
605
kernel/extended/plimit/los_devicelimit.c
Normal file
@@ -0,0 +1,605 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
||||
#include "los_seq_buf.h"
|
||||
#include "los_bitmap.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "los_devicelimit.h"
|
||||
|
||||
#define TYPE_CHAR_LEN (1)
|
||||
#define DEVICE_NAME_PREFIX_SPACE (1)
|
||||
#define DEVICE_ACCESS_MAXLEN (3)
|
||||
#define BUF_SEPARATOR (5)
|
||||
|
||||
STATIC ProcDevLimit *g_procDevLimit = NULL;
|
||||
|
||||
VOID OsDevLimitInit(UINTPTR limit)
|
||||
{
|
||||
ProcDevLimit *deviceLimit = (ProcDevLimit *)limit;
|
||||
deviceLimit->behavior = DEVLIMIT_DEFAULT_ALLOW;
|
||||
LOS_ListInit(&(deviceLimit->accessList));
|
||||
g_procDevLimit = deviceLimit;
|
||||
}
|
||||
|
||||
VOID *OsDevLimitAlloc(VOID)
|
||||
{
|
||||
ProcDevLimit *plimit = (ProcDevLimit *)LOS_MemAlloc(m_aucSysMem1, sizeof(ProcDevLimit));
|
||||
if (plimit == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
(VOID)memset_s(plimit, sizeof(ProcDevLimit), 0, sizeof(ProcDevLimit));
|
||||
LOS_ListInit(&(plimit->accessList));
|
||||
plimit->behavior = DEVLIMIT_DEFAULT_NONE;
|
||||
return (VOID *)plimit;
|
||||
}
|
||||
|
||||
STATIC VOID DevAccessListDelete(ProcDevLimit *devLimit)
|
||||
{
|
||||
DevAccessItem *delItem = NULL;
|
||||
DevAccessItem *tmpItem = NULL;
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(delItem, tmpItem, &devLimit->accessList, DevAccessItem, list) {
|
||||
LOS_ListDelete(&delItem->list);
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, (VOID *)delItem);
|
||||
}
|
||||
}
|
||||
|
||||
VOID OsDevLimitFree(UINTPTR limit)
|
||||
{
|
||||
ProcDevLimit *devLimit = (ProcDevLimit *)limit;
|
||||
if (devLimit == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
DevAccessListDelete(devLimit);
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, devLimit);
|
||||
}
|
||||
|
||||
STATIC UINT32 DevLimitCopyAccess(ProcDevLimit *devLimitDest, ProcDevLimit *devLimitSrc)
|
||||
{
|
||||
DevAccessItem *tmpItem = NULL;
|
||||
INT32 itemSize = sizeof(DevAccessItem);
|
||||
devLimitDest->behavior = devLimitSrc->behavior;
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(tmpItem, &devLimitSrc->accessList, DevAccessItem, list) {
|
||||
DevAccessItem *newItem = (DevAccessItem *)LOS_MemAlloc(m_aucSysMem1, itemSize);
|
||||
if (newItem == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
(VOID)memcpy_s(newItem, sizeof(DevAccessItem), tmpItem, sizeof(DevAccessItem));
|
||||
LOS_ListTailInsert(&devLimitDest->accessList, &newItem->list);
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID OsDevLimitCopy(UINTPTR dest, UINTPTR src)
|
||||
{
|
||||
ProcDevLimit *devLimitDest = (ProcDevLimit *)dest;
|
||||
ProcDevLimit *devLimitSrc = (ProcDevLimit *)src;
|
||||
(VOID)DevLimitCopyAccess(devLimitDest, devLimitSrc);
|
||||
devLimitDest->parent = (ProcDevLimit *)src;
|
||||
}
|
||||
|
||||
STATIC INLINE INT32 IsSpace(INT32 c)
|
||||
{
|
||||
return (c == ' ' || (unsigned)c - '\t' < BUF_SEPARATOR);
|
||||
}
|
||||
|
||||
STATIC UINT32 ParseItemAccess(const CHAR *buf, DevAccessItem *item)
|
||||
{
|
||||
switch (*buf) {
|
||||
case 'a':
|
||||
item->type = DEVLIMIT_DEV_ALL;
|
||||
return LOS_OK;
|
||||
case 'b':
|
||||
item->type = DEVLIMIT_DEV_BLOCK;
|
||||
break;
|
||||
case 'c':
|
||||
item->type = DEVLIMIT_DEV_CHAR;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
buf += DEVICE_NAME_PREFIX_SPACE;
|
||||
if (!IsSpace(*buf)) {
|
||||
return EINVAL;
|
||||
}
|
||||
buf += DEVICE_NAME_PREFIX_SPACE;
|
||||
|
||||
for (INT32 count = 0; count < sizeof(item->name) - 1; count++) {
|
||||
if (IsSpace(*buf)) {
|
||||
break;
|
||||
}
|
||||
item->name[count] = *buf;
|
||||
buf += TYPE_CHAR_LEN;
|
||||
}
|
||||
if (!IsSpace(*buf)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
buf += DEVICE_NAME_PREFIX_SPACE;
|
||||
for (INT32 i = 0; i < DEVICE_ACCESS_MAXLEN; i++) {
|
||||
switch (*buf) {
|
||||
case 'r':
|
||||
item->access |= DEVLIMIT_ACC_READ;
|
||||
break;
|
||||
case 'w':
|
||||
item->access |= DEVLIMIT_ACC_WRITE;
|
||||
break;
|
||||
case 'm':
|
||||
item->access |= DEVLIMIT_ACC_MKNOD;
|
||||
break;
|
||||
case '\n':
|
||||
case '\0':
|
||||
i = DEVICE_ACCESS_MAXLEN;
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
buf += TYPE_CHAR_LEN;
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC BOOL DevLimitMayAllowAll(ProcDevLimit *parent)
|
||||
{
|
||||
if (parent == NULL) {
|
||||
return TRUE;
|
||||
}
|
||||
return (parent->behavior == DEVLIMIT_DEFAULT_ALLOW);
|
||||
}
|
||||
|
||||
STATIC BOOL DevLimitHasChildren(ProcLimitSet *procLimitSet, ProcDevLimit *devLimit)
|
||||
{
|
||||
ProcLimitSet *parent = procLimitSet;
|
||||
ProcLimitSet *childProcLimitSet = NULL;
|
||||
if (devLimit == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(childProcLimitSet, &(procLimitSet->childList), ProcLimitSet, childList) {
|
||||
if (childProcLimitSet == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (childProcLimitSet->parent != parent) {
|
||||
continue;
|
||||
}
|
||||
if (!((childProcLimitSet->mask) & BIT(PROCESS_LIMITER_ID_DEV))) {
|
||||
continue;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC UINT32 DealItemAllAccess(ProcLimitSet *procLimitSet, ProcDevLimit *devLimit,
|
||||
ProcDevLimit *devParentLimit, INT32 filetype)
|
||||
{
|
||||
switch (filetype) {
|
||||
case DEVLIMIT_ALLOW: {
|
||||
if (DevLimitHasChildren(procLimitSet, devLimit)) {
|
||||
return EINVAL;
|
||||
}
|
||||
if (!DevLimitMayAllowAll(devParentLimit)) {
|
||||
return EPERM;
|
||||
}
|
||||
DevAccessListDelete(devLimit);
|
||||
devLimit->behavior = DEVLIMIT_DEFAULT_ALLOW;
|
||||
if (devParentLimit == NULL) {
|
||||
break;
|
||||
}
|
||||
DevLimitCopyAccess(devLimit, devParentLimit);
|
||||
break;
|
||||
}
|
||||
case DEVLIMIT_DENY: {
|
||||
if (DevLimitHasChildren(procLimitSet, devLimit)) {
|
||||
return EINVAL;
|
||||
}
|
||||
DevAccessListDelete(devLimit);
|
||||
devLimit->behavior = DEVLIMIT_DEFAULT_DENY;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return EINVAL;
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC BOOL DevLimitMatchItemPartial(LOS_DL_LIST *list, DevAccessItem *item)
|
||||
{
|
||||
if ((list == NULL) || (item == NULL)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (LOS_ListEmpty(list)) {
|
||||
return FALSE;
|
||||
}
|
||||
DevAccessItem *walk = NULL;
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(walk, list, DevAccessItem, list) {
|
||||
if (item->type != walk->type) {
|
||||
continue;
|
||||
}
|
||||
if ((strcmp(walk->name, "*") != 0) && (strcmp(item->name, "*") != 0)
|
||||
&& (strcmp(walk->name, item->name) != 0)) {
|
||||
continue;
|
||||
}
|
||||
if (!(item->access & ~(walk->access))) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC BOOL DevLimitParentAllowsRmItem(ProcDevLimit *devParentLimit, DevAccessItem *item)
|
||||
{
|
||||
if (devParentLimit == NULL) {
|
||||
return TRUE;
|
||||
}
|
||||
/* Make sure you're not removing part or a whole item existing in the parent plimits */
|
||||
return !DevLimitMatchItemPartial(&devParentLimit->accessList, item);
|
||||
}
|
||||
|
||||
STATIC BOOL DevLimitMatchItem(LOS_DL_LIST *list, DevAccessItem *item)
|
||||
{
|
||||
if ((list == NULL) || (item == NULL)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (LOS_ListEmpty(list)) {
|
||||
return FALSE;
|
||||
}
|
||||
DevAccessItem *walk = NULL;
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(walk, list, DevAccessItem, list) {
|
||||
if (item->type != walk->type) {
|
||||
continue;
|
||||
}
|
||||
if ((strcmp(walk->name, "*") != 0) && (strcmp(walk->name, item->name) != 0)) {
|
||||
continue;
|
||||
}
|
||||
if (!(item->access & ~(walk->access))) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is used to make sure a child plimits won't have more privileges than its parent
|
||||
*/
|
||||
STATIC BOOL DevLimitVerifyNewItem(ProcDevLimit *parent, DevAccessItem *item, INT32 currBehavior)
|
||||
{
|
||||
if (parent == NULL) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (parent->behavior == DEVLIMIT_DEFAULT_ALLOW) {
|
||||
if (currBehavior == DEVLIMIT_DEFAULT_ALLOW) {
|
||||
return TRUE;
|
||||
}
|
||||
return !DevLimitMatchItemPartial(&parent->accessList, item);
|
||||
}
|
||||
return DevLimitMatchItem(&parent->accessList, item);
|
||||
}
|
||||
|
||||
STATIC BOOL DevLimitParentAllowsAddItem(ProcDevLimit *devParentLimit, DevAccessItem *item, INT32 currBehavior)
|
||||
{
|
||||
return DevLimitVerifyNewItem(devParentLimit, item, currBehavior);
|
||||
}
|
||||
|
||||
STATIC VOID DevLimitAccessListRm(ProcDevLimit *devLimit, DevAccessItem *item)
|
||||
{
|
||||
if ((item == NULL) || (devLimit == NULL)) {
|
||||
return;
|
||||
}
|
||||
DevAccessItem *walk, *tmp = NULL;
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(walk, tmp, &devLimit->accessList, DevAccessItem, list) {
|
||||
if (walk->type != item->type) {
|
||||
continue;
|
||||
}
|
||||
if (strcmp(walk->name, item->name) != 0) {
|
||||
continue;
|
||||
}
|
||||
walk->access &= ~item->access;
|
||||
if (!walk->access) {
|
||||
LOS_ListDelete(&walk->list);
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, (VOID *)walk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
STATIC UINT32 DevLimitAccessListAdd(ProcDevLimit *devLimit, DevAccessItem *item)
|
||||
{
|
||||
if ((item == NULL) || (devLimit == NULL)) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
DevAccessItem *walk = NULL;
|
||||
DevAccessItem *newItem = (DevAccessItem *)LOS_MemAlloc(m_aucSysMem1, sizeof(DevAccessItem));
|
||||
if (newItem == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
(VOID)memcpy_s(newItem, sizeof(DevAccessItem), item, sizeof(DevAccessItem));
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(walk, &devLimit->accessList, DevAccessItem, list) {
|
||||
if (walk->type != item->type) {
|
||||
continue;
|
||||
}
|
||||
if (strcmp(walk->name, item->name) != 0) {
|
||||
continue;
|
||||
}
|
||||
walk->access |= item->access;
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, (VOID *)newItem);
|
||||
newItem = NULL;
|
||||
}
|
||||
|
||||
if (newItem != NULL) {
|
||||
LOS_ListTailInsert(&devLimit->accessList, &newItem->list);
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Revalidate permissions
|
||||
*/
|
||||
STATIC VOID DevLimitRevalidateActiveItems(ProcDevLimit *devLimit, ProcDevLimit *devParentLimit)
|
||||
{
|
||||
if ((devLimit == NULL) || (devParentLimit == NULL)) {
|
||||
return;
|
||||
}
|
||||
DevAccessItem *walK = NULL;
|
||||
DevAccessItem *tmp = NULL;
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(walK, tmp, &devLimit->accessList, DevAccessItem, list) {
|
||||
if (!DevLimitParentAllowsAddItem(devParentLimit, walK, devLimit->behavior)) {
|
||||
DevLimitAccessListRm(devLimit, walK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* propagates a new item to the children
|
||||
*/
|
||||
STATIC UINT32 DevLimitPropagateItem(ProcLimitSet *procLimitSet, ProcDevLimit *devLimit, DevAccessItem *item)
|
||||
{
|
||||
UINT32 ret = LOS_OK;
|
||||
ProcLimitSet *parent = procLimitSet;
|
||||
ProcLimitSet *childProcLimitSet = NULL;
|
||||
|
||||
if ((procLimitSet == NULL) || (item == NULL)) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (devLimit == NULL) {
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(childProcLimitSet, &procLimitSet->childList, ProcLimitSet, childList) {
|
||||
if (childProcLimitSet == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (childProcLimitSet->parent != parent) {
|
||||
continue;
|
||||
}
|
||||
if (!((childProcLimitSet->mask) & BIT(PROCESS_LIMITER_ID_DEV))) {
|
||||
continue;
|
||||
}
|
||||
ProcDevLimit *devLimitChild = (ProcDevLimit *)childProcLimitSet->limitsList[PROCESS_LIMITER_ID_DEV];
|
||||
if (devLimit->behavior == DEVLIMIT_DEFAULT_ALLOW &&
|
||||
devLimitChild->behavior == DEVLIMIT_DEFAULT_ALLOW) {
|
||||
ret = DevLimitAccessListAdd(devLimitChild, item);
|
||||
} else {
|
||||
DevLimitAccessListRm(devLimitChild, item);
|
||||
}
|
||||
DevLimitRevalidateActiveItems(devLimitChild, (ProcDevLimit *)parent->limitsList[PROCESS_LIMITER_ID_DEV]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
STATIC UINT32 DevLimitUpdateAccess(ProcLimitSet *procLimitSet, const CHAR *buf, INT32 filetype)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 intSave;
|
||||
DevAccessItem item = {0};
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
ProcDevLimit *devLimit = (ProcDevLimit *)(procLimitSet->limitsList[PROCESS_LIMITER_ID_DEV]);
|
||||
ProcDevLimit *devParentLimit = devLimit->parent;
|
||||
|
||||
ret = ParseItemAccess(buf, &item);
|
||||
if (ret != LOS_OK) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return ret;
|
||||
}
|
||||
if (item.type == DEVLIMIT_DEV_ALL) {
|
||||
ret = DealItemAllAccess(procLimitSet, devLimit, devParentLimit, filetype);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return ret;
|
||||
}
|
||||
switch (filetype) {
|
||||
case DEVLIMIT_ALLOW: {
|
||||
if (devLimit->behavior == DEVLIMIT_DEFAULT_ALLOW) {
|
||||
if (!DevLimitParentAllowsRmItem(devParentLimit, &item)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EPERM;
|
||||
}
|
||||
DevLimitAccessListRm(devLimit, &item);
|
||||
break;
|
||||
}
|
||||
if (!DevLimitParentAllowsAddItem(devParentLimit, &item, devLimit->behavior)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EPERM;
|
||||
}
|
||||
ret = DevLimitAccessListAdd(devLimit, &item);
|
||||
break;
|
||||
}
|
||||
case DEVLIMIT_DENY: {
|
||||
if (devLimit->behavior == DEVLIMIT_DEFAULT_DENY) {
|
||||
DevLimitAccessListRm(devLimit, &item);
|
||||
} else {
|
||||
ret = DevLimitAccessListAdd(devLimit, &item);
|
||||
}
|
||||
// update child access list
|
||||
ret = DevLimitPropagateItem(procLimitSet, devLimit, &item);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = EINVAL;
|
||||
break;
|
||||
}
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
UINT32 OsDevLimitWriteAllow(ProcLimitSet *plimit, const CHAR *buf, UINT32 size)
|
||||
{
|
||||
(VOID)size;
|
||||
return DevLimitUpdateAccess(plimit, buf, DEVLIMIT_ALLOW);
|
||||
}
|
||||
|
||||
UINT32 OsDevLimitWriteDeny(ProcLimitSet *plimit, const CHAR *buf, UINT32 size)
|
||||
{
|
||||
(VOID)size;
|
||||
return DevLimitUpdateAccess(plimit, buf, DEVLIMIT_DENY);
|
||||
}
|
||||
|
||||
STATIC VOID DevLimitItemSetAccess(CHAR *accArray, INT16 access)
|
||||
{
|
||||
INT32 index = 0;
|
||||
(VOID)memset_s(acc, ACCLEN, 0, ACCLEN);
|
||||
if (access & DEVLIMIT_ACC_READ) {
|
||||
accArray[index] = 'r';
|
||||
index++;
|
||||
}
|
||||
if (access & DEVLIMIT_ACC_WRITE) {
|
||||
accArray[index] = 'w';
|
||||
index++;
|
||||
}
|
||||
if (access & DEVLIMIT_ACC_MKNOD) {
|
||||
accArray[index] = 'm';
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
STATIC CHAR DevLimitItemTypeToChar(INT16 type)
|
||||
{
|
||||
switch (type) {
|
||||
case DEVLIMIT_DEV_ALL:
|
||||
return 'a';
|
||||
case DEVLIMIT_DEV_CHAR:
|
||||
return 'c';
|
||||
case DEVLIMIT_DEV_BLOCK:
|
||||
return 'b';
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 'X';
|
||||
}
|
||||
|
||||
UINT32 OsDevLimitShow(ProcDevLimit *devLimit, struct SeqBuf *seqBuf)
|
||||
{
|
||||
DevAccessItem *item = NULL;
|
||||
CHAR acc[ACCLEN];
|
||||
UINT32 intSave;
|
||||
|
||||
if ((devLimit == NULL) || (seqBuf == NULL)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (devLimit->behavior == DEVLIMIT_DEFAULT_ALLOW) {
|
||||
DevLimitItemSetAccess(acc, DEVLIMIT_ACC_MASK);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
LosBufPrintf(seqBuf, "%c %s %s\n", DevLimitItemTypeToChar(DEVLIMIT_DEV_ALL), "*", acc);
|
||||
return LOS_OK;
|
||||
}
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(item, &devLimit->accessList, DevAccessItem, list) {
|
||||
DevLimitItemSetAccess(acc, item->access);
|
||||
LosBufPrintf(seqBuf, "%c %s %s\n", DevLimitItemTypeToChar(item->type), item->name, acc);
|
||||
}
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC INLINE INT16 ConversionDevType(INT32 vnodeType)
|
||||
{
|
||||
INT16 type = 0;
|
||||
if (vnodeType == VNODE_TYPE_BLK) {
|
||||
type = DEVLIMIT_DEV_BLOCK;
|
||||
} else if (vnodeType == VNODE_TYPE_CHR) {
|
||||
type = DEVLIMIT_DEV_CHAR;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
STATIC INLINE INT16 ConversionDevAccess(INT32 flags)
|
||||
{
|
||||
INT16 access = 0;
|
||||
if ((flags & O_ACCMODE) == O_RDONLY) {
|
||||
access |= DEVLIMIT_ACC_READ;
|
||||
}
|
||||
if (flags & O_WRONLY) {
|
||||
access |= DEVLIMIT_ACC_WRITE;
|
||||
}
|
||||
if (flags & O_RDWR) {
|
||||
access |= DEVLIMIT_ACC_WRITE | DEVLIMIT_ACC_READ;
|
||||
}
|
||||
if (flags & O_CREAT) {
|
||||
access |= DEVLIMIT_ACC_MKNOD;
|
||||
}
|
||||
return access;
|
||||
}
|
||||
|
||||
UINT32 OsDevLimitCheckPermission(INT32 vnodeType, const CHAR *pathName, INT32 flags)
|
||||
{
|
||||
BOOL matched = FALSE;
|
||||
DevAccessItem item = {0};
|
||||
LosProcessCB *run = OsCurrProcessGet();
|
||||
if ((run == NULL) || (run->plimits == NULL)) {
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (pathName == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
ProcDevLimit *devLimit = (ProcDevLimit *)run->plimits->limitsList[PROCESS_LIMITER_ID_DEV];
|
||||
|
||||
item.type = ConversionDevType(vnodeType);
|
||||
item.access = ConversionDevAccess(flags);
|
||||
LOS_ListInit(&(item.list));
|
||||
(VOID)strncpy_s(item.name, PATH_MAX, pathName, PATH_MAX);
|
||||
|
||||
if (devLimit->behavior == DEVLIMIT_DEFAULT_ALLOW) {
|
||||
matched = !DevLimitMatchItemPartial(&devLimit->accessList, &item);
|
||||
} else {
|
||||
matched = DevLimitMatchItem(&devLimit->accessList, &item);
|
||||
}
|
||||
if (!matched) {
|
||||
return EPERM;
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
#endif
|
||||
96
kernel/extended/plimit/los_devicelimit.h
Normal file
96
kernel/extended/plimit/los_devicelimit.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_DEVICELIMIT_H
|
||||
#define _LOS_DEVICELIMIT_H
|
||||
|
||||
#include "los_typedef.h"
|
||||
#include "los_list.h"
|
||||
#include "vfs_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define DEVLIMIT_ACC_MKNOD 1
|
||||
#define DEVLIMIT_ACC_READ 2
|
||||
#define DEVLIMIT_ACC_WRITE 4
|
||||
#define DEVLIMIT_ACC_MASK (DEVLIMIT_ACC_MKNOD | DEVLIMIT_ACC_READ | DEVLIMIT_ACC_WRITE)
|
||||
|
||||
#define DEVLIMIT_DEV_BLOCK 1
|
||||
#define DEVLIMIT_DEV_CHAR 2
|
||||
#define DEVLIMIT_DEV_ALL 4 /* all devices */
|
||||
|
||||
#define DEVLIMIT_ALLOW 1
|
||||
#define DEVLIMIT_DENY 2
|
||||
|
||||
#define ACCLEN 4
|
||||
|
||||
struct SeqBuf;
|
||||
typedef struct TagPLimiterSet ProcLimitSet;
|
||||
|
||||
enum DevLimitBehavior {
|
||||
DEVLIMIT_DEFAULT_NONE,
|
||||
DEVLIMIT_DEFAULT_ALLOW,
|
||||
DEVLIMIT_DEFAULT_DENY,
|
||||
};
|
||||
|
||||
typedef struct DevAccessItem {
|
||||
INT16 type;
|
||||
INT16 access;
|
||||
LOS_DL_LIST list;
|
||||
CHAR name[PATH_MAX];
|
||||
} DevAccessItem;
|
||||
|
||||
typedef struct ProcDevLimit {
|
||||
struct ProcDevLimit *parent;
|
||||
UINT8 allowFile;
|
||||
UINT8 denyFile;
|
||||
LOS_DL_LIST accessList; // device belong to devicelimite
|
||||
enum DevLimitBehavior behavior;
|
||||
} ProcDevLimit;
|
||||
|
||||
VOID OsDevLimitInit(UINTPTR limit);
|
||||
VOID *OsDevLimitAlloc(VOID);
|
||||
VOID OsDevLimitFree(UINTPTR limit);
|
||||
VOID OsDevLimitCopy(UINTPTR dest, UINTPTR src);
|
||||
UINT32 OsDevLimitWriteAllow(ProcLimitSet *plimit, const CHAR *buf, UINT32 size);
|
||||
UINT32 OsDevLimitWriteDeny(ProcLimitSet *plimit, const CHAR *buf, UINT32 size);
|
||||
UINT32 OsDevLimitShow(ProcDevLimit *devLimit, struct SeqBuf *seqBuf);
|
||||
UINT32 OsDevLimitCheckPermission(INT32 vnodeType, const CHAR *pathName, INT32 flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
#endif /* _LOS_DEVICELIMIT_H */
|
||||
249
kernel/extended/plimit/los_ipclimit.c
Normal file
249
kernel/extended/plimit/los_ipclimit.c
Normal file
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
#include "los_ipclimit.h"
|
||||
#include "los_process_pri.h"
|
||||
|
||||
STATIC ProcIPCLimit *g_rootIPCLimit = NULL;
|
||||
#define PLIMIT_IPC_SHM_LIMIT_MAX 0xFFFFFFFF
|
||||
|
||||
VOID OsIPCLimitInit(UINTPTR limite)
|
||||
{
|
||||
ProcIPCLimit *plimite = (ProcIPCLimit *)limite;
|
||||
plimite->mqCountLimit = LOSCFG_BASE_IPC_QUEUE_LIMIT;
|
||||
plimite->shmSizeLimit = PLIMIT_IPC_SHM_LIMIT_MAX;
|
||||
g_rootIPCLimit = plimite;
|
||||
}
|
||||
|
||||
VOID *OsIPCLimitAlloc(VOID)
|
||||
{
|
||||
ProcIPCLimit *plimite = (ProcIPCLimit *)LOS_MemAlloc(m_aucSysMem1, sizeof(ProcIPCLimit));
|
||||
if (plimite == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
(VOID)memset_s(plimite, sizeof(ProcIPCLimit), 0, sizeof(ProcIPCLimit));
|
||||
return (VOID *)plimite;
|
||||
}
|
||||
|
||||
VOID OsIPCLimitFree(UINTPTR limite)
|
||||
{
|
||||
ProcIPCLimit *plimite = (ProcIPCLimit *)limite;
|
||||
if (plimite == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, (VOID *)plimite);
|
||||
}
|
||||
|
||||
VOID OsIPCLimitCopy(UINTPTR dest, UINTPTR src)
|
||||
{
|
||||
ProcIPCLimit *plimiteDest = (ProcIPCLimit *)dest;
|
||||
ProcIPCLimit *plimiteSrc = (ProcIPCLimit *)src;
|
||||
plimiteDest->mqCountLimit = plimiteSrc->mqCountLimit;
|
||||
plimiteDest->shmSizeLimit = plimiteSrc->shmSizeLimit;
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL OsIPCLimiteMigrateCheck(UINTPTR curr, UINTPTR parent)
|
||||
{
|
||||
ProcIPCLimit *currIpcLimit = (ProcIPCLimit *)curr;
|
||||
ProcIPCLimit *parentIpcLimit = (ProcIPCLimit *)parent;
|
||||
if ((currIpcLimit->mqCount + parentIpcLimit->mqCount) >= parentIpcLimit->mqCountLimit) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((currIpcLimit->shmSize + parentIpcLimit->shmSize) >= parentIpcLimit->shmSizeLimit) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID OsIPCLimitMigrate(UINTPTR currLimit, UINTPTR parentLimit, UINTPTR process)
|
||||
{
|
||||
ProcIPCLimit *currIpcLimit = (ProcIPCLimit *)currLimit;
|
||||
ProcIPCLimit *parentIpcLimit = (ProcIPCLimit *)parentLimit;
|
||||
LosProcessCB *pcb = (LosProcessCB *)process;
|
||||
|
||||
if (pcb == NULL) {
|
||||
parentIpcLimit->mqCount += currIpcLimit->mqCount;
|
||||
parentIpcLimit->mqFailedCount += currIpcLimit->mqFailedCount;
|
||||
parentIpcLimit->shmSize += currIpcLimit->shmSize;
|
||||
parentIpcLimit->shmFailedCount += currIpcLimit->shmFailedCount;
|
||||
return;
|
||||
}
|
||||
|
||||
parentIpcLimit->mqCount -= pcb->limitStat.mqCount;
|
||||
parentIpcLimit->shmSize -= pcb->limitStat.shmSize;
|
||||
currIpcLimit->mqCount += pcb->limitStat.mqCount;
|
||||
currIpcLimit->shmSize += pcb->limitStat.shmSize;
|
||||
}
|
||||
|
||||
BOOL OsIPCLimitAddProcessCheck(UINTPTR limit, UINTPTR process)
|
||||
{
|
||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)limit;
|
||||
LosProcessCB *pcb = (LosProcessCB *)process;
|
||||
if ((ipcLimit->mqCount + pcb->limitStat.mqCount) >= ipcLimit->mqCountLimit) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((ipcLimit->shmSize + pcb->limitStat.shmSize) >= ipcLimit->shmSizeLimit) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID OsIPCLimitAddProcess(UINTPTR limit, UINTPTR process)
|
||||
{
|
||||
LosProcessCB *pcb = (LosProcessCB *)process;
|
||||
ProcIPCLimit *plimits = (ProcIPCLimit *)limit;
|
||||
plimits->mqCount += pcb->limitStat.mqCount;
|
||||
plimits->shmSize += pcb->limitStat.shmSize;
|
||||
return;
|
||||
}
|
||||
|
||||
VOID OsIPCLimitDelProcess(UINTPTR limit, UINTPTR process)
|
||||
{
|
||||
LosProcessCB *pcb = (LosProcessCB *)process;
|
||||
ProcIPCLimit *plimits = (ProcIPCLimit *)limit;
|
||||
|
||||
plimits->mqCount -= pcb->limitStat.mqCount;
|
||||
plimits->shmSize -= pcb->limitStat.shmSize;
|
||||
return;
|
||||
}
|
||||
|
||||
UINT32 OsIPCLimitSetMqLimit(ProcIPCLimit *ipcLimit, UINT32 value)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
if ((ipcLimit == NULL) || (value == 0) || (value > LOSCFG_BASE_IPC_QUEUE_LIMIT)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (ipcLimit == g_rootIPCLimit) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (value < ipcLimit->mqCount) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
ipcLimit->mqCountLimit = value;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 OsIPCLimitSetShmLimit(ProcIPCLimit *ipcLimit, UINT32 value)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
if ((ipcLimit == NULL) || (value == 0) || (value > PLIMIT_IPC_SHM_LIMIT_MAX)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (ipcLimit == g_rootIPCLimit) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (value < ipcLimit->shmSize) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
ipcLimit->shmSizeLimit = value;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 OsIPCLimitMqAlloc(VOID)
|
||||
{
|
||||
UINT32 intSave;
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LosProcessCB *run = OsCurrProcessGet();
|
||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)run->plimits->limitsList[PROCESS_LIMITER_ID_IPC];
|
||||
if (ipcLimit->mqCount >= ipcLimit->mqCountLimit) {
|
||||
ipcLimit->mqFailedCount++;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
run->limitStat.mqCount++;
|
||||
ipcLimit->mqCount++;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID OsIPCLimitMqFree(VOID)
|
||||
{
|
||||
UINT32 intSave;
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LosProcessCB *run = OsCurrProcessGet();
|
||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)run->plimits->limitsList[PROCESS_LIMITER_ID_IPC];
|
||||
ipcLimit->mqCount--;
|
||||
run->limitStat.mqCount--;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
UINT32 OsIPCLimitShmAlloc(UINT32 size)
|
||||
{
|
||||
UINT32 intSave;
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LosProcessCB *run = OsCurrProcessGet();
|
||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)run->plimits->limitsList[PROCESS_LIMITER_ID_IPC];
|
||||
if ((ipcLimit->shmSize + size) >= ipcLimit->shmSizeLimit) {
|
||||
ipcLimit->shmFailedCount++;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
run->limitStat.shmSize += size;
|
||||
ipcLimit->shmSize += size;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID OsIPCLimitShmFree(UINT32 size)
|
||||
{
|
||||
UINT32 intSave;
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LosProcessCB *run = OsCurrProcessGet();
|
||||
ProcIPCLimit *ipcLimit = (ProcIPCLimit *)run->plimits->limitsList[PROCESS_LIMITER_ID_IPC];
|
||||
ipcLimit->shmSize -= size;
|
||||
run->limitStat.shmSize -= size;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
92
kernel/extended/plimit/los_ipclimit.h
Normal file
92
kernel/extended/plimit/los_ipclimit.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_IPCLIMIT_H
|
||||
#define _LOS_IPCLIMIT_H
|
||||
|
||||
#include "los_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct ProcIPCLimit {
|
||||
UINT32 mqCount;
|
||||
UINT32 mqFailedCount;
|
||||
UINT32 mqCountLimit;
|
||||
UINT32 shmSize;
|
||||
UINT32 shmFailedCount;
|
||||
UINT32 shmSizeLimit;
|
||||
} ProcIPCLimit;
|
||||
|
||||
enum IPCStatType {
|
||||
IPC_STAT_TYPE_MQ = 0,
|
||||
IPC_STAT_TYPE_SHM = 3,
|
||||
IPC_STAT_TYPE_BUT // buttock
|
||||
};
|
||||
|
||||
enum IPCStatOffset {
|
||||
IPC_STAT_OFFSET_MQ = 0,
|
||||
IPC_STAT_OFFSET_SHM = 3,
|
||||
IPC_STAT_OFFSET_BUT // buttock
|
||||
};
|
||||
|
||||
enum StatItem {
|
||||
STAT_ITEM_TOTAL,
|
||||
STAT_ITEM_FAILED,
|
||||
STAT_ITEM_LIMIT,
|
||||
STAT_ITEM_BUT // buttock
|
||||
};
|
||||
|
||||
VOID OsIPCLimitInit(UINTPTR limite);
|
||||
VOID *OsIPCLimitAlloc(VOID);
|
||||
VOID OsIPCLimitFree(UINTPTR limite);
|
||||
VOID OsIPCLimitCopy(UINTPTR dest, UINTPTR src);
|
||||
BOOL OsIPCLimiteMigrateCheck(UINTPTR curr, UINTPTR parent);
|
||||
VOID OsIPCLimitMigrate(UINTPTR currLimit, UINTPTR parentLimit, UINTPTR process);
|
||||
BOOL OsIPCLimitAddProcessCheck(UINTPTR limit, UINTPTR process);
|
||||
VOID OsIPCLimitAddProcess(UINTPTR limit, UINTPTR process);
|
||||
VOID OsIPCLimitDelProcess(UINTPTR limit, UINTPTR process);
|
||||
UINT32 OsIPCLimitSetMqLimit(ProcIPCLimit *ipcLimit, UINT32 value);
|
||||
UINT32 OsIPCLimitSetShmLimit(ProcIPCLimit *ipcLimit, UINT32 value);
|
||||
UINT32 OsIPCLimitMqAlloc(VOID);
|
||||
VOID OsIPCLimitMqFree(VOID);
|
||||
UINT32 OsIPCLimitShmAlloc(UINT32 size);
|
||||
VOID OsIPCLimitShmFree(UINT32 size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_IPCIMIT_H */
|
||||
223
kernel/extended/plimit/los_memlimit.c
Normal file
223
kernel/extended/plimit/los_memlimit.c
Normal file
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
||||
#include <stdlib.h>
|
||||
#include <securec.h>
|
||||
#include "los_config.h"
|
||||
#include "los_hook.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "los_plimits.h"
|
||||
|
||||
STATIC ProcMemLimiter *g_procMemLimiter = NULL;
|
||||
|
||||
VOID OsMemLimiterInit(UINTPTR limite)
|
||||
{
|
||||
ProcMemLimiter *procMemLimiter = (ProcMemLimiter *)limite;
|
||||
procMemLimiter->limit = OS_NULL_INT;
|
||||
g_procMemLimiter = procMemLimiter;
|
||||
}
|
||||
|
||||
VOID OsMemLimitSetLimit(UINT32 limit)
|
||||
{
|
||||
g_procMemLimiter->limit = limit;
|
||||
}
|
||||
|
||||
VOID *OsMemLimiterAlloc(VOID)
|
||||
{
|
||||
ProcMemLimiter *plimite = (ProcMemLimiter *)LOS_MemAlloc(m_aucSysMem1, sizeof(ProcMemLimiter));
|
||||
if (plimite == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
(VOID)memset_s(plimite, sizeof(ProcMemLimiter), 0, sizeof(ProcMemLimiter));
|
||||
return (VOID *)plimite;
|
||||
}
|
||||
|
||||
VOID OsMemLimiterFree(UINTPTR limite)
|
||||
{
|
||||
ProcMemLimiter *plimite = (ProcMemLimiter *)limite;
|
||||
if (plimite == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, (VOID *)limite);
|
||||
}
|
||||
|
||||
VOID OsMemLimiterCopy(UINTPTR dest, UINTPTR src)
|
||||
{
|
||||
ProcMemLimiter *plimiteDest = (ProcMemLimiter *)dest;
|
||||
ProcMemLimiter *plimiteSrc = (ProcMemLimiter *)src;
|
||||
plimiteDest->limit = plimiteSrc->limit;
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL MemLimiteMigrateCheck(UINTPTR curr, UINTPTR parent)
|
||||
{
|
||||
ProcMemLimiter *currMemLimit = (ProcMemLimiter *)curr;
|
||||
ProcMemLimiter *parentMemLimit = (ProcMemLimiter *)parent;
|
||||
if ((currMemLimit->usage + parentMemLimit->usage) >= parentMemLimit->limit) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID OsMemLimiterMigrate(UINTPTR currLimit, UINTPTR parentLimit, UINTPTR process)
|
||||
{
|
||||
ProcMemLimiter *currMemLimit = (ProcMemLimiter *)currLimit;
|
||||
ProcMemLimiter *parentMemLimit = (ProcMemLimiter *)parentLimit;
|
||||
LosProcessCB *pcb = (LosProcessCB *)process;
|
||||
|
||||
if (pcb == NULL) {
|
||||
parentMemLimit->usage += currMemLimit->usage;
|
||||
parentMemLimit->failcnt += currMemLimit->failcnt;
|
||||
if (parentMemLimit->peak < parentMemLimit->usage) {
|
||||
parentMemLimit->peak = parentMemLimit->usage;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
parentMemLimit->usage -= pcb->limitStat.memUsed;
|
||||
currMemLimit->usage += pcb->limitStat.memUsed;
|
||||
}
|
||||
|
||||
BOOL OsMemLimitAddProcessCheck(UINTPTR limit, UINTPTR process)
|
||||
{
|
||||
ProcMemLimiter *memLimit = (ProcMemLimiter *)limit;
|
||||
LosProcessCB *pcb = (LosProcessCB *)process;
|
||||
if ((memLimit->usage + pcb->limitStat.memUsed) > memLimit->limit) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID OsMemLimitAddProcess(UINTPTR limit, UINTPTR process)
|
||||
{
|
||||
LosProcessCB *pcb = (LosProcessCB *)process;
|
||||
ProcMemLimiter *plimits = (ProcMemLimiter *)limit;
|
||||
plimits->usage += pcb->limitStat.memUsed;
|
||||
if (plimits->peak < plimits->usage) {
|
||||
plimits->peak = plimits->usage;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
VOID OsMemLimitDelProcess(UINTPTR limit, UINTPTR process)
|
||||
{
|
||||
LosProcessCB *pcb = (LosProcessCB *)process;
|
||||
ProcMemLimiter *plimits = (ProcMemLimiter *)limit;
|
||||
|
||||
plimits->usage -= pcb->limitStat.memUsed;
|
||||
return;
|
||||
}
|
||||
|
||||
UINT32 OsMemLimitSetMemLimit(ProcMemLimiter *memLimit, UINT64 value)
|
||||
{
|
||||
UINT32 intSave;
|
||||
if ((memLimit == NULL) || (value == 0)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (memLimit == g_procMemLimiter) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (value < memLimit->usage) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
memLimit->limit = value;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#define MEM_LIMIT_LOCK(state, locked) do { \
|
||||
if (SCHEDULER_HELD()) { \
|
||||
locked = TRUE; \
|
||||
} else { \
|
||||
SCHEDULER_LOCK(state); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define MEM_LIMIT_UNLOCK(state, locked) do { \
|
||||
if (!locked) { \
|
||||
SCHEDULER_UNLOCK(state); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
UINT32 OsMemLimitCheckAndMemAdd(UINT32 size)
|
||||
{
|
||||
UINT32 intSave;
|
||||
BOOL locked = FALSE;
|
||||
MEM_LIMIT_LOCK(intSave, locked);
|
||||
LosProcessCB *run = OsCurrProcessGet();
|
||||
UINT32 currProcessID = run->processID;
|
||||
if ((run == NULL) || (run->plimits == NULL)) {
|
||||
MEM_LIMIT_UNLOCK(intSave, locked);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
ProcMemLimiter *memLimit = (ProcMemLimiter *)run->plimits->limitsList[PROCESS_LIMITER_ID_MEM];
|
||||
if ((memLimit->usage + size) > memLimit->limit) {
|
||||
memLimit->failcnt++;
|
||||
MEM_LIMIT_UNLOCK(intSave, locked);
|
||||
PRINT_ERR("plimits: process %u adjust the memory limit of Plimits group\n", currProcessID);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
memLimit->usage += size;
|
||||
run->limitStat.memUsed += size;
|
||||
if (memLimit->peak < memLimit->usage) {
|
||||
memLimit->peak = memLimit->usage;
|
||||
}
|
||||
MEM_LIMIT_UNLOCK(intSave, locked);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
VOID OsMemLimitMemFree(UINT32 size)
|
||||
{
|
||||
UINT32 intSave;
|
||||
BOOL locked = FALSE;
|
||||
MEM_LIMIT_LOCK(intSave, locked);
|
||||
LosProcessCB *run = OsCurrProcessGet();
|
||||
if ((run == NULL) || (run->plimits == NULL)) {
|
||||
MEM_LIMIT_UNLOCK(intSave, locked);
|
||||
return;
|
||||
}
|
||||
|
||||
ProcMemLimiter *memLimit = (ProcMemLimiter *)run->plimits->limitsList[PROCESS_LIMITER_ID_MEM];
|
||||
if (run->limitStat.memUsed > size) {
|
||||
run->limitStat.memUsed -= size;
|
||||
memLimit->usage -= size;
|
||||
}
|
||||
MEM_LIMIT_UNLOCK(intSave, locked);
|
||||
}
|
||||
#endif
|
||||
69
kernel/extended/plimit/los_memlimit.h
Normal file
69
kernel/extended/plimit/los_memlimit.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_MEMLIMIT_H
|
||||
#define _LOS_MEMLIMIT_H
|
||||
|
||||
#include "los_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct ProcMemLimiter {
|
||||
UINT64 usage;
|
||||
UINT64 limit;
|
||||
UINT64 peak;
|
||||
UINT32 failcnt;
|
||||
} ProcMemLimiter;
|
||||
|
||||
VOID OsMemLimiterInit(UINTPTR limite);
|
||||
VOID *OsMemLimiterAlloc(VOID);
|
||||
VOID OsMemLimiterFree(UINTPTR limite);
|
||||
VOID OsMemLimiterCopy(UINTPTR dest, UINTPTR src);
|
||||
BOOL MemLimiteMigrateCheck(UINTPTR curr, UINTPTR parent);
|
||||
VOID OsMemLimiterMigrate(UINTPTR currLimit, UINTPTR parentLimit, UINTPTR process);
|
||||
BOOL OsMemLimitAddProcessCheck(UINTPTR limit, UINTPTR process);
|
||||
VOID OsMemLimitAddProcess(UINTPTR limit, UINTPTR process);
|
||||
VOID OsMemLimitDelProcess(UINTPTR limit, UINTPTR process);
|
||||
UINT32 OsMemLimitSetMemLimit(ProcMemLimiter *memLimit, UINT64 value);
|
||||
VOID OsMemLimitSetLimit(UINTPTR limit);
|
||||
UINT32 OsMemLimitCheckAndMemAdd(UINT32 size);
|
||||
VOID OsMemLimitMemFree(UINT32 size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_MEMLIMIT_H */
|
||||
434
kernel/extended/plimit/los_plimits.c
Normal file
434
kernel/extended/plimit/los_plimits.c
Normal file
@@ -0,0 +1,434 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
#include "los_base.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "hal_timer.h"
|
||||
#include "los_plimits.h"
|
||||
|
||||
typedef struct PlimiteOperations {
|
||||
VOID (*LimiterInit)(UINTPTR);
|
||||
VOID *(*LimiterAlloc)(VOID);
|
||||
VOID (*LimiterFree)(UINTPTR);
|
||||
VOID (*LimiterCopy)(UINTPTR, UINTPTR);
|
||||
BOOL (*LimiterAddProcessCheck)(UINTPTR, UINTPTR);
|
||||
VOID (*LimiterAddProcess)(UINTPTR, UINTPTR);
|
||||
VOID (*LimiterDelProcess)(UINTPTR, UINTPTR);
|
||||
BOOL (*LimiterMigrateCheck)(UINTPTR, UINTPTR);
|
||||
VOID (*LimiterMigrate)(UINTPTR, UINTPTR, UINTPTR);
|
||||
} PlimiteOperations;
|
||||
|
||||
static PlimiteOperations g_limiteOps[PROCESS_LIMITER_COUNT] = {
|
||||
[PROCESS_LIMITER_ID_PIDS] = {
|
||||
.LimiterInit = PidLimiterInit,
|
||||
.LimiterAlloc = PidLimiterAlloc,
|
||||
.LimiterFree = PidLimterFree,
|
||||
.LimiterCopy = PidLimiterCopy,
|
||||
.LimiterAddProcessCheck = OsPidLimitAddProcessCheck,
|
||||
.LimiterAddProcess = OsPidLimitAddProcess,
|
||||
.LimiterDelProcess = OsPidLimitDelProcess,
|
||||
.LimiterMigrateCheck = PidLimitMigrateCheck,
|
||||
.LimiterMigrate = NULL,
|
||||
},
|
||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
||||
[PROCESS_LIMITER_ID_MEM] = {
|
||||
.LimiterInit = OsMemLimiterInit,
|
||||
.LimiterAlloc = OsMemLimiterAlloc,
|
||||
.LimiterFree = OsMemLimiterFree,
|
||||
.LimiterCopy = OsMemLimiterCopy,
|
||||
.LimiterAddProcessCheck = OsMemLimitAddProcessCheck,
|
||||
.LimiterAddProcess = OsMemLimitAddProcess,
|
||||
.LimiterDelProcess = OsMemLimitDelProcess,
|
||||
.LimiterMigrateCheck = MemLimiteMigrateCheck,
|
||||
.LimiterMigrate = OsMemLimiterMigrate,
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
[PROCESS_LIMITER_ID_SCHED] = {
|
||||
.LimiterInit = OsSchedLimitInit,
|
||||
.LimiterAlloc = OsSchedLimitAlloc,
|
||||
.LimiterFree = OsSchedLimitFree,
|
||||
.LimiterCopy = OsSchedLimitCopy,
|
||||
.LimiterAddProcessCheck = NULL,
|
||||
.LimiterAddProcess = NULL,
|
||||
.LimiterDelProcess = NULL,
|
||||
.LimiterMigrateCheck = NULL,
|
||||
.LimiterMigrate = NULL,
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
||||
[PROCESS_LIMITER_ID_DEV] = {
|
||||
.LimiterInit = OsDevLimitInit,
|
||||
.LimiterAlloc = OsDevLimitAlloc,
|
||||
.LimiterFree = OsDevLimitFree,
|
||||
.LimiterCopy = OsDevLimitCopy,
|
||||
.LimiterAddProcessCheck = NULL,
|
||||
.LimiterAddProcess = NULL,
|
||||
.LimiterDelProcess = NULL,
|
||||
.LimiterMigrateCheck = NULL,
|
||||
.LimiterMigrate = NULL,
|
||||
},
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
[PROCESS_LIMITER_ID_IPC] = {
|
||||
.LimiterInit = OsIPCLimitInit,
|
||||
.LimiterAlloc = OsIPCLimitAlloc,
|
||||
.LimiterFree = OsIPCLimitFree,
|
||||
.LimiterCopy = OsIPCLimitCopy,
|
||||
.LimiterAddProcessCheck = OsIPCLimitAddProcessCheck,
|
||||
.LimiterAddProcess = OsIPCLimitAddProcess,
|
||||
.LimiterDelProcess = OsIPCLimitDelProcess,
|
||||
.LimiterMigrateCheck = OsIPCLimiteMigrateCheck,
|
||||
.LimiterMigrate = OsIPCLimitMigrate,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
STATIC ProcLimiterSet *g_rootPLimite = NULL;
|
||||
|
||||
ProcLimiterSet *OsRootPLimitsGet(VOID)
|
||||
{
|
||||
return g_rootPLimite;
|
||||
}
|
||||
|
||||
UINT32 OsProcLimiterSetInit(VOID)
|
||||
{
|
||||
g_rootPLimite = (ProcLimiterSet *)LOS_MemAlloc(m_aucSysMem1, sizeof(ProcLimiterSet));
|
||||
if (g_rootPLimite == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
(VOID)memset_s(g_rootPLimite, sizeof(ProcLimiterSet), 0, sizeof(ProcLimiterSet));
|
||||
|
||||
LOS_ListInit(&g_rootPLimite->childList);
|
||||
LOS_ListInit(&g_rootPLimite->processList);
|
||||
|
||||
ProcLimiterSet *procLimiterSet = g_rootPLimite;
|
||||
for (INT32 plimiteID = 0; plimiteID < PROCESS_LIMITER_COUNT; ++plimiteID) {
|
||||
procLimiterSet->limitsList[plimiteID] = (UINTPTR)g_limiteOps[plimiteID].LimiterAlloc();
|
||||
if (procLimiterSet->limitsList[plimiteID] == (UINTPTR)NULL) {
|
||||
OsPLimitsFree(procLimiterSet);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (g_limiteOps[plimiteID].LimiterInit != NULL) {
|
||||
g_limiteOps[plimiteID].LimiterInit(procLimiterSet->limitsList[plimiteID]);
|
||||
}
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID PLimitsDeleteProcess(LosProcessCB *processCB)
|
||||
{
|
||||
if ((processCB == NULL) || (processCB->plimits == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProcLimiterSet *plimits = processCB->plimits;
|
||||
for (UINT32 limitsID = 0; limitsID < PROCESS_LIMITER_COUNT; limitsID++) {
|
||||
if (g_limiteOps[limitsID].LimiterDelProcess == NULL) {
|
||||
continue;
|
||||
}
|
||||
g_limiteOps[limitsID].LimiterDelProcess(plimits->limitsList[limitsID], (UINTPTR)processCB);
|
||||
}
|
||||
plimits->pidCount--;
|
||||
LOS_ListDelete(&processCB->plimitsList);
|
||||
processCB->plimits = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC UINT32 PLimitsAddProcess(ProcLimiterSet *plimits, LosProcessCB *processCB)
|
||||
{
|
||||
UINT32 limitsID;
|
||||
if (plimits == NULL) {
|
||||
plimits = g_rootPLimite;
|
||||
}
|
||||
|
||||
if (processCB->plimits == g_rootPLimite) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
if (processCB->plimits == plimits) {
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
for (limitsID = 0; limitsID < PROCESS_LIMITER_COUNT; limitsID++) {
|
||||
if (g_limiteOps[limitsID].LimiterAddProcessCheck == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!g_limiteOps[limitsID].LimiterAddProcessCheck(plimits->limitsList[limitsID], (UINTPTR)processCB)) {
|
||||
return EACCES;
|
||||
}
|
||||
}
|
||||
|
||||
PLimitsDeleteProcess(processCB);
|
||||
|
||||
for (limitsID = 0; limitsID < PROCESS_LIMITER_COUNT; limitsID++) {
|
||||
if (g_limiteOps[limitsID].LimiterAddProcess == NULL) {
|
||||
continue;
|
||||
}
|
||||
g_limiteOps[limitsID].LimiterAddProcess(plimits->limitsList[limitsID], (UINTPTR)processCB);
|
||||
}
|
||||
|
||||
LOS_ListTailInsert(&plimits->processList, &processCB->plimitsList);
|
||||
plimits->pidCount++;
|
||||
processCB->plimits = plimits;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 OsPLimitsAddProcess(ProcLimiterSet *plimits, LosProcessCB *processCB)
|
||||
{
|
||||
UINT32 intSave;
|
||||
SCHEDULER_LOCK(intSave);
|
||||
UINT32 ret = PLimitsAddProcess(plimits, processCB);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return ret;
|
||||
}
|
||||
|
||||
UINT32 OsPLimitsAddPid(ProcLimiterSet *plimits, UINT32 pid)
|
||||
{
|
||||
UINT32 intSave, ret;
|
||||
if ((plimits == NULL) || OS_PID_CHECK_INVALID(pid) || (pid == 0)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (plimits == g_rootPLimite) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID((unsigned int)pid);
|
||||
if (OsProcessIsInactive(processCB)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
ret = PLimitsAddProcess(plimits, processCB);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return ret;
|
||||
}
|
||||
|
||||
VOID OsPLimitsDeleteProcess(LosProcessCB *processCB)
|
||||
{
|
||||
UINT32 intSave;
|
||||
SCHEDULER_LOCK(intSave);
|
||||
PLimitsDeleteProcess(processCB);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
}
|
||||
|
||||
UINT32 OsPLimitsPidsGet(const ProcLimiterSet *plimits, UINT32 *pids, UINT32 size)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosProcessCB *processCB = NULL;
|
||||
UINT32 minSize = LOS_GetSystemProcessMaximum() * sizeof(UINT32);
|
||||
if ((plimits == NULL) || (pids == NULL) || (size < minSize)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LOS_DL_LIST *listHead = (LOS_DL_LIST *)&plimits->processList;
|
||||
if (LOS_ListEmpty(listHead)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(processCB, listHead, LosProcessCB, plimitsList) {
|
||||
pids[OsGetPid(processCB)] = 1;
|
||||
}
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID PLimitsProcessMerge(ProcLimiterSet *currPLimits, ProcLimiterSet *parentPLimits)
|
||||
{
|
||||
LOS_DL_LIST *head = &currPLimits->processList;
|
||||
while (!LOS_ListEmpty(head)) {
|
||||
LosProcessCB *processCB = LOS_DL_LIST_ENTRY(head->pstNext, LosProcessCB, plimitsList);
|
||||
PLimitsDeleteProcess(processCB);
|
||||
PLimitsAddProcess(parentPLimits, processCB);
|
||||
}
|
||||
LOS_ListDelete(&currPLimits->childList);
|
||||
currPLimits->parent = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC UINT32 PLimitsMigrateCheck(ProcLimiterSet *currPLimits, ProcLimiterSet *parentPLimits)
|
||||
{
|
||||
for (UINT32 limiteID = 0; limiteID < PROCESS_LIMITER_COUNT; limiteID++) {
|
||||
UINTPTR currLimit = currPLimits->limitsList[limiteID];
|
||||
UINTPTR parentLimit = parentPLimits->limitsList[limiteID];
|
||||
if (g_limiteOps[limiteID].LimiterMigrateCheck == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!g_limiteOps[limiteID].LimiterMigrateCheck(currLimit, parentLimit)) {
|
||||
return EPERM;
|
||||
}
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 OsPLimitsFree(ProcLimiterSet *currPLimits)
|
||||
{
|
||||
UINT32 intSave, ret;
|
||||
if (currPLimits == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
ProcLimiterSet *parentPLimits = currPLimits->parent;
|
||||
ret = PLimitsMigrateCheck(currPLimits, parentPLimits);
|
||||
if (ret != LOS_OK) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return ret;
|
||||
}
|
||||
|
||||
PLimitsProcessMerge(currPLimits, parentPLimits);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
for (INT32 limiteID = 0; limiteID < PROCESS_LIMITER_COUNT; ++limiteID) {
|
||||
UINTPTR procLimiter = currPLimits->limitsList[limiteID];
|
||||
if (g_limiteOps[limiteID].LimiterFree != NULL) {
|
||||
g_limiteOps[limiteID].LimiterFree(procLimiter);
|
||||
}
|
||||
}
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, currPLimits);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
ProcLimiterSet *OsPLimitsCreate(ProcLimiterSet *parentPLimits)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
ProcLimiterSet *newPLimits = (ProcLimiterSet *)LOS_MemAlloc(m_aucSysMem1, sizeof(ProcLimiterSet));
|
||||
if (newPLimits == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
(VOID)memset_s(newPLimits, sizeof(ProcLimiterSet), 0, sizeof(ProcLimiterSet));
|
||||
LOS_ListInit(&newPLimits->childList);
|
||||
LOS_ListInit(&newPLimits->processList);
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
newPLimits->parent = parentPLimits;
|
||||
newPLimits->level = parentPLimits->level + 1;
|
||||
newPLimits->mask = parentPLimits->mask;
|
||||
|
||||
for (INT32 plimiteID = 0; plimiteID < PROCESS_LIMITER_COUNT; ++plimiteID) {
|
||||
newPLimits->limitsList[plimiteID] = (UINTPTR)g_limiteOps[plimiteID].LimiterAlloc();
|
||||
if (newPLimits->limitsList[plimiteID] == (UINTPTR)NULL) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
OsPLimitsFree(newPLimits);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (g_limiteOps[plimiteID].LimiterCopy != NULL) {
|
||||
g_limiteOps[plimiteID].LimiterCopy(newPLimits->limitsList[plimiteID],
|
||||
parentPLimits->limitsList[plimiteID]);
|
||||
}
|
||||
}
|
||||
LOS_ListTailInsert(&g_rootPLimite->childList, &newPLimits->childList);
|
||||
|
||||
(VOID)PLimitsDeleteProcess(OsCurrProcessGet());
|
||||
(VOID)PLimitsAddProcess(newPLimits, OsCurrProcessGet());
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return newPLimits;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
||||
UINT32 OsPLimitsMemUsageGet(ProcLimiterSet *plimits, UINT64 *usage, UINT32 size)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosProcessCB *processCB = NULL;
|
||||
UINT32 minSize = LOS_GetSystemProcessMaximum() * sizeof(UINT64) + sizeof(ProcMemLimiter);
|
||||
ProcMemLimiter *memLimit = (ProcMemLimiter *)usage;
|
||||
UINT64 *memSuage = (UINT64 *)((UINTPTR)usage + sizeof(ProcMemLimiter));
|
||||
if ((plimits == NULL) || (usage == NULL) || (size < minSize)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
(VOID)memcpy_s(memLimit, sizeof(ProcMemLimiter),
|
||||
(VOID *)plimits->limitsList[PROCESS_LIMITER_ID_MEM], sizeof(ProcMemLimiter));
|
||||
LOS_DL_LIST *listHead = (LOS_DL_LIST *)&plimits->processList;
|
||||
if (LOS_ListEmpty(listHead)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(processCB, listHead, LosProcessCB, plimitsList) {
|
||||
memSuage[OsGetPid(processCB)] = processCB->limitStat.memUsed;
|
||||
}
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
UINT32 OsPLimitsIPCStatGet(ProcLimiterSet *plimits, ProcIPCLimit *ipc, UINT32 size)
|
||||
{
|
||||
UINT32 intSave;
|
||||
if ((plimits == NULL) || (ipc == NULL) || (size != sizeof(ProcIPCLimit))) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
(VOID)memcpy_s(ipc, sizeof(ProcIPCLimit),
|
||||
(VOID *)plimits->limitsList[PROCESS_LIMITER_ID_IPC], sizeof(ProcIPCLimit));
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
UINT32 OsPLimitsSchedUsageGet(ProcLimiterSet *plimits, UINT64 *usage, UINT32 size)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LosProcessCB *processCB = NULL;
|
||||
UINT32 minSize = LOS_GetSystemProcessMaximum() * sizeof(UINT64);
|
||||
if ((plimits == NULL) || (usage == NULL) || (size < minSize)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LOS_DL_LIST *listHead = (LOS_DL_LIST *)&plimits->processList;
|
||||
if (LOS_ListEmpty(listHead)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(processCB, listHead, LosProcessCB, plimitsList) {
|
||||
usage[OsGetPid(processCB)] = processCB->limitStat.allRuntime;
|
||||
}
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
114
kernel/extended/plimit/los_plimits.h
Normal file
114
kernel/extended/plimit/los_plimits.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_PLIMITS_H
|
||||
#define _LOS_PLIMITS_H
|
||||
|
||||
#include "los_list.h"
|
||||
#include "los_typedef.h"
|
||||
#include "los_processlimit.h"
|
||||
#include "los_memlimit.h"
|
||||
#include "los_ipclimit.h"
|
||||
#include "los_devicelimit.h"
|
||||
#include "los_schedlimit.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* proc limit set lock */
|
||||
#define PLIMITS_MIN_PERIOD_IN_US 1000000
|
||||
#define PLIMITS_MIN_QUOTA_IN_US 1
|
||||
#define PLIMITS_DELETE_WAIT_TIME 1000
|
||||
typedef struct ProcessCB LosProcessCB;
|
||||
|
||||
enum ProcLimiterID {
|
||||
PROCESS_LIMITER_ID_PIDS = 0,
|
||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
||||
PROCESS_LIMITER_ID_MEM,
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
PROCESS_LIMITER_ID_SCHED,
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_DEV_PLIMIT
|
||||
PROCESS_LIMITER_ID_DEV,
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
PROCESS_LIMITER_ID_IPC,
|
||||
#endif
|
||||
PROCESS_LIMITER_COUNT,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
#ifdef LOSCFG_KERNEL_MEM_PLIMIT
|
||||
UINT64 memUsed;
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
|
||||
UINT32 mqCount;
|
||||
UINT32 shmSize;
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
UINT64 allRuntime;
|
||||
#endif
|
||||
} PLimitsData;
|
||||
|
||||
typedef struct TagPLimiterSet {
|
||||
struct TagPLimiterSet *parent; /* plimite parent */
|
||||
LOS_DL_LIST childList; /* plimite childList */
|
||||
LOS_DL_LIST processList;
|
||||
UINT32 pidCount;
|
||||
UINTPTR limitsList[PROCESS_LIMITER_COUNT]; /* plimite list */
|
||||
UINT32 mask; /* each bit indicates that a limite exists */
|
||||
UINT8 level; /* plimits hierarchy level */
|
||||
} ProcLimiterSet;
|
||||
|
||||
typedef struct ProcessCB LosProcessCB;
|
||||
ProcLimiterSet *OsRootPLimitsGet(VOID);
|
||||
UINT32 OsPLimitsAddProcess(ProcLimiterSet *plimits, LosProcessCB *processCB);
|
||||
UINT32 OsPLimitsAddPid(ProcLimiterSet *plimits, UINT32 pid);
|
||||
VOID OsPLimitsDeleteProcess(LosProcessCB *processCB);
|
||||
UINT32 OsPLimitsPidsGet(const ProcLimiterSet *plimits, UINT32 *pids, UINT32 size);
|
||||
UINT32 OsPLimitsFree(ProcLimiterSet *currPLimits);
|
||||
ProcLimiterSet *OsPLimitsCreate(ProcLimiterSet *parentProcLimiterSet);
|
||||
UINT32 OsProcLimiterSetInit(VOID);
|
||||
|
||||
UINT32 OsPLimitsMemUsageGet(ProcLimiterSet *plimits, UINT64 *usage, UINT32 size);
|
||||
UINT32 OsPLimitsIPCStatGet(ProcLimiterSet *plimits, ProcIPCLimit *ipc, UINT32 size);
|
||||
UINT32 OsPLimitsSchedUsageGet(ProcLimiterSet *plimits, UINT64 *usage, UINT32 size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_PLIMITS_H */
|
||||
182
kernel/extended/plimit/los_processlimit.c
Normal file
182
kernel/extended/plimit/los_processlimit.c
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PLIMITS
|
||||
#include "los_config.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "los_process.h"
|
||||
#include "los_plimits.h"
|
||||
#include "los_task_pri.h"
|
||||
#include "los_processlimit.h"
|
||||
|
||||
STATIC PidLimit *g_rootPidLimit = NULL;
|
||||
|
||||
VOID PidLimiterInit(UINTPTR limit)
|
||||
{
|
||||
PidLimit *pidLimit = (PidLimit *)limit;
|
||||
if (pidLimit == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
pidLimit->pidLimit = LOS_GetSystemProcessMaximum();
|
||||
pidLimit->priorityLimit = OS_USER_PROCESS_PRIORITY_HIGHEST;
|
||||
g_rootPidLimit = pidLimit;
|
||||
}
|
||||
|
||||
VOID *PidLimiterAlloc(VOID)
|
||||
{
|
||||
PidLimit *plimite = (PidLimit *)LOS_MemAlloc(m_aucSysMem1, sizeof(PidLimit));
|
||||
if (plimite == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
(VOID)memset_s(plimite, sizeof(PidLimit), 0, sizeof(PidLimit));
|
||||
return (VOID *)plimite;
|
||||
}
|
||||
|
||||
VOID PidLimterFree(UINTPTR limit)
|
||||
{
|
||||
PidLimit *pidLimit = (PidLimit *)limit;
|
||||
if (pidLimit == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, (VOID *)limit);
|
||||
}
|
||||
|
||||
BOOL PidLimitMigrateCheck(UINTPTR curr, UINTPTR parent)
|
||||
{
|
||||
PidLimit *currPidLimit = (PidLimit *)curr;
|
||||
PidLimit *parentPidLimit = (PidLimit *)parent;
|
||||
if ((currPidLimit == NULL) || (parentPidLimit == NULL)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((currPidLimit->pidCount + parentPidLimit->pidCount) >= parentPidLimit->pidLimit) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL OsPidLimitAddProcessCheck(UINTPTR limit, UINTPTR process)
|
||||
{
|
||||
(VOID)process;
|
||||
PidLimit *pidLimit = (PidLimit *)limit;
|
||||
if (pidLimit->pidCount >= pidLimit->pidLimit) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID OsPidLimitAddProcess(UINTPTR limit, UINTPTR process)
|
||||
{
|
||||
(VOID)process;
|
||||
PidLimit *plimits = (PidLimit *)limit;
|
||||
|
||||
plimits->pidCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
VOID OsPidLimitDelProcess(UINTPTR limit, UINTPTR process)
|
||||
{
|
||||
(VOID)process;
|
||||
PidLimit *plimits = (PidLimit *)limit;
|
||||
|
||||
plimits->pidCount--;
|
||||
return;
|
||||
}
|
||||
|
||||
VOID PidLimiterCopy(UINTPTR curr, UINTPTR parent)
|
||||
{
|
||||
PidLimit *currPidLimit = (PidLimit *)curr;
|
||||
PidLimit *parentPidLimit = (PidLimit *)parent;
|
||||
if ((currPidLimit == NULL) || (parentPidLimit == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
currPidLimit->pidLimit = parentPidLimit->pidLimit;
|
||||
currPidLimit->priorityLimit = parentPidLimit->priorityLimit;
|
||||
currPidLimit->pidCount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
UINT32 PidLimitSetPidLimit(PidLimit *pidLimit, UINT32 pidMax)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
if ((pidLimit == NULL) || (pidMax > LOS_GetSystemProcessMaximum())) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (pidLimit == g_rootPidLimit) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (pidLimit->pidCount >= pidMax) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
pidLimit->pidLimit = pidMax;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 PidLimitSetPriorityLimit(PidLimit *pidLimit, UINT32 priority)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
if ((pidLimit == NULL) ||
|
||||
(priority < OS_USER_PROCESS_PRIORITY_HIGHEST) ||
|
||||
(priority > OS_PROCESS_PRIORITY_LOWEST)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (pidLimit == g_rootPidLimit) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
pidLimit->priorityLimit = priority;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT16 OsPidLimitGetPriorityLimit(VOID)
|
||||
{
|
||||
UINT32 intSave;
|
||||
SCHEDULER_LOCK(intSave);
|
||||
LosProcessCB *run = OsCurrProcessGet();
|
||||
PidLimit *pidLimit = (PidLimit *)run->plimits->limitsList[PROCESS_LIMITER_ID_PIDS];
|
||||
UINT16 priority = pidLimit->priorityLimit;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return priority;
|
||||
}
|
||||
#endif
|
||||
67
kernel/extended/plimit/los_processlimit.h
Normal file
67
kernel/extended/plimit/los_processlimit.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_PROCESSLIMIT_H
|
||||
#define _LOS_PROCESSLIMIT_H
|
||||
|
||||
#include "los_list.h"
|
||||
#include "los_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct PidLimit {
|
||||
UINT32 pidLimit;
|
||||
UINT32 priorityLimit;
|
||||
UINT32 pidCount;
|
||||
} PidLimit;
|
||||
|
||||
VOID PidLimiterInit(UINTPTR limit);
|
||||
VOID *PidLimiterAlloc(VOID);
|
||||
VOID PidLimterFree(UINTPTR limit);
|
||||
VOID PidLimiterCopy(UINTPTR curr, UINTPTR parent);
|
||||
BOOL PidLimitMigrateCheck(UINTPTR curr, UINTPTR parent);
|
||||
BOOL OsPidLimitAddProcessCheck(UINTPTR limit, UINTPTR process);
|
||||
VOID OsPidLimitAddProcess(UINTPTR limit, UINTPTR process);
|
||||
VOID OsPidLimitDelProcess(UINTPTR limit, UINTPTR process);
|
||||
UINT32 PidLimitSetPidLimit(PidLimit *pidLimit, UINT32 pidMax);
|
||||
UINT32 PidLimitSetPriorityLimit(PidLimit *pidLimit, UINT32 priority);
|
||||
UINT16 OsPidLimitGetPriorityLimit(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
151
kernel/extended/plimit/los_schedlimit.c
Normal file
151
kernel/extended/plimit/los_schedlimit.c
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SCHED_PLIMIT
|
||||
#include "los_schedlimit.h"
|
||||
#include "los_process_pri.h"
|
||||
|
||||
STATIC ProcSchedLimiter *g_procSchedLimit = NULL;
|
||||
|
||||
VOID OsSchedLimitInit(UINTPTR limit)
|
||||
{
|
||||
ProcSchedLimiter *schedLimit = (ProcSchedLimiter *)limit;
|
||||
schedLimit->period = 0;
|
||||
schedLimit->quota = 0;
|
||||
g_procSchedLimit = schedLimit;
|
||||
}
|
||||
|
||||
VOID *OsSchedLimitAlloc(VOID)
|
||||
{
|
||||
ProcSchedLimiter *plimit = (ProcSchedLimiter *)LOS_MemAlloc(m_aucSysMem1, sizeof(ProcSchedLimiter));
|
||||
if (plimit == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
(VOID)memset_s(plimit, sizeof(ProcSchedLimiter), 0, sizeof(ProcSchedLimiter));
|
||||
return (VOID *)plimit;
|
||||
}
|
||||
|
||||
VOID OsSchedLimitFree(UINTPTR limit)
|
||||
{
|
||||
ProcSchedLimiter *schedLimit = (ProcSchedLimiter *)limit;
|
||||
if (schedLimit == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, (VOID *)limit);
|
||||
}
|
||||
|
||||
VOID OsSchedLimitCopy(UINTPTR dest, UINTPTR src)
|
||||
{
|
||||
ProcSchedLimiter *plimitDest = (ProcSchedLimiter *)dest;
|
||||
ProcSchedLimiter *plimitSrc = (ProcSchedLimiter *)src;
|
||||
plimitDest->period = plimitSrc->period;
|
||||
plimitDest->quota = plimitSrc->quota;
|
||||
return;
|
||||
}
|
||||
|
||||
VOID OsSchedLimitUpdateRuntime(LosTaskCB *runTask, UINT64 currTime, INT32 incTime)
|
||||
{
|
||||
LosProcessCB *run = (LosProcessCB *)runTask->processCB;
|
||||
if ((run == NULL) || (run->plimits == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProcSchedLimiter *schedLimit = (ProcSchedLimiter *)run->plimits->limitsList[PROCESS_LIMITER_ID_SCHED];
|
||||
|
||||
run->limitStat.allRuntime += incTime;
|
||||
if ((schedLimit->period <= 0) || (schedLimit->quota <= 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((schedLimit->startTime <= currTime) && (schedLimit->allRuntime < schedLimit->quota)) {
|
||||
schedLimit->allRuntime += incTime;
|
||||
return;
|
||||
}
|
||||
|
||||
if (schedLimit->startTime <= currTime) {
|
||||
schedLimit->startTime = currTime + schedLimit->period;
|
||||
schedLimit->allRuntime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL OsSchedLimitCheckTime(LosTaskCB *task)
|
||||
{
|
||||
UINT64 currTime = OsGetCurrSchedTimeCycle();
|
||||
LosProcessCB *processCB = (LosProcessCB *)task->processCB;
|
||||
if ((processCB == NULL) || (processCB->plimits == NULL)) {
|
||||
return TRUE;
|
||||
}
|
||||
ProcSchedLimiter *schedLimit = (ProcSchedLimiter *)processCB->plimits->limitsList[PROCESS_LIMITER_ID_SCHED];
|
||||
if (schedLimit->startTime >= currTime) {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
UINT32 OsSchedLimitSetPeriod(ProcSchedLimiter *schedLimit, UINT64 value)
|
||||
{
|
||||
UINT32 intSave;
|
||||
if (schedLimit == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (schedLimit == g_procSchedLimit) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
schedLimit->period = value;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 OsSchedLimitSetQuota(ProcSchedLimiter *schedLimit, UINT64 value)
|
||||
{
|
||||
UINT32 intSave;
|
||||
if (schedLimit == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (schedLimit == g_procSchedLimit) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (value > (UINT64)schedLimit->period) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
schedLimit->quota = value;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
#endif
|
||||
68
kernel/extended/plimit/los_schedlimit.h
Normal file
68
kernel/extended/plimit/los_schedlimit.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOS_SCHEDLIMIT_H
|
||||
#define _LOS_SCHEDLIMIT_H
|
||||
|
||||
#include "los_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define CORE_US_PER_SECOND (1000 * 1000) /* 1000 * 1000 us per second */
|
||||
typedef struct TagTaskCB LosTaskCB;
|
||||
|
||||
typedef struct ProcSchedLimiter {
|
||||
UINT64 startTime;
|
||||
UINT64 endTime;
|
||||
UINT64 period;
|
||||
UINT64 quota;
|
||||
UINT64 allRuntime;
|
||||
} ProcSchedLimiter;
|
||||
|
||||
VOID OsSchedLimitInit(UINTPTR limit);
|
||||
VOID *OsSchedLimitAlloc(VOID);
|
||||
VOID OsSchedLimitFree(UINTPTR limit);
|
||||
VOID OsSchedLimitCopy(UINTPTR dest, UINTPTR src);
|
||||
VOID OsSchedLimitUpdateRuntime(LosTaskCB *runTask, UINT64 currTime, INT32 incTime);
|
||||
UINT32 OsSchedLimitSetPeriod(ProcSchedLimiter *schedLimit, UINT64 value);
|
||||
UINT32 OsSchedLimitSetQuota(ProcSchedLimiter *schedLimit, UINT64 value);
|
||||
BOOL OsSchedLimitCheckTime(LosTaskCB *task);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_SCHEDLIMIT_H */
|
||||
@@ -47,13 +47,13 @@
|
||||
|
||||
extern INT32 LOS_Fork(UINT32 flags, const CHAR *name, const TSK_ENTRY_FUNC entry, UINT32 stackSize);
|
||||
|
||||
extern INT32 LOS_SetProcessPriority(INT32 pid, UINT16 prio);
|
||||
extern INT32 LOS_SetProcessPriority(INT32 pid, INT32 prio);
|
||||
|
||||
extern INT32 LOS_GetProcessPriority(INT32 pid);
|
||||
|
||||
extern INT32 LOS_GetProcessScheduler(INT32 pid);
|
||||
extern INT32 LOS_GetProcessScheduler(INT32 pid, INT32 *policy, LosSchedParam *schedParam);
|
||||
|
||||
extern INT32 LOS_SetProcessScheduler(INT32 pid, UINT16 policy, UINT16 prio);
|
||||
extern INT32 LOS_SetProcessScheduler(INT32 pid, UINT16 policy, const LosSchedParam *schedParam);
|
||||
|
||||
extern UINT32 LOS_GetCurrProcessID(VOID);
|
||||
|
||||
|
||||
@@ -514,8 +514,21 @@ typedef struct tagTskInitParam {
|
||||
UINT16 consoleID; /**< The console id of task belongs */
|
||||
UINTPTR processID;
|
||||
UserTaskParam userParam;
|
||||
/* edf parameters */
|
||||
UINT32 runTimeUs;
|
||||
UINT64 deadlineUs;
|
||||
UINT64 periodUs;
|
||||
} TSK_INIT_PARAM_S;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
INT32 priority;
|
||||
INT32 runTimeUs;
|
||||
};
|
||||
INT32 deadlineUs;
|
||||
INT32 periodUs;
|
||||
} LosSchedParam;
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Task name length
|
||||
|
||||
@@ -28,11 +28,8 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
MUSLDIR = "$LITEOSTHIRDPARTY/musl"
|
||||
|
||||
import("//third_party/optimized-routines/optimized-routines.gni")
|
||||
import("$MUSLDIR/porting/liteos_a/kernel/musl.gni")
|
||||
import("$THIRDPARTY_MUSL_DIR/porting/liteos_a/kernel/musl.gni")
|
||||
import("$THIRDPARTY_OPTIMIZED_ROUTINES_DIR/optimized-routines.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_LIBC_MUSL)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
|
||||
@@ -64,5 +64,6 @@ else
|
||||
LOCAL_FLAGS += -frounding-math -Wno-unused-but-set-variable
|
||||
endif
|
||||
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-logical-op-parentheses -Wno-bitwise-op-parentheses -Wno-unknown-pragmas
|
||||
LOCAL_FLAGS += -Wno-unused-but-set-variable
|
||||
|
||||
include $(MODULE)
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/musl/porting/liteos_a_newlib/kernel/newlib.gni")
|
||||
import("$THIRDPARTY_MUSL_DIR/porting/liteos_a_newlib/kernel/newlib.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_LIBC_NEWLIB)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user