* [PATCH v2 2/2] MIPS: get schedule_mfi info from __schedule
@ 2013-05-10 11:09 Tony Wu
0 siblings, 0 replies; only message in thread
From: Tony Wu @ 2013-05-10 11:09 UTC (permalink / raw)
To: ralf, linux-mips
schedule_mfi is supposed to be extracted from schedule(), and
is used in thread_saved_pc and get_wchan.
But, after optimization, schedule() is reduced to a sibling
call to __schedule(), and no real frame info can be extracted.
One solution is to compile schedule() with -fno-omit-frame-pointer
and -fno-optimize-sibling-calls, but that will incur performance
degradation.
Another solution is to extract info from the real scheduler,
__schedule, and this is the approache adopted here.
This patch follows the sibling call and extracts the schedule_mfi
from the __schedule with and without KALLSYMS enabled. It also fixes
the "Can't analyze schedule() prologue" warning at boot time.
Signed-off-by: Tony Wu <tung7970@gmail.com>
---
arch/mips/kernel/process.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index a794eb5..a01b523 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -314,15 +314,42 @@ err:
static struct mips_frame_info schedule_mfi __read_mostly;
+#ifdef CONFIG_KALLSYMS
+static unsigned long get___schedule_addr(void)
+{
+ return kallsyms_lookup_name("__schedule");
+}
+#else
+static unsigned long get___schedule_addr(void)
+{
+ union mips_instruction *ip = (void *)schedule;
+ int max_insns = 8;
+ int i;
+
+ for (i = 0; i < max_insns; i++, ip++) {
+ if (ip->j_format.opcode == j_op)
+ return J_TARGET(ip, ip->j_format.target);
+ }
+ return 0;
+}
+#endif
+
static int __init frame_info_init(void)
{
unsigned long size = 0;
#ifdef CONFIG_KALLSYMS
unsigned long ofs;
+#endif
+ unsigned long addr;
- kallsyms_lookup_size_offset((unsigned long)schedule, &size, &ofs);
+ addr = get___schedule_addr();
+ if (!addr)
+ addr = (unsigned long)schedule;
+
+#ifdef CONFIG_KALLSYMS
+ kallsyms_lookup_size_offset(addr, &size, &ofs);
#endif
- schedule_mfi.func = schedule;
+ schedule_mfi.func = (void *)addr;
schedule_mfi.func_size = size;
get_frame_info(&schedule_mfi);
--
1.7.10.2 (Apple Git-33)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-05-10 11:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-10 11:09 [PATCH v2 2/2] MIPS: get schedule_mfi info from __schedule Tony Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox