From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
live-patching@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Andy Lutomirski <luto@kernel.org>, Jiri Slaby <jslaby@suse.cz>,
"H. Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <peterz@infradead.org>,
Mike Galbraith <efault@gmx.de>
Subject: Re: [PATCH v4 2/2] x86/kconfig: make it easier to switch to the new ORC unwinder
Date: Tue, 25 Jul 2017 08:54:24 -0500 [thread overview]
Message-ID: <20170725135424.zukjmgpz3plf5pmt@treble> (raw)
In-Reply-To: <20170725091059.a2et5mhz7ytrhv6y@gmail.com>
On Tue, Jul 25, 2017 at 11:10:59AM +0200, Ingo Molnar wrote:
>
> * Josh Poimboeuf <jpoimboe@redhat.com> wrote:
>
> > A couple of Kconfig changes which make it much easier to switch to the
> > new CONFIG_ORC_UNWINDER:
> >
> > 1) Remove x86 dependencies on CONFIG_FRAME_POINTER for lockdep,
> > latencytop, and fault injection. x86 has a 'guess' unwinder which
> > just scans the stack for kernel text addresses. It's not 100%
> > accurate but in many cases it's good enough. This allows those users
> > who don't want the text overhead of the frame pointer or ORC
> > unwinders to still use these features. More importantly, this also
> > makes it much more straightforward to disable frame pointers.
> >
> > 2) Make CONFIG_ORC_UNWINDER depend on !CONFIG_FRAME_POINTER. While it
> > would be possible to have both enabled, it doesn't really make sense
> > to do so. So enforce a sane configuration to prevent the user from
> > making a dumb mistake.
> >
> > With these changes, when you disable CONFIG_FRAME_POINTER, "make
> > oldconfig" will ask if you want to enable CONFIG_ORC_UNWINDER.
>
> Yeah, so I think this is still suboptimal: the frame pointer and the Orc unwinders
> are configured in different places, and the user won't know about the various
> unwinder options unless stumbling across them by accidentally disabling frame
> pointers ...
>
> Also, the Kconfig help text for frame pointers is now actively misleading:
>
> CONFIG_FRAME_POINTER:
>
> If you say Y here the resulting kernel image will be slightly
> larger and slower, but it gives very useful debugging information
> in case of kernel bugs. (precise oopses/stacktraces/warnings)
>
> Please, as I suggested it before, make it a multiple choice option: frame, Orc, or
> the guess unwinder.
>
> I'd only offer the 'guess' unwinder if EXPERT is selected, because it's a really
> sub-optimal selection all things considered.
>
> Once things are tested and it's all rosy we can change the default x86 unwinder to
> Orc and organize the naming of the config variables to:
>
> CONFIG_UNWINDER_ORC
> CONFIG_UNWINDER_FRAME_POINTER
> CONFIG_UNWINDER_GUESS
How about the below patch? It goes on top of the other two.
----
From: Josh Poimboeuf <jpoimboe@redhat.com>
Subject: [PATCH] x86/kconfig: consolidate unwinders into multiple choice selection
There are three mutually exclusive unwinders. Make that more obvious by
combining them into a multiple-choice selection:
CONFIG_FRAME_POINTER_UNWINDER
CONFIG_ORC_UNWINDER
CONFIG_GUESS_UNWINDER (if CONFIG_EXPERT=y)
Frame pointers are still the default (for now).
The old CONFIG_FRAME_POINTER option is still used in some
arch-independent places, so keep it around, but make it invisible to the
user on x86. It's now selected by CONFIG_FRAME_POINTER_UNWINDER.
Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
arch/x86/Kconfig | 3 +--
arch/x86/Kconfig.debug | 47 ++++++++++++++++++++++++++++++++++++-------
arch/x86/configs/tiny.config | 2 ++
arch/x86/include/asm/unwind.h | 4 ++--
4 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 21c75a652bb9..1e789ecefc02 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -73,7 +73,6 @@ config X86
select ARCH_USE_QUEUED_RWLOCKS
select ARCH_USE_QUEUED_SPINLOCKS
select ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
- select ARCH_WANT_FRAME_POINTERS
select ARCH_WANTS_DYNAMIC_TASK_STRUCT
select ARCH_WANTS_THP_SWAP if X86_64
select BUILDTIME_EXTABLE_SORT
@@ -168,7 +167,7 @@ config X86
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
select HAVE_REGS_AND_STACK_ACCESS_API
- select HAVE_RELIABLE_STACKTRACE if X86_64 && FRAME_POINTER && STACK_VALIDATION
+ select HAVE_RELIABLE_STACKTRACE if X86_64 && FRAME_POINTER_UNWINDER && STACK_VALIDATION
select HAVE_STACK_VALIDATION if X86_64
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_UNSTABLE_SCHED_CLOCK
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index e6176007b838..71a48a30fc84 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -356,9 +356,32 @@ config PUNIT_ATOM_DEBUG
The current power state can be read from
/sys/kernel/debug/punit_atom/dev_power_state
+choice
+ prompt "Choose kernel unwinder"
+ default FRAME_POINTER_UNWINDER
+ ---help---
+ This determines which method will be used for unwinding kernel stack
+ traces for panics, oopses, bugs, warnings, perf, /proc/<pid>/stack,
+ livepatch, lockdep, and more.
+
+config FRAME_POINTER_UNWINDER
+ bool "Frame pointer unwinder"
+ select FRAME_POINTER
+ ---help---
+ This option enables the frame pointer unwinder for unwinding kernel
+ stack traces.
+
+ The unwinder itself is fast and it uses less RAM than the ORC
+ unwinder, but the kernel text size will grow by ~3% and the kernel's
+ overall performance will degrade by roughly 5-10%.
+
+ This option is recommended if you want to use the livepatch
+ consistency model, as this is currently the only way to get a
+ reliable stack trace (CONFIG_HAVE_RELIABLE_STACKTRACE).
+
config ORC_UNWINDER
bool "ORC unwinder"
- depends on X86_64 && !FRAME_POINTER
+ depends on X86_64
select STACK_VALIDATION
---help---
This option enables the ORC (Oops Rewind Capability) unwinder for
@@ -372,12 +395,22 @@ config ORC_UNWINDER
Enabling this option will increase the kernel's runtime memory usage
by roughly 2-4MB, depending on your kernel config.
-config FRAME_POINTER_UNWINDER
- def_bool y
- depends on !ORC_UNWINDER && FRAME_POINTER
-
config GUESS_UNWINDER
- def_bool y
- depends on !ORC_UNWINDER && !FRAME_POINTER
+ bool "Guess unwinder"
+ depends on EXPERT
+ ---help---
+ This option enables the "guess" unwinder for unwinding kernel stack
+ traces. It scans the stack and reports every kernel text address it
+ finds. Some of the addresses it reports may be incorrect.
+
+ While this option often produces false positives, it can still be
+ useful in many cases. Unlike the other unwinders, it has no runtime
+ overhead.
+
+endchoice
+
+config FRAME_POINTER
+ depends on !ORC_UNWINDER && !GUESS_UNWINDER
+ bool
endmenu
diff --git a/arch/x86/configs/tiny.config b/arch/x86/configs/tiny.config
index 4b429df40d7a..550cd5012b73 100644
--- a/arch/x86/configs/tiny.config
+++ b/arch/x86/configs/tiny.config
@@ -1,3 +1,5 @@
CONFIG_NOHIGHMEM=y
# CONFIG_HIGHMEM4G is not set
# CONFIG_HIGHMEM64G is not set
+CONFIG_GUESS_UNWINDER=y
+# CONFIG_FRAME_POINTER_UNWINDER is not set
diff --git a/arch/x86/include/asm/unwind.h b/arch/x86/include/asm/unwind.h
index 25b8d31a007d..e9f793e2df7a 100644
--- a/arch/x86/include/asm/unwind.h
+++ b/arch/x86/include/asm/unwind.h
@@ -16,7 +16,7 @@ struct unwind_state {
bool signal, full_regs;
unsigned long sp, bp, ip;
struct pt_regs *regs;
-#elif defined(CONFIG_FRAME_POINTER)
+#elif defined(CONFIG_FRAME_POINTER_UNWINDER)
bool got_irq;
unsigned long *bp, *orig_sp, ip;
struct pt_regs *regs;
@@ -50,7 +50,7 @@ void unwind_start(struct unwind_state *state, struct task_struct *task,
__unwind_start(state, task, regs, first_frame);
}
-#if defined(CONFIG_ORC_UNWINDER) || defined(CONFIG_FRAME_POINTER)
+#if defined(CONFIG_ORC_UNWINDER) || defined(CONFIG_FRAME_POINTER_UNWINDER)
static inline struct pt_regs *unwind_get_entry_regs(struct unwind_state *state)
{
if (unwind_done(state))
--
2.13.3
next prev parent reply other threads:[~2017-07-25 13:54 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 23:36 [PATCH v4 0/2] " Josh Poimboeuf
2017-07-24 23:36 ` [PATCH v4 1/2] x86/unwind: add " Josh Poimboeuf
2017-07-26 12:10 ` [tip:x86/asm] x86/unwind: Add the " tip-bot for Josh Poimboeuf
2017-07-28 16:48 ` [PATCH v4 1/2] x86/unwind: add " Levin, Alexander (Sasha Levin)
2017-07-28 17:52 ` Josh Poimboeuf
2017-07-28 18:29 ` Levin, Alexander (Sasha Levin)
2017-07-28 18:57 ` Josh Poimboeuf
2017-07-28 19:59 ` Levin, Alexander (Sasha Levin)
2017-07-29 3:54 ` Josh Poimboeuf
2017-08-08 18:58 ` Josh Poimboeuf
2017-08-08 19:03 ` Linus Torvalds
2017-08-08 19:13 ` Josh Poimboeuf
2017-08-08 20:09 ` Andy Lutomirski
2017-08-08 22:00 ` Josh Poimboeuf
2017-08-09 8:49 ` Juergen Gross
2017-08-09 9:16 ` Peter Zijlstra
2017-08-09 9:24 ` Juergen Gross
2017-08-09 9:35 ` Peter Zijlstra
2017-08-09 9:55 ` Juergen Gross
2017-08-09 20:15 ` Josh Poimboeuf
2017-08-10 7:05 ` Juergen Gross
2017-08-10 14:09 ` Josh Poimboeuf
2017-08-10 14:24 ` Juergen Gross
2017-08-10 14:39 ` Josh Poimboeuf
2017-08-10 14:59 ` Juergen Gross
2017-08-10 15:49 ` Josh Poimboeuf
2017-08-10 14:42 ` Josh Poimboeuf
2017-08-09 16:11 ` Andy Lutomirski
2017-08-09 17:52 ` Juergen Gross
2017-09-27 21:08 ` Josh Poimboeuf
2017-09-28 6:03 ` Juergen Gross
2017-09-28 13:55 ` Josh Poimboeuf
2017-09-28 13:58 ` Juergen Gross
2017-07-24 23:36 ` [PATCH v4 2/2] x86/kconfig: make it easier to switch to the new " Josh Poimboeuf
2017-07-25 9:10 ` Ingo Molnar
2017-07-25 13:54 ` Josh Poimboeuf [this message]
2017-07-26 12:11 ` [tip:x86/asm] x86/kconfig: Consolidate unwinders into multiple choice selection tip-bot for Josh Poimboeuf
2017-07-26 12:10 ` [tip:x86/asm] x86/kconfig: Make it easier to switch to the new ORC unwinder tip-bot for Josh Poimboeuf
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=20170725135424.zukjmgpz3plf5pmt@treble \
--to=jpoimboe@redhat.com \
--cc=efault@gmx.de \
--cc=hpa@zytor.com \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--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
all inboxes | Powered by JetHome®