linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Brian Gerst <brgerst@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	Ingo Molnar <mingo@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Borislav Petkov <bp@suse.de>, "H. Peter Anvin" <hpa@zytor.com>,
	X86 ML <x86@kernel.org>
Subject: Re: [PATCH 3/4] x86: Rewrite switch_to() code
Date: Mon, 23 May 2016 06:47:22 -0500	[thread overview]
Message-ID: <20160523114722.4nv3dpb2e5xr7ku7@treble> (raw)
In-Reply-To: <CAMzpN2hG3N5RguPb6uj=Eau8Kdo8492L9L6k9s3921S2-XDQAg@mail.gmail.com>

On Mon, May 23, 2016 at 07:14:14AM -0400, Brian Gerst wrote:
> On Sun, May 22, 2016 at 10: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.
> 
> Ok, how about if it pushed RBP first, then we teach get_wchan() to add
> the fixed offset from thread.sp to get bp?  that way it don't have to
> push it twice.

In theory I like the idea, and it would work: the unwinder could just
use the inactive_task_frame struct (as Andy suggested) to find the frame
pointer.

But I suspect it would break all existing unwinders, both in-tree and
out-of-tree.  The only out-of-tree one I know of is crash, not sure if
there are more out there.

-- 
Josh

  reply	other threads:[~2016-05-23 11:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-21 16:04 [PATCH 0/4] x86: Rewrite switch_to() Brian Gerst
2016-05-21 16:04 ` [PATCH 1/4] x86: Save return value from kernel_thread Brian Gerst
2016-05-22  1:44   ` Andy Lutomirski
2016-05-22  2:19     ` Brian Gerst
2016-05-21 16:04 ` [PATCH 2/4] x86-32, kgdb: Don't use thread.ip in sleeping_thread_to_gdb_regs() Brian Gerst
2016-05-23 17:05   ` Andy Lutomirski
2016-05-21 16:04 ` [PATCH 3/4] x86: Rewrite switch_to() code Brian Gerst
2016-05-22 17:59   ` Andy Lutomirski
2016-05-22 19:31     ` Brian Gerst
2016-05-22 21:07       ` Andy Lutomirski
2016-05-23  2:34     ` Josh Poimboeuf
2016-05-23  4:47       ` Andy Lutomirski
2016-05-23 11:40         ` Josh Poimboeuf
2016-05-23 11:49           ` Brian Gerst
2016-05-23 12:05             ` Josh Poimboeuf
2016-05-23 11:14       ` Brian Gerst
2016-05-23 11:47         ` Josh Poimboeuf [this message]
2016-05-23 11:49           ` Josh Poimboeuf
2016-05-23 16:46             ` Josh Poimboeuf
2016-05-23 17:03               ` Andy Lutomirski
2016-05-23 18:44                 ` Josh Poimboeuf
2016-07-12 14:16                 ` Josh Poimboeuf
2016-06-15  1:31   ` Andy Lutomirski
2016-06-15  8:03     ` Ingo Molnar
2016-06-15 11:52       ` Brian Gerst
2016-05-21 16:04 ` [PATCH 4/4] x86: Pass kernel thread parameters in fork_frame Brian Gerst
2016-05-22 18:01   ` Andy Lutomirski
2016-05-22 19:21     ` Brian Gerst
2016-05-23 15:23   ` Josh Poimboeuf
2016-05-23 15:36     ` Andy Lutomirski
2016-05-23 21:04       ` Brian Gerst

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=20160523114722.4nv3dpb2e5xr7ku7@treble \
    --to=jpoimboe@redhat.com \
    --cc=bp@suse.de \
    --cc=brgerst@gmail.com \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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;
as well as URLs for NNTP newsgroup(s).