Re: [PATCH] x86/unwind/orc: unwind ftrace trampolines with correct orc
From: Steven Rostedt
Date: Thu Aug 18 2022 - 10:00:12 EST
On Thu, 18 Aug 2022 11:42:17 +0800
Chen Zhongjin <chenzhongjin@xxxxxxxxxx> wrote:
> Thanks for review!
>
>
> On 2022/8/18 10:28, Steven Rostedt wrote:
> > On Thu, 18 Aug 2022 09:55:25 +0800
> > Chen Zhongjin <chenzhongjin@xxxxxxxxxx> wrote:
> >
> >
> >> arch/x86/kernel/unwind_orc.c | 13 ++++++++-----
> >> 1 file changed, 8 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c
> >> index 38185aedf7d1..a938c5d0ed6f 100644
> >> --- a/arch/x86/kernel/unwind_orc.c
> >> +++ b/arch/x86/kernel/unwind_orc.c
> >> @@ -93,22 +93,25 @@ static struct orc_entry *orc_find(unsigned long ip);
> >> static struct orc_entry *orc_ftrace_find(unsigned long ip)
> >> {
> >> struct ftrace_ops *ops;
> >> - unsigned long caller;
> >> + unsigned long tramp_addr, offset;
> >>
> >> ops = ftrace_ops_trampoline(ip);
> >> if (!ops)
> >> return NULL;
> >>
> > Now if this is that unlikely recursion mentioned below then ops->trampoline
> > will be NULL, and if we do that offset addition, it will be incorrect.
> >
> > Perhaps we should add here:
> >
> > if (!ops->trampoline)
> > return NULL;
>
> I think when this will return NULL and then stop at orc_find:`if (ip ==
> 0)` and return null_orc_entry.
>
Duh, you're correct. I wasn't paying attention to how we acquired ops. Yes,
if ops->trampoline is NULL, then it will never be returned by
ftrace_ops_trampoline().
> >
> > Let's add some comments.
>
> Makes sense.
>
> If the above explanation logic is fine, I'll add this comment and send v2.
>
Yes, just add the comments for v2.
Thanks,
-- Steve