Skip to contentSkip to conversation

tcore for 2.5.23 kernel

PATCH In review mgross 2 participants 3 messages Jun 19, 2002 – Jun 24, 2002

Subsystems (3)
lore
Share & tools
lore

mgross

author
#0 lore raw

PATCH 1/1 tcore for 2.5.23 kernel

The following is a re-base of the 2.5.22 patch posted yesterday. With the changes to sched.c it needed some minor fix ups to work with the 2.5.23 source.

This patch has been tested on my SMP system and is stable. I would like very much to see this feature added to the 2.5.x kernels and more milage given to it.

To use the core files from multi-threaded applications, created with this patch you may need to strip the objects from /lib/libpthread. For my system 'strip /lib/libpthread-0.9.so makes things good, YMMV.

Please apply this patch.

--mgross

arch/i386/kernel/i387.c +33 -0
diff -urN -X dontdiff linux-2.5.23/arch/i386/kernel/i387.c linux2523.tcore/arch/i386/kernel/i387.c
@@ -528,3 +528,36 @@
 
 	return fpvalid;
 }
+
+int dump_task_fpu( struct task_struct *tsk, struct user_i387_struct *fpu )
+{
+	int fpvalid;
+
+	fpvalid = tsk->used_math;
+	if ( fpvalid ) {
+		if (tsk == current) unlazy_fpu( tsk );
+		if ( cpu_has_fxsr ) {
+			copy_fpu_fxsave( tsk, fpu );
+		} else {
+			copy_fpu_fsave( tsk, fpu );
+		}
+	}
+
+	return fpvalid;
+}
+
+int dump_task_extended_fpu( struct task_struct *tsk, struct user_fxsr_struct *fpu )
+{
+	int fpvalid;
+	
+	fpvalid = tsk->used_math && cpu_has_fxsr;
+	if ( fpvalid ) {
+		if (tsk == current) unlazy_fpu( tsk );
+		memcpy( fpu, &tsk->thread.i387.fxsave,
+		sizeof(struct user_fxsr_struct) );
+	}
+	
+	return fpvalid;
+}
+
+
arch/i386/kernel/process.c +18 -0
diff -urN -X dontdiff linux-2.5.23/arch/i386/kernel/process.c linux2523.tcore/arch/i386/kernel/process.c
@@ -626,6 +626,24 @@
 
 	dump->u_fpvalid = dump_fpu (regs, &dump->i387);
 }
+/* 
+ * Capture the user space registers if the task is not running (in user space)
+ */
+#include <linux/elfcore.h>
+int dump_task_regs(struct task_struct *tsk,  elf_gregset_t *regs)
+{
+	struct pt_regs ptregs;
+	
+	ptregs = *(struct pt_regs *)((unsigned long)tsk->thread_info + THREAD_SIZE - sizeof(struct pt_regs));
+	ptregs.xcs &= 0xffff;
+	ptregs.xds &= 0xffff;
+	ptregs.xes &= 0xffff;
+	ptregs.xss &= 0xffff;
+
+	elf_core_copy_regs(regs, &ptregs);
+
+	return 1;
+}
 
 /*
  * This special macro can be used to load a debugging register
arch/ia64/kernel/process.c +58 -14

105 lines not on this page · raw message

fs/binfmt_elf.c +250 -104

439 lines not on this page · raw message

include/asm-i386/elf.h +10 -0
diff -urN -X dontdiff linux-2.5.23/include/asm-i386/elf.h linux2523.tcore/include/asm-i386/elf.h
@@ -99,6 +99,16 @@
 
 #ifdef __KERNEL__
 #define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
+
+
+extern int dump_task_regs (struct task_struct *, elf_gregset_t *);
+extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *);
+extern int dump_task_extended_fpu (struct task_struct *, struct user_fxsr_struct *);
+
+#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
+#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
+#define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs)
+
 #endif
 
 #endif
include/asm-ia64/elf.h +12 -0
diff -urN -X dontdiff linux-2.5.23/include/asm-ia64/elf.h linux2523.tcore/include/asm-ia64/elf.h
@@ -65,12 +65,16 @@
 #define ELF_NGREG	128	/* we really need just 72 but let's leave some headroom... */
 #define ELF_NFPREG	128	/* f0 and f1 could be omitted, but so what... */
 
+typedef unsigned long elf_fpxregset_t;
+
 typedef unsigned long elf_greg_t;
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 typedef struct ia64_fpreg elf_fpreg_t;
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
 
+
+
 struct pt_regs;	/* forward declaration... */
 extern void ia64_elf_core_copy_regs (struct pt_regs *src, elf_gregset_t dst);
 #define ELF_CORE_COPY_REGS(_dest,_regs)	ia64_elf_core_copy_regs(_regs, _dest);
@@ -88,6 +92,14 @@
 struct elf64_hdr;
 extern void ia64_set_personality (struct elf64_hdr *elf_ex, int ibcs2_interpreter);
 #define SET_PERSONALITY(ex, ibcs2)	ia64_set_personality(&(ex), ibcs2)
+
+extern int dump_task_regs(struct task_struct *, elf_gregset_t *);
+extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *);
+
+#define ELF_CORE_COPY_TASK_REGS(tsk, elf_gregs) dump_task_regs(tsk, elf_gregs)
+#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
+
+
 #endif
 
 #endif /* _ASM_IA64_ELF_H */
include/linux/elf.h +3 -1
diff -urN -X dontdiff linux-2.5.23/include/linux/elf.h linux2523.tcore/include/linux/elf.h
@@ -576,6 +576,9 @@
 #define NT_PRPSINFO	3
 #define NT_TASKSTRUCT	4
 #define NT_PRFPXREG	20
+#define NT_PRXFPREG     0x46e62b7f	/* note name must be "LINUX" as per GDB */
+					/* from gdb5.1/include/elf/common.h */
+
 
 /* Note header in a PT_NOTE section */
 typedef struct elf32_note {
@@ -606,6 +609,5 @@
 #define elf_note	elf64_note
 
 #endif
-
 
 #endif /* _LINUX_ELF_H */
include/linux/elfcore.h +44 -0

48 lines not on this page · raw message

include/linux/sched.h +8 -0
diff -urN -X dontdiff linux-2.5.23/include/linux/sched.h linux2523.tcore/include/linux/sched.h
@@ -131,6 +131,14 @@
 
 #include <linux/spinlock.h>
 
+
+/* functions for pausing and resumming functions 
+ * common mm's without using signals.  These are used
+ * by the multithreaded elf core dump code in binfmt_elf.c*/
+extern void tcore_suspend_threads( void );
+extern void tcore_resume_threads( void );
+
+
 /*
  * This serializes "schedule()" and also protects
  * the run-queue from deletions/modifications (but
kernel/sched.c +168 -7

225 lines not on this page · raw message

Binary files linux-2.5.23/scripts/fixdep and linux2523.tcore/scripts/fixdep differ

#1 lore raw

Hi!

Quoted 3 lines

This patch has been tested on my SMP system and is stable. I would like very much to see this feature added to the 2.5.x kernels and more milage given to it.

Minor comments:

kernel/sched.c line 1112

Quoted 4 lines
kernel/sched.c +4 -0
+//
+// grab all the rq_locks.
+// current is the process dumping core
+//  

Do not use C++ style comments in kernel.

kernel/sched.c line 1140

Quoted 1 line
kernel/sched.c +1 -0
+				threads[OnCPUCount] = p;

on_cpu_count, this is gnu stile, not java.
Pavel

Signature · 2 lines
(about SSSCA) "I don't say this lightly.  However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa
author
#2 lore raw

Thanks for the input, I'll tweak these things on my next re-base of the patch.

--mgross

Quoted 18 lines · Pavel Machek

Hi!

Quoted 3 lines

This patch has been tested on my SMP system and is stable. I would like very much to see this feature added to the 2.5.x kernels and more milage given to it.

Minor comments:

kernel/sched.c line 1112

Quoted 4 lines
kernel/sched.c +4 -0
+//
+// grab all the rq_locks.
+// current is the process dumping core
+//

Do not use C++ style comments in kernel.

kernel/sched.c line 1140

Quoted 1 line
kernel/sched.c +1 -0
+				threads[OnCPUCount] = p;

on_cpu_count, this is gnu stile, not java.
Pavel