Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Tony Wu <tung7970@gmail.com>
To: ralf@linux-mips.org, linux-mips@linux-mips.org
Subject: [PATCH 0/2] MIPS: fix get_frame_info and frame_info_init
Date: Thu, 9 May 2013 22:44:06 +0800	[thread overview]
Message-ID: <20130509144406.GB3562@hades> (raw)

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 optimization
801de7b4 <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(-)

                 reply	other threads:[~2013-05-09 14:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130509144406.GB3562@hades \
    --to=tung7970@gmail.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox