Skip to content

Commit c6a2b8e

Browse files
author
cyh21
committed
2025-3-20v2
1 parent d4a63a6 commit c6a2b8e

2 files changed

Lines changed: 70 additions & 27 deletions

File tree

docs/日报/2025-3-17.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub fn sys_prlimit64(
3434
) -> LinuxResult<isize> {
3535
// 检查资源类型是否有效
3636
// let curr_process = current().task_ext_mut();
37+
info!("sys_prlimit64 pid: {}, resource: {}", pid, resource);
3738
let curr_process = current();
3839
let task_ext = curr_process.task_ext();
3940
if pid == 0 || pid == task_ext.proc_id as i32 {
@@ -46,26 +47,36 @@ pub fn sys_prlimit64(
4647
// Ok(0)
4748
// }
4849
RLIMIT_STACK => {
49-
let new_limit = new_limit.get()?;
50-
let old_limit = old_limit.get()?;
50+
info!("RLIMIT_STACK");
51+
// let new_limit = new_limit.get()?;
52+
let old_limit_ptr = old_limit.address().as_ptr();
53+
54+
info!("111");
55+
let new_limit_ptr = new_limit.address().as_ptr();
56+
info!("222");
5157
// let old_limit = curr_process.task_ext().set_rlimit(RLIMIT_STACK, new_limit, old_limit);
5258
// Ok(0)
5359
// let mut stack_limit = curr_process
5460
let mut stack_limit: u64 = task_ext.get_stack_size();
55-
if old_limit as usize != 0 {
61+
if old_limit_ptr as usize != 0 {
62+
info!("RLIMIT_STACK: old_limit as usize != 0");
63+
let old_limit = old_limit_ptr as *mut RLimit;
5664
unsafe {
5765
*old_limit = RLimit {
5866
rlim_cur: stack_limit,
5967
rlim_max: stack_limit,
6068
};
6169
}
6270
}
63-
if new_limit as usize != 0 {
71+
if new_limit_ptr as usize != 0 {
72+
info!("RLIMIT_STACK: new_limit as usize != 0");
73+
let new_limit = new_limit_ptr as *const RLimit;
6474
stack_limit = unsafe {
6575
(*new_limit).rlim_cur
6676
};
6777
task_ext.set_stack_size(stack_limit);
6878
}
79+
info!("RLIMIT_STACK: {}", stack_limit);
6980
}
7081
// RLIMIT_NOFILE => {
7182
// let new_limit = new_limit.get()?;
@@ -77,6 +88,7 @@ pub fn sys_prlimit64(
7788
_=> { }
7889
}
7990
} else {
91+
info!("sys_prlimit64 pid: {}, resource: {}", pid, resource);
8092
return Err(LinuxError::EINVAL);
8193
}
8294

docs/日报/2025-3-20.md

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,59 @@
1010
- starry-next下执行sudo ./build_img.sh -a x86_64 -fs ext4 -file apps/tests/build/ -s 30
1111
- make AX_TESTCASE=tests ARCH=riscv64 EXTRA_CONFIG=../configs/riscv64.toml BLK=y NET=y SMP=4 FEATURES=fp_simd,lwext4_rs LOG=info run
1212

13-
## 测试结果(失败,正在调试)
13+
## 测试结果(可以设置soft的大小)
1414
```shell
15-
[ 6.203695 0:10 starry::syscall_imp:57] Syscall set_tid_address
16-
[ 6.233718 0:10 starry::syscall_imp:170] Syscall set_tid_address return 10
17-
[ 6.244388 0:10 starry::syscall_imp:57] Syscall getpid
18-
[ 6.250047 0:10 starry::syscall_imp:170] Syscall getpid return 10
19-
[ 6.256574 0:10 starry::syscall_imp:57] Syscall prlimit64
20-
[ 6.266883 0:10 starry::syscall_imp::task::thread:213] sys_prlimit64 => Err(EFAULT)
21-
[ 6.277822 0:10 starry::syscall_imp:170] Syscall prlimit64 return -14
22-
[ 6.288521 0:10 starry::syscall_imp:57] Syscall writev
23-
prlimit64 get stack limit failed[ 6.318049 0:10 starry::syscall_imp:170] Syscall writev return 32
24-
[ 6.326058 0:10 starry::syscall_imp:57] Syscall writev
25-
:[ 6.330115 0:10 starry::syscall_imp:170] Syscall writev return 1
26-
[ 6.335907 0:10 starry::syscall_imp:57] Syscall writev
27-
[ 6.340294 0:10 starry::syscall_imp:170] Syscall writev return 1
28-
[ 6.347025 0:10 starry::syscall_imp:57] Syscall writev
29-
Bad address[ 6.352396 0:10 starry::syscall_imp:170] Syscall writev return 11
30-
[ 6.358162 0:10 starry::syscall_imp:57] Syscall writev
15+
[ 5.705789 0:10 starry::task:244] Enter user space: entry=0x40015b6, ustack=0x3fffffeb0, kstack=VA:0xffffffc080bcf050
16+
[ 5.740558 0:10 starry::syscall_imp:57] Syscall set_tid_address
17+
[ 5.769359 0:10 starry::syscall_imp:170] Syscall set_tid_address return 10
18+
[ 5.777429 0:10 starry::syscall_imp:57] Syscall getpid
19+
[ 5.781931 0:10 starry::syscall_imp:170] Syscall getpid return 10
20+
[ 5.787727 0:10 starry::syscall_imp:57] Syscall prlimit64
21+
[ 5.792707 0:10 starry::syscall_imp::task::thread:222] sys_prlimit64 pid: 10, resource: 3
22+
[ 5.801293 0:10 starry::syscall_imp::task::thread:235] RLIMIT_STACK
23+
[ 5.805986 0:10 starry::syscall_imp::task::thread:239] 111
24+
[ 5.811259 0:10 starry::syscall_imp::task::thread:241] 222
25+
[ 5.818334 0:10 starry::syscall_imp::task::thread:247] RLIMIT_STACK: old_limit as usize != 0
26+
[ 5.824086 0:10 starry::syscall_imp::task::thread:264] RLIMIT_STACK: 65536
27+
[ 5.831362 0:10 starry::syscall_imp:170] Syscall prlimit64 return 0
28+
[ 5.851718 0:10 starry::syscall_imp:57] Syscall ioctl
29+
[ 5.855015 0:10 starry::syscall_imp::fs::ctl:23] Unimplemented syscall: SYS_IOCTL
30+
[ 5.860316 0:10 starry::syscall_imp:170] Syscall ioctl return 0
31+
[ 5.864975 0:10 starry::syscall_imp:57] Syscall writev
32+
Current STACK limits: soft=65536, hard=65536
33+
[ 5.893069 0:10 starry::syscall_imp:170] Syscall writev return 45
34+
[ 5.900102 0:10 starry::syscall_imp:57] Syscall getpid
35+
[ 5.903449 0:10 starry::syscall_imp:170] Syscall getpid return 10
36+
[ 5.908279 0:10 starry::syscall_imp:57] Syscall prlimit64
37+
[ 5.912626 0:10 starry::syscall_imp::task::thread:222] sys_prlimit64 pid: 10, resource: 3
38+
[ 5.919415 0:10 starry::syscall_imp::task::thread:235] RLIMIT_STACK
39+
[ 5.923416 0:10 starry::syscall_imp::task::thread:239] 111
40+
[ 5.927788 0:10 starry::syscall_imp::task::thread:241] 222
41+
[ 5.933363 0:10 starry::syscall_imp::task::thread:257] RLIMIT_STACK: new_limit as usize != 0
42+
[ 5.939179 0:10 starry::syscall_imp::task::thread:264] RLIMIT_STACK: 8388608
43+
[ 5.943653 0:10 starry::syscall_imp:170] Syscall prlimit64 return 0
44+
[ 5.949309 0:10 starry::syscall_imp:57] Syscall writev
45+
Set new STACK limits: soft=8388608, hard=16777216
46+
[ 5.955466 0:10 starry::syscall_imp:170] Syscall writev return 50
47+
[ 5.960372 0:10 starry::syscall_imp:57] Syscall getpid
48+
[ 5.963915 0:10 starry::syscall_imp:170] Syscall getpid return 10
49+
[ 5.969356 0:10 starry::syscall_imp:57] Syscall prlimit64
50+
[ 5.973010 0:10 starry::syscall_imp::task::thread:222] sys_prlimit64 pid: 10, resource: 3
51+
[ 5.978666 0:10 starry::syscall_imp::task::thread:235] RLIMIT_STACK
52+
[ 5.983168 0:10 starry::syscall_imp::task::thread:239] 111
53+
[ 5.988364 0:10 starry::syscall_imp::task::thread:241] 222
54+
[ 5.992334 0:10 starry::syscall_imp::task::thread:247] RLIMIT_STACK: old_limit as usize != 0
55+
[ 5.998899 0:10 starry::syscall_imp::task::thread:264] RLIMIT_STACK: 8388608
56+
[ 6.004507 0:10 starry::syscall_imp:170] Syscall prlimit64 return 0
57+
[ 6.010477 0:10 starry::syscall_imp:57] Syscall writev
58+
New STACK limits: soft=8388608, hard=8388608
59+
[ 6.016266 0:10 starry::syscall_imp:170] Syscall writev return 45
60+
[ 6.024514 0:10 starry::syscall_imp:57] Syscall exit_group
61+
[ 6.030226 0:10 starry::syscall_imp::task::thread:62] Temporarily replace sys_exit_group with sys_exit
62+
[ 6.054137 1:2 starry:59] User task /prlimit64 exited with code: Some(0)
63+
[ 6.073207 1:2 axhal::platform::riscv64_qemu_virt::misc:3] Shutting down...
64+
```
3165

32-
[ 6.364011 0:10 starry::syscall_imp:170] Syscall writev return 1
33-
[ 6.372136 0:10 starry::syscall_imp:57] Syscall exit_group
34-
[ 6.377821 0:10 starry::syscall_imp::task::thread:62] Temporarily replace sys_exit_group with sys_exit
35-
[ 6.407838 1:2 starry:59] User task /prlimit64 exited with code: Some(1)
36-
[ 6.428410 1:2 axhal::platform::riscv64_qemu_virt::misc:3] Shutting down...
37-
```
66+
## 注意
67+
68+
目前的stack_size只是一个task_ext中的状态量,并没有实际的作用

0 commit comments

Comments
 (0)