cpu高,R状态的任务为什么/proc/[pid]/stack堆栈不准
-
构造sys cpu高R的情况,为什么堆栈不准
-
190 read_unlock(&tasklist_lock);
-
191 while(1) {
-
192 udelay(8000);
-
193 usleep_range(1, 2);
-
194 }
-
195
-
196 return 0;
-
197 }
-
-
如下,只有在任务睡眠的时候堆栈是正确的
-
1、原因是如果任务在运行,cat stack的起始帧是上次切换出去的时候ENTRY(cpu_switch_to)保存的帧
-
而如果任务在运行处于R状态,那么用上次的起始帧去unwind现在的内核栈,回溯就会有很奇怪的数据,不是正常的数据
-
2、如果是单核的情况,那么在敲回溯的时候,R状态的任务会被preempt 调度出去,这种情况下cat的stack每次都是准确的
-
3、如果是用户态100%的情况rtprocess_arm64 1 50 2(FIFO 50 cpu2),内核栈是退出来的已经清空了的,一般没有内容
-
# cat /proc/189/stack
-
[<0>] __switch_to+0x288/0x418
-
/ #
-
-
-
/ # cat /proc/148/stack
-
[<0>] __switch_to+0x288/0x418
-
[<0>] info_show+0x23c/0x2b8
-
[<0>] seq_read+0x334/0xf38
-
[<0>] proc_reg_read+0x124/0x1b0
-
[<0>] do_iter_read+0x2e8/0x490
-
[<0>] vfs_readv+0xc8/0x120
-
[<0>] default_file_splice_read+0x374/0x730
-
[<0>] do_splice_to+0xe0/0x140
-
[<0>] splice_direct_to_actor+0x270/0x720
-
[<0>] do_splice_direct+0x12c/0x200
-
[<0>] do_sendfile+0x338/0xac0
-
[<0>] __arm64_sys_sendfile64+0x340/0x400
-
[<0>] el0_svc_common.constprop.0+0x110/0x378
-
[<0>] el0_svc_handler+0x4c/0xd0
-
[<0>] el0_svc+0x8/0x1bc
-
/ # cat /proc/148/stack
-
[<0>] __switch_to+0x288/0x418
-
[<0>] 0xffff000008cccc00
-
/ # cat /proc/148/stack
-
[<0>] __switch_to+0x288/0x418
-
[<0>] str_spec.71612+0x1c2838/0x2d6378
-
/ # cat /proc/148/stack
-
[<0>] __switch_to+0x288/0x418
-
[<0>] str_spec.71612+0x1c2838/0x2d6378
-
/ #
-
-
if (tsk != current) {
-
start_backtrace(&frame, thread_saved_fp(tsk),
-
thread_saved_pc(tsk));
-
-
#define thread_saved_pc(tsk) \
-
((unsigned long)(tsk->thread.cpu_context.pc))
-
#define thread_saved_sp(tsk) \
-
((unsigned long)(tsk->thread.cpu_context.sp))
-
#define thread_saved_fp(tsk) \
-
((unsigned long)(tsk->thread.cpu_context.fp))
-
-
-
1208 */
-
1209 ENTRY(cpu_switch_to)
-
1210 mov x10, #THREAD_CPU_CONTEXT
-
1211 add x8, x0, x10
-
1212 mov x9, sp
-
1213 stp x19, x20, [x8], #16 // store callee-saved registers
-
1214 stp x21, x22, [x8], #16
-
1215 stp x23, x24, [x8], #16
-
1216 stp x25, x26, [x8], #16
-
1217 stp x27, x28, [x8], #16
-
1218 stp x29, x9, [x8], #16
-
1219 str lr, [x8]
-
1220 add x8, x1, x10
-
1221 ldp x19, x20, [x8], #16 // restore callee-saved registers
-
1222 ldp x21, x22, [x8], #16
-
1223 ldp x23, x24, [x8], #16
-
1224 ldp x25, x26, [x8], #16
-
1225 ldp x27, x28, [x8], #16
-
1226 ldp x29, x9, [x8], #16
-
1227 ldr lr, [x8]
-
1228 mov sp, x9
-
1229 msr sp_el0, x1
-
1230 ret
-
1231 ENDPROC(cpu_switch_to)
-
1232 NOKPROBE(cpu_switch_to)
阅读(1267) | 评论(0) | 转发(0) |