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


Groups > linux.kernel > #1430219

Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ tracking

Path csiph.com!weretis.net!feeder4.news.weretis.net!news.mixmin.net!news.unit0.net!news.panservice.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod
From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ tracking
Date Fri, 24 Jun 2016 00:10:01 +0200
Message-ID <rNkYV-7Vl-5@gated-at.bofh.it> (permalink)
References <rCbFD-6ln-1@gated-at.bofh.it> <rMTm1-5QR-1@gated-at.bofh.it> <rMUBs-6zr-5@gated-at.bofh.it> <rMV4t-6Zs-3@gated-at.bofh.it> <rMV4t-6Zs-1@gated-at.bofh.it> <rMVnP-76s-21@gated-at.bofh.it> <rMVQR-7xn-5@gated-at.bofh.it> <rNfFT-48V-11@gated-at.bofh.it> <rNfPA-4cB-23@gated-at.bofh.it> <rNhHH-5Aq-17@gated-at.bofh.it> <rNjJw-6Ua-3@gated-at.bofh.it>
X-Original-To Josh Poimboeuf <jpoimboe@redhat.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=WeiB6Y6w14UNiVbJk1vKziD1j2j6rf6s52j3b+3NKQg=; b=MMWLTc5xE2Km0QlSkZdGj7OkHmRmcbKRoCPx6WV6ftFx6yFUparpqFRZUQogc5CLb0 gR7Lq1WuWPWQ8DOLEBKfsa6AT98eAp6RDMUCSYE7aGJwpc/kvn70eH3HiJ4wGbTY1fHr vua1umCZCImCQ9S2nJbEkQqg/cbu/DmNmRrdSlGmZIQkkSyLFgiBtjsH/UkI/MtLr9KH CJzMl6yMjIiNanZ2JPSBRmv7kJIT/g+fmxnGKBTMWxmB2dplv5/Nub4S32d0tIB8fmgb ZDPr6r2K0Fn9MIO/rRpej4o1j4YKgVstGiyrjrCLQsjsS99M6qlEnvx+a8kWiEHcL8Se WHJg==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=WeiB6Y6w14UNiVbJk1vKziD1j2j6rf6s52j3b+3NKQg=; b=Su6oXz2eqy0a/NIrhcOMj8WsapDbLgQyCAvmdbBSXGtoaoV5XI3hj4DeYdiaB8gdKN YJlqt1pjcP90l8hL54EHSrHODx86rDDZKh01GukF/5FfeJQis5O3mG2AJhJuCnvJ9O8F 944GdZMKGXl+qvJ3ggRuefcusCt6sWejddLPRujae6a9SgBZMyNd19KxNUEdyQV4gb0C u6NGJQx8eYVdXXY4YaPejzfKrjUMF1cVUWU8CaRvZS8HBlESPSRHLY7euoVWRRhiaVLe THoWh8jvkZYNszmHTfjQ1usoDPQ7VC78oF2p/otOEX4oWeIMlgd94k3R4qQh7Z06roR2 Os0w==
X-Gm-Message-State ALyK8tIleRv7gUZbbnlA02t78SuR6DP4clGzJGWamGfd3xn1Jl0HbdA5hCJd8CO6XhDcoMUlFYUATu43f/NipMY0
X-Received by 10.31.33.80 with SMTP id h77mr633361vkh.59.1466719259755; Thu, 23 Jun 2016 15:00:59 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 82
Organization linux.* mail to news gateway
X-Original-Cc Jiri Kosina <jikos@kernel.org>, Ingo Molnar <mingo@redhat.com>, X86 ML <x86@kernel.org>, Heiko Carstens <heiko.carstens@de.ibm.com>, "linux-s390@vger.kernel.org" <linux-s390@vger.kernel.org>, live-patching@vger.kernel.org, Michael Ellerman <mpe@ellerman.id.au>, Chris J Arges <chris.j.arges@canonical.com>, Jessica Yu <jeyu@redhat.com>, linuxppc-dev@lists.ozlabs.org, Petr Mladek <pmladek@suse.com>, Jiri Slaby <jslaby@suse.cz>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Vojtech Pavlik <vojtech@suse.com>, Miroslav Benes <mbenes@suse.cz>, Peter Zijlstra <peterz@infradead.org>
X-Original-Date Thu, 23 Jun 2016 15:00:40 -0700
X-Original-Message-ID <CALCETrXq-uZvxZ4xxLWcHVKx4unjJTe=Gqh0V0rkLz+-6su4gg@mail.gmail.com>
X-Original-References <CALCETrVNj2bscRZmSyzq4fMp5s3m0+KqpEFofv_uXsHF_na_=Q@mail.gmail.com> <20160622163011.4fjwalehrzk4a32t@treble> <CALCETrVJpFYi=x0nVWSVi3n40Xkig43Y5bRNOO2XNmUuC9Wt+g@mail.gmail.com> <20160622182245.4u72jgjg2khxracz@treble> <CALCETrXR9iMO1veHREumqTOvQuLYYQFH_=VRhQ6oXusXi+NFNg@mail.gmail.com> <20160622184042.br7ov37pl6eydr3y@treble> <CALCETrWQWhPnFai5_RkLDiNmaxcjVmaYDAGTzQL8fXien8ojSQ@mail.gmail.com> <20160623161950.ovwpvhq43tq35u7k@treble> <CALCETrWJ8fdttrM3ZwCgeBBzhJOPGc4PEHT8AZzc=eg7K69nfA@mail.gmail.com> <20160623183132.oqtl6flnoqtilurs@treble> <20160623204017.df22mljbrgpogeqp@treble>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1430219

Show key headers only | View raw


On Thu, Jun 23, 2016 at 1:40 PM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> On Thu, Jun 23, 2016 at 01:31:32PM -0500, Josh Poimboeuf wrote:
>> On Thu, Jun 23, 2016 at 09:35:29AM -0700, Andy Lutomirski wrote:
>> > > So which is the least-bad option?  To summarize:
>> > >
>> > >   1) task flag(s) for preemption and page faults
>> > >
>> > >   2) turn pt_regs into a stack frame
>> > >
>> > >   3) annotate all calls from entry code in a table
>> > >
>> > >   4) encode rbp on entry
>> > >
>> > > They all have their issues, though I'm partial to #2.
>> > >
>> > > Any more hare-brained ideas? :-)
>> >
>> > I'll try to take a closer look at #2 and see just how much I dislike
>> > all the stack frame munging.
>>
>> Ok.
>>
>> > Also, in principle, it's only the
>> > sleeping calls and the calls that make it into real (non-entry) kernel
>> > code that really want to be unwindable through this mechanism.
>>
>> Yeah, that's true.  We could modify options 2 or 3 to be less absolute.
>> Though I think that makes them more prone to future breakage.
>>
>> > FWIW, I don't care that much about preserving gdb's partial ability to
>> > unwind through pt_regs, especially because gdb really ought to be able
>> > to use DWARF, too.
>>
>> Hm, that's a good point.  I really don't know if there are any other
>> external tools out there that would care.  Maybe we could try option 4
>> and then see if anybody complains.
>
> I'm starting to think hare-brained option 4 is the way to go.  Any
> external tooling should really be relying on DWARF anyway.
>
> Here's a sneak preview.  If this general approach looks ok to you, I'll
> go ahead and port all the in-tree unwinders and post a proper patch.
>
> Instead of using xor -1 on the pt_regs pointer, I just cleared the
> high-order bit.  That makes the unwinding experience much more pleasant
> for a human stack walker, and also ensures that anybody trying to
> dereference it gets slapped with an oops, at least in the 48-bit address
> space era.
>
> diff --git a/arch/x86/entry/calling.h b/arch/x86/entry/calling.h
> index 9a9e588..bf397426 100644
> --- a/arch/x86/entry/calling.h
> +++ b/arch/x86/entry/calling.h
> @@ -201,6 +201,23 @@ For 32-bit we have the following conventions - kernel is built with
>         .byte 0xf1
>         .endm
>
> +       /*
> +        * This is a sneaky trick to help the unwinder find pt_regs on the
> +        * stack.  The frame pointer is replaced with an encoded pointer to
> +        * pt_regs.  The encoding is just a clearing of the highest-order bit,
> +        * which makes it an invalid address and is also a signal to the
> +        * unwinder that it's a pt_regs pointer in disguise.
> +        *
> +        * NOTE: This must be called *after* SAVE_EXTRA_REGS because it
> +        * corrupts rbp.
> +        */
> +       .macro ENCODE_FRAME_POINTER ptregs_offset=0
> +#ifdef CONFIG_FRAME_POINTER
> +       leaq \ptregs_offset(%rsp), %rbp
> +       btr $63, %rbp
> +#endif
> +       .endm
> +

Maybe optimize slightly:

.ifeq \ptregs_offset
mov %rsp, %rbp
.else
leaq \ptregs_offset(%rsp), %rbp
.endif

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


Thread

Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ  tracking Josh Poimboeuf <jpoimboe@redhat.com> - 2016-06-22 18:40 +0200
  Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ tracking Andy Lutomirski <luto@amacapital.net> - 2016-06-22 20:00 +0200
    Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ tracking Andy Lutomirski <luto@amacapital.net> - 2016-06-22 20:30 +0200
      Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ  tracking Josh Poimboeuf <jpoimboe@redhat.com> - 2016-06-22 20:50 +0200
        Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ tracking Andy Lutomirski <luto@amacapital.net> - 2016-06-22 21:20 +0200
          Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ  tracking Josh Poimboeuf <jpoimboe@redhat.com> - 2016-06-23 18:30 +0200
            Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ tracking Andy Lutomirski <luto@amacapital.net> - 2016-06-23 18:40 +0200
              Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ  tracking Josh Poimboeuf <jpoimboe@redhat.com> - 2016-06-23 20:40 +0200
                Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ  tracking Josh Poimboeuf <jpoimboe@redhat.com> - 2016-06-23 22:50 +0200
                Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ tracking Andy Lutomirski <luto@amacapital.net> - 2016-06-24 00:10 +0200
    Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ  tracking Josh Poimboeuf <jpoimboe@redhat.com> - 2016-06-22 20:30 +0200
  Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ tracking Andy Lutomirski <luto@amacapital.net> - 2016-06-23 02:10 +0200
    Re: [RFC PATCH v2 05/18] sched: add task flag for preempt IRQ  tracking Josh Poimboeuf <jpoimboe@redhat.com> - 2016-06-23 18:00 +0200

csiph-web