Hi Ingo, I intend to keep looking for possibilities to bring traps_32.c and traps_64.c closer to each-other. One trivial way (from my point of view) is to split out code into separate files. These two patches split out a large piece of code that has nothing to do with hardware traps. Are you willing to take those two patches? Or are they to intrusive? Patches are against the current master branch of the tip tree. The defconfigs compile fine and I ran some simple configs within qemu. Greetings, Alexander --
The dumpstack code is logically quite independent from the
hardware traps. Split it out into its own file.
Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm>
---
arch/x86/kernel/Makefile | 2 +-
arch/x86/kernel/dumpstack_32.c | 425 ++++++++++++++++++++++++++++++++++++++++
arch/x86/kernel/traps_32.c | 407 --------------------------------------
3 files changed, 426 insertions(+), 408 deletions(-)
create mode 100644 arch/x86/kernel/dumpstack_32.c
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index c71722d..ed1af8a 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -29,7 +29,7 @@ obj-y += time_$(BITS).o ioport.o ldt.o
obj-y += setup.o i8259.o irqinit_$(BITS).o setup_percpu.o
obj-$(CONFIG_X86_VISWS) += visws_quirks.o
obj-$(CONFIG_X86_32) += probe_roms_32.o
-obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
+obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o dumpstack_32.o
obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o
obj-y += bootflag.o e820.o
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
new file mode 100644
index 0000000..7378c0c
--- /dev/null
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -0,0 +1,425 @@
+/*
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
+ */
+#include <linux/kallsyms.h>
+#include <linux/kprobes.h>
+#include <linux/uaccess.h>
+#include <linux/utsname.h>
+#include <linux/hardirq.h>
+#include <linux/kdebug.h>
+#include <linux/module.h>
+#include <linux/ptrace.h>
+#include <linux/kexec.h>
+#include <linux/bug.h>
+#include <linux/nmi.h>
+
+#include <asm/stacktrace.h>
+
+int panic_on_unrecovered_nmi;
+int kstack_depth_to_print = 24;
+static unsigned int code_bytes = 64;
+static int die_counter;
+
+void printk_address(unsigned long address, int reliable)
+{
+#ifdef CONFIG_KALLSYMS
+ unsigned long offset = 0;
+ unsigned ...The dumpstack code is logically quite independent from the hardware traps. Split it out into its own file. Signed-off-by: Alexander van Heukelum <heukelum@fastmail.fm> --- arch/x86/kernel/Makefile | 4 +- arch/x86/kernel/dumpstack_64.c | 567 ++++++++++++++++++++++++++++++++++++++++ arch/x86/kernel/traps_64.c | 549 -------------------------------------- 3 files changed, 569 insertions(+), 551 deletions(-) create mode 100644 arch/x86/kernel/dumpstack_64.c diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index ed1af8a..6ccada6 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -24,12 +24,12 @@ CFLAGS_tsc.o := $(nostackp) CFLAGS_paravirt.o := $(nostackp) obj-y := process_$(BITS).o signal_$(BITS).o entry_$(BITS).o -obj-y += traps_$(BITS).o irq_$(BITS).o +obj-y += traps_$(BITS).o irq_$(BITS).o dumpstack_$(BITS).o obj-y += time_$(BITS).o ioport.o ldt.o obj-y += setup.o i8259.o irqinit_$(BITS).o setup_percpu.o obj-$(CONFIG_X86_VISWS) += visws_quirks.o obj-$(CONFIG_X86_32) += probe_roms_32.o -obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o dumpstack_32.o +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o obj-y += bootflag.o e820.o diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c new file mode 100644 index 0000000..11f22d2 --- /dev/null +++ b/arch/x86/kernel/dumpstack_64.c @@ -0,0 +1,567 @@ +/* + * Copyright (C) 1991, 1992 Linus Torvalds + * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs + */ +#include <linux/kallsyms.h> +#include <linux/kprobes.h> +#include <linux/uaccess.h> +#include <linux/utsname.h> +#include <linux/hardirq.h> +#include <linux/kdebug.h> +#include <linux/module.h> +#include <linux/ptrace.h> +#include <linux/kexec.h> +#include <linux/bug.h> +#include <linux/nmi.h> + +#include <asm/stacktrace.h> + +int ...
they are not intrusive at all! The right way to do such things is to would be nice to bring dumpstack_32.c and dumpstack_64.c together as well. While some of the details like IST stack logic (which dont exist on 32-bit) are special, most of the glue, the iterators, the boot parameters, and even the output should be unified some more. Ingo --
applied to tip/x86/traps: # 9bb2b4f: x86_64: split out dumpstack code from traps_64.c # f616942: i386: split out dumpstack code from traps_32.c there were some interactions with other branches: 054efa5: Merge branch 'tracing/nmisafe' into x86/traps 9ecb7cf: Merge branch 'kmemcheck' into x86/traps 8955b63: Merge branch 'core/signal' into x86/traps ff1b7a8: Merge branch 'x86/signal' into x86/traps 76b22d8: Merge commit 'v2.6.27-rc8' into x86/traps b58c936: Merge branch 'x86/core' into x86/traps I hope i sorted them out right. Ingo --
