Skip to contentSkip to conversation

UNWIND_INFO slowdown in -mm1

PATCH New Jan Beulich 3 participants 6 messages Oct 17, 2006 – Nov 17, 2006 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 2 lines

in 2.6.18-mm1 we are seeing _really_ long delays in the unwind code. (full trace attached) On an Athlon64 3800+ CPU:

Below patch should help, can you try it out? Short of the linker supporting building a binary lookup table at build time, it creates one as soon as the bootmem allocator is usable (so you'll continue using the linear lookup for the first [hopefully] few calls). The code should be ready to utilize a build-time created table once a fixed linker becomes available.

Makefile +1 -0
@@ -499,6 +499,7 @@ endif
 
 ifdef CONFIG_UNWIND_INFO
 CFLAGS		+= -fasynchronous-unwind-tables
+LDFLAGS_vmlinux	+= --eh-frame-hdr
 endif
 
 ifdef CONFIG_DEBUG_INFO
include/asm-generic/vmlinux.lds.h +16 -0
@@ -125,6 +125,10 @@
 		*(__param)						\
 		VMLINUX_SYMBOL(__stop___param) = .;			\
 	}								\
+									\
+	/* Unwind data binary search table */				\
+	EH_FRAME_HDR							\
+									\
 	__end_rodata = .;						\
 	. = ALIGN(4096);
 
@@ -157,6 +161,18 @@
 		*(.kprobes.text)					\
 		VMLINUX_SYMBOL(__kprobes_text_end) = .;
 
+#ifdef CONFIG_STACK_UNWIND
+		/* Unwind data binary search table */
+#define EH_FRAME_HDR							\
+        	.eh_frame_hdr : AT(ADDR(.eh_frame_hdr) - LOAD_OFFSET) {	\
+			VMLINUX_SYMBOL(__start_unwind_hdr) = .;		\
+			*(.eh_frame_hdr)				\
+			VMLINUX_SYMBOL(__end_unwind_hdr) = .;		\
+		}
+#else
+#define EH_FRAME_HDR
+#endif
+
 		/* DWARF debug sections.
 		Symbols in the DWARF debugging sections are relative to
 		the beginning of the section so we begin them at 0.  */
include/linux/unwind.h +2 -0
@@ -26,6 +26,7 @@ struct module;
  * Initialize unwind support.
  */
 extern void unwind_init(void);
+extern void unwind_setup(void);
 
 #ifdef CONFIG_MODULES
 
@@ -73,6 +74,7 @@ extern int unwind_to_user(struct unwind_
 struct unwind_frame_info {};
 
 static inline void unwind_init(void) {}
+static inline void unwind_setup(void) {}
 
 #ifdef CONFIG_MODULES
 
init/main.c +1 -0
@@ -503,6 +503,7 @@ asmlinkage void __init start_kernel(void
 	printk(KERN_NOTICE);
 	printk(linux_banner);
 	setup_arch(&command_line);
+	unwind_setup();
 	setup_per_cpu_areas();
 	smp_prepare_boot_cpu();	/* arch-specific boot-cpu hooks */
 
kernel/unwind.c +278 -38

386 lines not on this page · raw message

Acked-by
#2 lore raw
Quoted 9 lines · Jan Beulich
Quoted 2 lines

in 2.6.18-mm1 we are seeing _really_ long delays in the unwind code. (full trace attached) On an Athlon64 3800+ CPU:

Below patch should help, can you try it out? Short of the linker supporting building a binary lookup table at build time, it creates one as soon as the bootmem allocator is usable (so you'll continue using the linear lookup for the first [hopefully] few calls). The code should be ready to utilize a build-time created table once a fixed linker becomes available.

i tried this ontop of -git and it builds and boots fine, and the bootup speed problems seem to be gone. Thanks!

Quoted 1 line

Ingo

#3 lore raw
In reply to Jan Beulich
Quoted 9 lines · Jan Beulich
Quoted 2 lines

in 2.6.18-mm1 we are seeing _really_ long delays in the unwind code. (full trace attached) On an Athlon64 3800+ CPU:

Below patch should help, can you try it out? Short of the linker supporting building a binary lookup table at build time, it creates one as soon as the bootmem allocator is usable (so you'll continue using the linear lookup for the first [hopefully] few calls). The code should be ready to utilize a build-time created table once a fixed linker becomes available.

I added the patch now, thanks.

Not sure this is still .19 material though or better delayed for .20. What do you think?

-Andi

#4 lore raw
Quoted 11 lines · Andi Kleen
Quoted 6 lines

Below patch should help, can you try it out? Short of the linker supporting building a binary lookup table at build time, it creates one as soon as the bootmem allocator is usable (so you'll continue using the linear lookup for the first [hopefully] few calls). The code should be ready to utilize a build-time created table once a fixed linker becomes available.

I added the patch now, thanks.

Not sure this is still .19 material though or better delayed for .20. What do you think?

it's a performance regression that results in 3x boot time slowdown.

Ingo

#5 lore raw

-rc6, "DWARF2 unwinder stuck at" ...

In reply to Jan Beulich

Jan,

in 2.6.19-rc6 i'm getting frequent unwinder failures, like:

  [<c0104eb5>] dump_trace+0x69/0x1b0
  [<c0105013>] show_trace_log_lvl+0x17/0x2b
  [<c034e6c4>] __func__.18297+0xf3fd/0x3ccf5
 DWARF2 unwinder stuck at __func__.18297+0xf3fd/0x3ccf5

Leftover inexact backtrace:

  [<c010534b>] show_trace+0xf/0x11
  [<c0105360>] dump_stack+0x13/0x15
  [<c01419e9>] __lock_acquire+0x6fe/0x98a
  [<c0175956>] cache_alloc_refill+0x8f/0x534
  [<c0141f14>] lock_acquire+0x5b/0x77
  [<f0a32963>] __ip_ct_refresh_acct+0x123/0x15b [ip_conntrack]
  [<f0a32963>] __ip_ct_refresh_acct+0x123/0x15b [ip_conntrack]
  [<f0a34acc>] udp_packet+0x9e/0xaa [ip_conntrack]
  [<f0a33437>] ip_conntrack_in+0x385/0x479 [ip_conntrack]
  [<c01215d8>] try_to_wake_up+0x3ea/0x3f4
  [<c0324300>] netlbl_mgmt_listall_cb+0xc8/0x1bd
  [<c02dfe28>] nf_iterate+0x38/0x6a
  [<c02e4dbf>] ip_rcv_finish+0x0/0x271
  [<c02dfeac>] nf_hook_slow+0x52/0xc9
  [<c02e4dbf>] ip_rcv_finish+0x0/0x271
  [<c02e564f>] ip_rcv+0x1fc/0x491
  [<c02e4dbf>] ip_rcv_finish+0x0/0x271
  [<c02c1f2a>] sock_queue_rcv_skb+0xd5/0xdc
  [<c02e5453>] ip_rcv+0x0/0x491
  [<c02cac42>] netif_receive_skb+0x339/0x366
  [<c02cad04>] process_backlog+0x95/0xed
  [<c02c909e>] net_rx_action+0xad/0x1da
  [<c012bfdc>] ksoftirqd+0x107/0x1e0
  [<c012bed5>] ksoftirqd+0x0/0x1e0
  [<c0139520>] kthread+0xbf/0xeb
  [<c0139461>] kthread+0x0/0xeb
  [<c0104c23>] kernel_thread_helper+0x7/0x10
  =======================

it's quite an annoyance, i rarely see the unwinder getting a stackdump right, without 'falling back' to the inexact backtrace ...

Ingo

#6 lore raw

PATCH 1/1 x86_64: stack unwinder crash fix

Quoted 3 lines · Ingo Molnar

Jan,

in 2.6.19-rc6 i'm getting frequent unwinder failures, like:

[...]

Quoted 2 lines

it's quite an annoyance, i rarely see the unwinder getting a stackdump right, without 'falling back' to the inexact backtrace ...

to make matters worse, i also got an unwinder /crash/ while it tried to dump the stack ...

that particular bug is fixed by the patch below - aligning the stack pointer solved both the case of corrupted RSP values and corrupted/buggy dwarf2 debug info.

Linus, please apply, this is a 2.6.19 must-fix i think.

Ingo

---------------->
Subject: [patch] x86_64: stack unwinder crash fix
From: Ingo Molnar <[email protected]>

the new dwarf2 unwinder crashes while trying to dump the stack:

Leftover inexact backtrace:

 Unable to handle kernel paging request at ffffffff82800000 RIP:
  [<ffffffff8026cf26>] dump_trace+0x35b/0x3d2
 PGD 203027 PUD 205027 PMD 0
 Oops: 0000 [2] PREEMPT SMP
 CPU 0
 Modules linked in:
 Pid: 30, comm: khelper Not tainted 2.6.19-rc6-rt1 #11
 RIP: 0010:[<ffffffff8026cf26>]  [<ffffffff8026cf26>] dump_trace+0x35b/0x3d2
 RSP: 0000:ffff81003fb9d848  EFLAGS: 00010006
 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
 RDX: 0000000000000000 RSI: ffffffff805b3520 RDI: 0000000000000000
 RBP: ffffffff827ffff9 R08: ffffffff80aad000 R09: 0000000000000005
 R10: ffffffff80aae000 R11: ffffffff8037961b R12: ffff81003fb9d858
 R13: 0000000000000000 R14: ffffffff80598460 R15: ffffffff80ab1fc0
 FS:  0000000000000000(0000) GS:ffffffff806c4200(0000) knlGS:0000000000000000
 CS:  0010 DS: 0018 ES: 0018 CR0: 000000008005003b
 CR2: ffffffff82800000 CR3: 0000000000201000 CR4: 00000000000006e0

this crash happened because it did not sanitize the dwarf2 data it got, and got an unaligned stack pointer - which happily walked past the process stack (and eventually reached the end of kernel memory and pagefaulted there) due to this naive iteration condition:

        HANDLE_STACK (((long) stack & (THREAD_SIZE-1)) != 0);

note that i386 is alot more conservative when it comes to trusting stack pointers:

static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)

 {
         return  p > (void *)tinfo &&
                 p < (void *)tinfo + THREAD_SIZE - 3;

}

but the x86_64 code did not take this bit of i386 code.

the fix is to align the stack pointer.

---
 arch/x86_64/kernel/traps.c |    6 ++++++
 1 file changed, 6 insertions(+)
arch/x86_64/kernel/traps.c +6 -0
Index: linux/arch/x86_64/kernel/traps.c
===================================================================
@@ -290,6 +290,12 @@ void dump_trace(struct task_struct *tsk,
 		if (tsk && tsk != current)
 			stack = (unsigned long *)tsk->thread.rsp;
 	}
+	/*
+	 * Align the stack pointer on word boundary, later loops
+	 * rely on that (and corruption / debug info bugs can cause
+	 * unaligned values here):
+	 */
+	stack = (unsigned long *)((unsigned long)stack & ~(sizeof(long)-1));
 
 	/*
 	 * Print function call entries within a stack. 'cond' is the