Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1405092

Re: [PATCH 3/4] x86: Rewrite switch_to() code

From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [PATCH 3/4] x86: Rewrite switch_to() code
Date 2016-05-23 06:50 +0200
Message-ID <rBPYu-1mf-23@gated-at.bofh.it> (permalink)
References <rBhDs-5HD-5@gated-at.bofh.it> <rBhDs-5HD-7@gated-at.bofh.it> <rBFZ8-3Y4-25@gated-at.bofh.it> <rBNWG-9l-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sun, May 22, 2016 at 7:34 PM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> On Sun, May 22, 2016 at 10:59:38AM -0700, Andy Lutomirski wrote:
>> cc: Josh Poimboeuf: do you care about the exact stack layout of the
>> bottom of the stack of an inactive task?
>
> So there's one minor issue with this patch, relating to unwinding the
> stack of a newly forked task.  For detecting reliable stacks, the
> unwinder needs to unwind all the way to the syscall pt_regs to make sure
> the stack is sane.  But for newly forked tasks, that won't be possible
> here because the unwinding will stop at the fork_frame instead.
>
> So from an unwinder standpoint it might be nice for copy_thread_tls() to
> place a frame pointer on the stack next to the ret_from_fork return
> address, so that it would resemble an actual stack frame.  The frame
> pointer could probably just be hard-coded to zero.  And then the first
> bp in fork_frame would need to be a pointer to it instead of zero.  That
> would make it nicely resemble the stack of any other task.
>
> Alternatively I could teach the unwinder that if the unwinding starts at
> the fork_frame offset from the end of the stack page, and the saved rbp
> is zero, it can assume that it's a newly forked task.  But that seems a
> little more brittle to me, as it requires the unwinder to understand
> more of the internal workings of the fork code.
>
> But overall I think this patch is a really nice cleanup, and other than
> the above minor issue it should be fine with my reliable unwinder, since
> rbp is still at the top of the stack.

Is this a regression or is there some reason that it works right
without the patch?

In any event, whatever we settle on for general pt_regs unwinding
should work for this, too.

>
> --
> Josh



-- 
Andy Lutomirski
AMA Capital Management, LLC

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 3/4] x86: Rewrite switch_to() code Brian Gerst <brgerst@gmail.com> - 2016-05-21 18:10 +0200
  Re: [PATCH 3/4] x86: Rewrite switch_to() code Andy Lutomirski <luto@amacapital.net> - 2016-05-22 20:10 +0200
    Re: [PATCH 3/4] x86: Rewrite switch_to() code Brian Gerst <brgerst@gmail.com> - 2016-05-22 21:40 +0200
      Re: [PATCH 3/4] x86: Rewrite switch_to() code Andy Lutomirski <luto@amacapital.net> - 2016-05-22 23:10 +0200
    Re: [PATCH 3/4] x86: Rewrite switch_to() code Josh Poimboeuf <jpoimboe@redhat.com> - 2016-05-23 04:40 +0200
      Re: [PATCH 3/4] x86: Rewrite switch_to() code Andy Lutomirski <luto@amacapital.net> - 2016-05-23 06:50 +0200
        Re: [PATCH 3/4] x86: Rewrite switch_to() code Josh Poimboeuf <jpoimboe@redhat.com> - 2016-05-23 13:50 +0200
          Re: [PATCH 3/4] x86: Rewrite switch_to() code Brian Gerst <brgerst@gmail.com> - 2016-05-23 13:50 +0200
            Re: [PATCH 3/4] x86: Rewrite switch_to() code Josh Poimboeuf <jpoimboe@redhat.com> - 2016-05-23 14:10 +0200
      Re: [PATCH 3/4] x86: Rewrite switch_to() code Brian Gerst <brgerst@gmail.com> - 2016-05-23 13:20 +0200
        Re: [PATCH 3/4] x86: Rewrite switch_to() code Josh Poimboeuf <jpoimboe@redhat.com> - 2016-05-23 13:50 +0200
          Re: [PATCH 3/4] x86: Rewrite switch_to() code Josh Poimboeuf <jpoimboe@redhat.com> - 2016-05-23 18:50 +0200
            Re: [PATCH 3/4] x86: Rewrite switch_to() code Andy Lutomirski <luto@amacapital.net> - 2016-05-23 19:10 +0200
              Re: [PATCH 3/4] x86: Rewrite switch_to() code Josh Poimboeuf <jpoimboe@redhat.com> - 2016-05-23 20:50 +0200
        Re: [PATCH 3/4] x86: Rewrite switch_to() code Josh Poimboeuf <jpoimboe@redhat.com> - 2016-05-23 13:50 +0200

csiph-web