MIPS: fix get_frame_info and frame_info_init
cover MIPS: fix get_frame_info and frame_info_init
Hi,
There are a couple of issues with the current frame_info_init and get_frame_info implementation. get_frame_info cannot detect sibling call and the result stored in schedule_mfi is wrong.
1. get_frame_info and sibling call
The first issue is that get_frame_info() did not consider sibling call case. When a sibling call function is given, it may come across function boundary and return wrong frame info instead.
For example, in frame_info_init(), schedule is passed to get_frame_info() and io_schedule's info is returned instead of schedule's.
801de7b4 <schedule>:
801de7b4: 8f820000 lw v0,0(gp) 801de7b8: 8c420000 lw v0,0(v0) 801de7bc: 080778ab j 801de2ac <__schedule> 801de7c0: 00000000 nop
801de7c4 <io_schedule>:
801de7c4: 27bdffe8 addiu sp,sp,-24
801de7c8: afbf0014 sw ra,20(sp)
801de7cc: 3c028021 lui v0,0x8021
801de7d0: 24425a60 addiu v0,v0,23136
801de7d4: c04303f8 lwc0 $3,1016(v0)
801de7d8: 24630001 addiu v1,v1,1
801de7dc: e04303f8 swc0 $3,1016(v0)
801de7e0: 1060fffc beqz v1,801de7d4 <io_schedule+0x10>
801de7e4: 00000000 nop
......2. schedule_mfi
After compiler compilation, schedule() is reduced to a sibling call stub to __schedule(), and due to issue 1, frame_info_init() is actually extracting wrong info from the function that follows schedule(), i.e. schedule_io().
Current optimization801de7b4 <schedule>:
801de7b4: 8f820000 lw v0,0(gp) 801de7b8: 8c420000 lw v0,0(v0) 801de7bc: 080778ab j 801de2ac <__schedule> 801de7c0: 00000000 nop
One solution is to compile schedule() in kernel/sched/core.c using -fno-omit-frame-pointer and -fno-optimize-sibling-calls, but this will incur performance degradation.
With -fno-omit-frame-pointer -fno-optimize-sibling-calls 801dee64 <schedule>:
801dee64: 27bdfff8 addiu sp,sp,-8 801dee68: afbe0004 sw s8,4(sp) 801dee6c: 03a0f021 move s8,sp 801dee70: 8f820000 lw v0,0(gp) 801dee74: 03c0e821 move sp,s8 801dee78: 8fbe0004 lw s8,4(sp) 801dee7c: 8c420000 lw v0,0(v0) 801dee80: 08077a4f j 801de93c <__schedule> 801dee84: 27bd0008 addiu sp,sp,8
Another solution is to extract schedule_mfi from the real scheduler __schedule.
I am sending two patches, one to fix get_frame_info sibling call issue, the other to extract schedule_mfi from __schedule. Please help review their validity.
Tony Wu (2):
MIPS: detect sibling call in get_frame_info
MIPS: get schedule_mfi info from __schedule
arch/mips/kernel/process.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)